繼續翻譯
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: FORCErm $(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::
后文待續