本文介绍了为什么这个makefile删除了我的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个最小的例子:
%.txt: foo.log # pass %.log: # pass运行:
$ make a.txt --dry-run # pass # pass rm foo.log为什么最后一个动作是rm foo.log? 如何摆脱它?
Why the last action is rm foo.log? How to 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删除了我的目标?
发布评论