Makefile GNU在shell命令中生成扩展模式
我需要一个小程序通过检查文件来确定文件的先决条件。具体地说:Makefile GNU在shell命令中生成扩展模式,makefile,gnu-make,Makefile,Gnu Make,我需要一个小程序通过检查文件来确定文件的先决条件。具体地说: %.bar: $(shell python get_preqs.py %.foo) # % in shell is not substituted python gen_bar.py $^ $@ 但是,这不起作用,因为shell命令中的%不会被make替换。有没有办法做到这一点?您可以使用GNU make的: .SECONDEXPANSION: %.bar: $$(shell python get_prereqs.py $
%.bar: $(shell python get_preqs.py %.foo) # % in shell is not substituted
python gen_bar.py $^ $@
但是,这不起作用,因为shell命令中的%
不会被make替换。有没有办法做到这一点?您可以使用GNU make的:
.SECONDEXPANSION:
%.bar: $$(shell python get_prereqs.py $$*.foo)
python gen_bar.py $^ $@
另一种选择是使用更适合动态目标的构建工具。例如,我编写了一个Gnu Make-like工具,其中包含了DJB重做中的一些概念,名为。您的等效makefile只是:
#? *.bar
preqs=$(python get_preqs.py ${1%.bar}.foo)
$0 $preqs
python gen_bar.py $preqs $1