Makefilehtml
SUBDIRS = xxx aaa BUILDSUBDIRS = $(SUBDIRS:%=build-%) CLEANSUBDIRS = $(SUBDIRS:%=clean-%) .PHONY: all clean all: $(BUILDSUBDIRS) $(BUILDSUBDIRS): @echo "<===" $@ make -C $(@:build-%=%) @echo ">===" $@ @echo "\n" clean: $(CLEANSUBDIRS) $(CLEANSUBDIRS): @echo "<===" $@ make -C $(@:clean-%=%) clean @echo "===>" $@ @echo "\n"
================================================
CLEANSUBDIRS = $(SUBDIRS:%=clean-%):
SUBDIRS 變數裡的元素,
如有符合 % pattern,(%是萬用字元,也可表明不少字)
則使用 clean-% 這個 pattern 送元素出去。
make -C $(@:clean-%=%) clean :
$@ 是表明 target,
$@ = $(@),
(@:clean-%=%) 是說 target 裡的元素,
若符合 clean-% 的 pattern,
則使用 % 這個 pattern 送元素出去ui
================================================
在 command line 執行.net
$ make
此指令是 build first target,
在 此例就是 all,
若 all 和 clean target 對換,code
$ make
就是執行 make clean,
並不是 make 就是必定 build all
================================================htm
reference:
http://vincentlogistics.blogspot.com/2014/05/makefile-recursive-make.html
http://lackof.org/taggart/hacking/make-example/
https://blog.csdn.net/a827415225/article/details/73414696
https://www.cnblogs.com/wang_yb/p/3990952.htmlblog