CXX = g++
src = $(wildcard *.cpp)
head = $(shell find ./ -name "*.h")
obj = $(src:%.cpp=%.o)
target = $(patsubst %.cpp, %, $(src))
INCS = -I./colib
LIBS = -L./colib -lcolib -lpthread -ldl
CFLAGS += -g
all:$(target)
$(target):%:%.o
$(CXX) $(INCS) $(CFLAGS) $^ -o $@ $(LIBS)
%.o:%.cpp
$(CXX) $(INCS) $(CFLAGS) -c $< -o $@ $(LIBS)
.PHONY:all clean
clean:
@echo "clean "+$(obj)+$(target)
rm -rf $(obj) $(target)
适用情况:该目录下一个cpp生成一个同名可执行文件