Makefile通用模板

Friday, Sep 23, 2022 | 1 minute read | Updated at Friday, Sep 23, 2022

@
Makefile通用模板

简单makefile套用模板

# 编译当前文件夹下的所有cpp文件
CC=g++ -std=c++11
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
target := $(basename $(objects))

all: $(target)

$(target): $(objects)
        $(CC) -o $@ $@.o

$(objects): %.o: %.cpp
        $(CC) -c $(CLFAGS) $< -o $@

.PHONY : clean
clean:
        rm $(target) $(objects)
CC=g++ -std=c++11
target := $(patsubst %.cpp,%,$(wildcard *.cpp))
all: $(target)
clean:
	rm $(target)

© 2016 - 2025 Caisong's Blog

🌱 Powered by Hugo with theme Dream.

About Me

大龄程序员,喜欢折腾各种环境部署、软件应用。

博客记录日常。