|
要對(duì)子目錄執(zhí)行make,需要在當(dāng)前目錄制作一個(gè)Makefile,遍歷所有子目錄的Makefile,并運(yùn)行相應(yīng)的make target. # # Reference http://www./software/make/manual/make.html # # 需要排除的目錄 exclude_dirs := include bin # 取得當(dāng)前子目錄深度為1的所有目錄名稱 dirs := $(shell find . -maxdepth 1 -type d) dirs := $(basename $(patsubst ./%,%,$(dirs))) dirs := $(filter-out $(exclude_dirs),$(dirs)) # 避免clean子目錄操作同名,加上_clean_前綴 SUBDIRS := $(dirs) clean_dirs := $(addprefix _clean_,$(SUBDIRS) ) # .PHONY: subdirs $(SUBDIRS) clean # 執(zhí)行默認(rèn)make target $(SUBDIRS): $(MAKE) -C $@ subdirs: $(SUBDIRS) # 執(zhí)行clean $(clean_dirs): $(MAKE) -C $(patsubst _clean_%,%,$@) clean clean: $(clean_dirs) @find . \ \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' \) \ -type f -print | xargs rm -f |
|
|
來(lái)自: jijo > 《Makefile》