简单地说,我想在Makefile中为规则命名:
A.ext : B.ext
compute A.ext from B.ext
所以我得到这样的东西:
.PHONY : my_rule
A.ext : my_rule
my_rule : B.ext
compute A.ext from B.ext
但这还不等同于第一个,因为即使B.ext没有改变,my_rule
总是被执行。我怎样才能实现等价?
这是make -d
的修剪输出:
Considering target file `A.ext'.
Considering target file `my_rule'.
File `my_rule' does not exist.
Considering target file `B.ext'.
Finished prerequisites of target file `B.ext'.
No need to remake target `B.ext'.
Finished prerequisites of target file `my_rule'.
Must remake target `my_rule'.
(我想要的原因是我有另一条规则C.ext :| my_rule
。)
答案 0 :(得分:1)
.PHONY : my_rule
my_rule: A.ext
A.ext : B.ext
compute A.ext from B.ext
或better:
.PHONY : my_rule
my_rule: A.ext
A.ext : B.ext
compute $@ from $<