makefile意外删除目标 [英] makefile unexpectedly removes target
本文介绍了makefile意外删除目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个最小的例子:
%.txt: foo.log
# pass
%.log:
# pass
运行:
$ make a.txt --dry-run
# pass
# pass
rm foo.log
为什么最后一个动作 rm foo.log
?我该如何摆脱呢?
Why is the last action rm foo.log
?
How can I get rid of it?
推荐答案
默认情况下,GNU make会删除中间文件.由于%.txt取决于%.log,因此make希望删除.log文件.为了防止这种行为,您可以使用.PRECIOUS或.SECONDARY将它们标记为珍贵.
By default, GNU make removes intermediate files. Since %.txt depends on %.log, make wants to remove the .log file. To prevent that behavior you mark them as precious with .PRECIOUS or .SECONDARY.
.PRECIOUS: foo.log
此外,您还可以使用.SECONDARY来创建没有依赖项的中间文件.
Also, you can make it so that no intermediate files are ever removed by using .SECONDARY with no dependencies.
.SECONDARY:
请参见GNU的此部分制作手册.
See this section of the GNU make manual.
这篇关于makefile意外删除目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文