【发布时间】:2012-01-19 04:42:19
【问题描述】:
我遇到了 GNU make 3.81 不删除中间文件的问题。该问题类似于GNU make Not Deleting Intermediate Files,但该答案并不能解决我的问题。我已将问题提炼到这个测试用例:
default:
@echo no $@ target; exit 1
oncetwice: once twice
@echo $@: $^
## Uncommenting the following line is sufficient to cause GNU make 3.81 to
## not delete the intermediate 'twice.dep', even if it didn't exist
## previously (i.e., was created by this invocation).
#another: twice.dep
%: %.dep
@echo $^ >$@
## the following .INTERMEDIATE has no effect re: the twice: twice.dep
## dependency
.INTERMEDIATE: %.dep
%.dep:
@echo $@ >$@
注意命令块必须是制表符缩进的。
也就是说,目标once 依赖于once.dep,而twice 依赖于twice.dep。此外,another 还依赖于twice.dep。正是这一行导致 twice.dep 永远不会被删除,即使 make 创建了它并且尽管有 .INTERMEDIATE 行。
发布的 Makefile 给出:
snafu$ rm -f once* twice*; make oncetwice
oncetwice: once twice
rm once.dep twice.dep
取消注释twice: twice.dep 行:
snafu$ rm -f once* twice*; make oncetwice
oncetwice: once twice
rm once.dep
请注意,在第二次调用中, two.dep 不是 rm'd。
来自信息页面:
.INTERMEDIATE
The targets which .INTERMEDIATE depends on are treated as intermediate files.
[...]
Intermediate files are remade using their rules just like all other
files. But intermediate files are treated differently in two ways.
The first difference [...]
**The second difference is that if make does create b in order to update
something else, it deletes b later on after it is no longer
needed. Therefore, an intermediate file which did not exist before make
also does not exist after make.**
我尝试使用命令块将another: twice.dep 设为真正的规则。我还尝试了将 .INTERMEDIATE 指定为模式、文字文件名以及两者的变体。我也尝试过使用.PHONY。 make-3.82 NEWS 似乎没有任何相关的修复。我目睹的行为看起来更像 .SECONDARY 目标所描述的行为。
谢谢,
里斯
【问题讨论】: