当前目录下所有.cpp文件编译为-o文件
最后生成main.exe
CXX=g++
TARGET=main
SRC=$(wildcard *.cpp)
OBJ=$(patsubst *.cpp ,-o ,$(SRC))
CXXFLAGS=-c -Wall
$(TARGET):$(OBJ)
$(CXX) -o $(TARGET) $(OBJ)
%.o:%.cpp
$(CXX) $(CXXFLAGS) $< -o $@
clean:
del *.o $(TARGET).exe
标签:%.,OBJ,TARGET,CXX,makefile,CXXFLAGS,cpp
From: https://www.cnblogs.com/cnleika/p/17191531.html