我想像这样定义一些规则:
x-9: y-9 z-9 x-8
python gen-files.py --out-x=x-9 --out-y=y-9 --in-x=x-8
x-8: y-8 z-8 x-7
python gen-files.py --out-x=x-8 --out-y=y-8 --in-x=x-7
x-7: y-7 z-7 x-6
python gen-files.py --out-x=x-7 --out-y=y-7 --in-x=x-6
x-6: y-6 z-6 x-5
python gen-files.py --out-x=x-6 --out-y=y-6 --in-x=x-5
x-5: y-5 z-5 x-4
python gen-files.py --out-x=x-5 --out-y=y-5 --in-x=x-4
x-4:
touch x-4如你所见,基本的想法是我有一个目标
outputfile-NUMBER:
它有两个依赖项,要么在它们的名称中包含NUMBER,要么在它们的名称中包含NUMBER-MINUS-ONE。
我的目标是当我尝试构建最终目标时,它会自动x-8,x-7...下到x-4。
我试过这样的东西
define oprule
x-$(1): x-$(1) y-$(1) z-$(1) x-$(2)
python gen-files.py --out-x=x-$(1) --out-y=y-$(1) --in-x=x-$(2)
endef
ttt = 9 8 7 6 5
$(foreach now, $(ttt), \
$(call oprule, $(now), $(shell $$(( $(now)-1 )) ) ) )我认为这会生成5条规则,但当我尝试时
make x-9我明白
Makefile:93: *** multiple target patterns. Stop.我不知道会发生什么。
发布于 2019-06-24 22:20:55
它应该是
define oprule
x-$(1): y-$(1) z-$(1) x-$(2)
python gen-files.py --out-x=x-$(1) --out-y=y-$(1) --in-x=x-$(2)
endefendef之前的最后一个换行符总是被吃掉(就像define之后的第一个换行符一样)。因此,您必须再创建一个,以便foreach生成正确的行分割(或者在调用$(nl)之后添加某种oprule宏)。
附注:也不要在逗号后面加空格。虽然在这种情况下不会有什么坏处,但通常情况下,空格对于make是很重要的。
https://stackoverflow.com/questions/56736662
复制相似问题