我建议你用Linux内核编译的模板——Kbuild,这个是我见过的最美观、最直观的Makefile编译模板。只要前期搭建好架子之后,后续再扩容也极其方便。
obj1=main.o
obj2=main.debug.o
target1=test
target2=test_debug
all: $(target1) $(target2)
clean:
rm -rf $(obj1) $(obj2) $(target1) $(target2)
%.o:%.c
gcc -c $< -o $@
%.debug.o:%.c
gcc -D_DEBUG -c $< -o $@
$(target1):$(obj1)
gcc -o $@ $^ -lpthread
$(target2):$(obj2)
gcc -g -o $@ $^ -lpthread
自己写吧,Makefile必须自己练过!
给我邮箱,发给你