- 可使用变量名
引用名=文件群
,使用时 引用方法$(变量名)
- command前加tab。注意最后有clean。会自动联想。
例1,普通makefile
obj=test1.o test2.o test3.o
test: $(obj)
cc -o test $(obj)
.PHONY: clean
clean:
rm test $(obj)
例2,调用文件下所有makefile
SUBDIRS := $(wildcard */.)
all: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
clean:
find . -name "*.o" | xargs rm -f
find . -name "test" | xargs rm -f
find . -name "test1" | xargs rm -f
find . -name "test2" | xargs rm -f
find . -name "test3" | xargs rm -f
.PHONY: all $(SUBDIRS) clean