1
ivan_wl 2022-04-24 09:44:37 +08:00 1
make 可以 shell 调用命令,如果非要用纯 make 实现的话,我目前项目中使用的:
rwildcard = $(strip $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))) findall = $(foreach d,$1,$(call rwildcard,$(strip $d)/,$(strip $2))) C_SRCS := $(call findall, $(PRJ_SCOPE), *.c) H_SRCS := $(call findall, $(PRJ_SCOPE), *.h) 参考 https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make |
2
mxx894 2022-04-24 21:12:01 +08:00 1
可以调用 find 命令,生成依赖。另外 makefile 的推导功能很强大。
C_SOURCES = $(shell find ./ -type f -iname "*.c") OBJECTS += $(addprefix $(BUILD)/Obj/,$(notdir $(C_SOURCES:%.c=%.o))) |