【发布时间】:2015-08-15 17:14:52
【问题描述】:
我有这样的文件和目录结构:
.
├── Makefile
└── packages
├── Makefile
└── subdir
└── Makefile
顶部的 Makefile 看起来像这样:
define aa
make -C $1 $2
endef
packages=$(shell find ./packages -type d)
p1=$(filter-out . .., $(packages))
all:
$(foreach f,$(p1),$(call aa,$(f),compile))
./packages/ 和 ./packages/subdir/ 中的 Makefile 都有“编译”目标。
我正在尝试在“packages”子目录中自动调用所有 Makefile,而不是将它们单独添加到 Makefile 中。
当我在顶级目录中运行 make 时出现错误:
make -C ./packages compile make -C ./packages/subdir compile
make[1]: *** packages/subdir: No such file or directory. Stop.
Makefile:16: recipe for target 'all' failed
make: *** [all] Error 2
我想知道为什么 make 的两个调用(应该是单独的调用)都放在一行中?
当我像这样在“aa”宏的末尾添加行尾时:
define aa
make -C $1 $2
endef
一切都按预期进行。 我的问题是为什么没有这个行尾这个宏就不能工作?
【问题讨论】:
标签: makefile