为什么这个makefile删除了我的目标?

编程入门 行业动态 更新时间:2024-10-17 08:24:32
本文介绍了为什么这个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删除了我的目标?

本文发布于:2023-11-01 01:56:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547914.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目标   makefile

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!