0
我有如下所示生成文件:为什么在使用模式规则时,GNU make会删除中间目标?
.PHONY: all
all: foo_1.txt foo_2.txt foo_xxx.txt
.PHONY: clean
clean:
rm -f foo_* bar_*
foo_%.txt: bar_%.txt
cp $< [email protected]
#.PRECIOUS: bar_%.txt
bar_%.txt:
touch [email protected]
bar_2.txt:
touch [email protected]
的“使所有”的输出如下因素使用图案由规则创建
touch bar_1.txt
cp bar_1.txt foo_1.txt
touch bar_2.txt
cp bar_2.txt foo_2.txt
touch bar_xxx.txt
cp bar_xxx.txt foo_xxx.txt
rm bar_xxx.txt bar_1.txt
中间文件(bar_xxx.txt,bar_1.txt )在最后被删除。我发现这种行为可以通过.PRECIOUS(在代码中是故意注释掉的行)来抑制。
为什么默认情况下已删除模式的规则创建的中间文件以及无模式规则创建的文件不是?