【发布时间】:2018-08-04 13:30:44
【问题描述】:
我想在循环中使用变量 KDIR 进行子制作,并将其传递给在 module/ 文件夹中调用的 Makefile。
sub_make=$(MAKE) -C module all KDIR=$(1);
SUB_DIRS= k1 k2 k3
all:
@$(foreach n, $(SUB_DIRS), $(call sub_make, $(n)))
module/文件夹中Makefile的内容很简单,如下:
all:
echo $(KDIR)
但我收到以下错误:
make[1]: *** No rule to make target 'k1'. Stop.
make[1]: Leaving directory '/home/r/Desktop/work/test/module'
make[1]: Entering directory '/home/r/Desktop/work/test/module'
echo
make[1]: *** No rule to make target 'k2'. Stop.
make[1]: Leaving directory '/home/r/Desktop/work/test/module'
make[1]: Entering directory '/home/r/Desktop/work/test/module'
echo
make[1]: *** No rule to make target 'k3'. Stop.
make[1]: Leaving directory '/home/r/Desktop/work/test/module'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
谁能解决?
【问题讨论】:
-
make 调试的第一条规则:删除
@修饰符然后仔细查看正在调用的命令。在您的 makefile 完全工作后的最后一件事之前,您永远不应该添加@。实际上最好不要添加它们,而是使用诸如make.mad-scientist.net/managing-recipe-echoing之类的方法...