我有以下 GNU 生成文件:
.PHONY a b c d
a: b c
b: d
c: d
d:
echo HI
我希望目标“d”运行两次——因为它被 b&c 指定为依赖项。不幸的是,目标 'd' 将只执行一次。运行 make 的输出将只是“HI”,而不是“HI HI”。
我怎样才能解决这个问题?
谢谢!
澄清一下,目标是这样的:
subdirs = a b c
build: x y
x: target=build
x: $(subdirs)
y: target=prepare
y: $(subdirs)
$(subdirs):
$(make) -f $@/makefile $(target)
最佳答案
build: x y
x: target=build
y: target=prepare
x y:
echo hi $(target) $@
touch $@
另见 GNU Makefile rule generating a few targets from a single source file因为它是对与此相反的问题的答案。
关于build-process - 指定为对多个规则的依赖时重新执行目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1218019/