【发布时间】:2015-08-09 08:15:31
【问题描述】:
来自docs:
通常当配方行失败时,如果它改变了目标文件 根本上,文件已损坏且无法使用——或者至少它不是 完全更新。然而文件的时间戳表明它现在是 日期,因此下次运行“make”时,它不会尝试更新该文件。 情况与shell被信号杀死时的情况相同; *注意中断::.所以通常正确的做法是删除 目标文件,如果配方在开始更改文件后失败。 如果“.DELETE_ON_ERROR”作为目标出现,“make”将执行此操作。这是 几乎总是你想要“制作”的东西,但这不是历史性的 实践;所以为了兼容性,你必须明确地请求它。
所以,这里我有一个makefile:
# The idea here is to auto-generate the file ('make.include')
# and to use it as a makefile.
# For simplicity, I replaced the "auto-generate" part, with "touch".
# I also simplified the dependency-tree with 'phony'.
# In practice, we re-generate, only when "need" to.
make.include : phony
+touch '$@'
make -f '$@'
.PHONY: phony
跑步:
$ make -q
我明白了:
touch 'make.include'
make: *** Deleting file 'make.include'
现在,我不知道如何防止 make 删除这个新自动生成的“make.include”(重新运行可能是一个相当昂贵的过程),除非我求助于 .PRECIOUS 特殊目标。
但是,要求用户明确定义他们的“宝贵”目标,并不符合上述文档中的引用。对吧?
【问题讨论】:
标签: makefile