继续翻译
4.7 Rules without Recipes or Prerequisites ========================================== If a rule has no prerequisites or recipe, and the target of the rule is a nonexistent file, then `make' imagines this target to have been updated whenever its rule is run. This implies that all targets depending on this one will always have their recipe run. An example will illustrate this: clean: FORCE rm $(objects) FORCE: Here the target `FORCE' satisfies the special conditions, so the target `clean' that depends on it is forced to run its recipe. There is nothing special about the name `FORCE', but that is one name commonly used this way. As you can see, using `FORCE' this way has the same results as using `.PHONY: clean'. Using `.PHONY' is more explicit and more efficient. However, other versions of `make' do not support `.PHONY'; thus `FORCE' appears in many makefiles. *Note Phony Targets::.
4.7 没有片段或前提条件的规则
==========================================
如果一个规则没有前提条件或者片段,并且此规则的目的是一个尚未存在的文件,那么 make 将认为此目的在任何一次make 运行时都已经被更新。这暗示着每个依赖于此的目的都总是运行其片段。
例子是这样的:
clean: FORCE
rm $(objects)
FORCE:
这里,目的 FORCE 满足前面所述的特定的条件,于是依赖此 目的的 目的 clean 被强制执行。这里的名字 FORCE 没有任何特殊之处,但是是一个通常被使用的名字。
如你所见,采用这种方法用 FORCE 和用 .PHONY: clean 是一样的效果。
使用 .PHONY 更佳的明确和更有效率,但是其他版本的 make ,有的不支持 .PHONY 语法;因此你会在某些 makefile里面看到 FORCE 出现。 *Note Phony Targets::
后文待续