zoukankan      html  css  js  c++  java
  • GNU make manual 翻译(九十九)

    继续翻译

       The phony target will cease to work if anything ever does create a
    file named `clean' in this directory.  Since it has no prerequisites,
    the file `clean' would inevitably be considered up to date, and its
    recipe would not be executed.  To avoid this problem, you can explicitly
    declare the target to be phony, using the special target `.PHONY'
    (*note Special Built-in Target Names: Special Targets.) as follows:
    
         .PHONY : clean
    
    Once this is done, `make clean' will run the recipe regardless of
    whether there is a file named `clean'.
    
       Since it knows that phony targets do not name actual files that
    could be remade from other files, `make' skips the implicit rule search
    for phony targets (*note Implicit Rules::).  This is why declaring a
    target phony is good for performance, even if you are not worried about
    the actual file existing.

    如果在目录下创建了名为 clean 的文件,则此伪目标将停止工作。因为它没有前提条件,文件clean 会被认为是最新的,它的片段不会被执行。为了回避这个问题,你可以显式声明此目的为伪--使用特殊的目的--.PHONY(*note Special Built-in Target Names: Special Targets.),如下;

    .PHONY : clean

    当这个做好以后,make clean 无论 是否有一个名为 clean 的文件存在,都会执行片段。

    由于make 知道,伪目标不会命名从其他文件而重新创建的文件名,它会跳过对伪目标的隐式规则搜索(*note Implicit Rules::),这是为何定义伪目标有利于提高性能,甚至你根本不需担心是否实际的文件存在。

    后文待续

  • 相关阅读:
    Alpha 冲刺 (7/10)
    Alpha 冲刺 (6/10)
    同学录
    Alpha 冲刺 (5/10)
    Letcode刷题总结知识点
    python 基础语法
    Python 文件读写与编码解读
    py2exe界面和程序开发打包
    求职者五险一金解读
    互联网企业程序题总结
  • 原文地址:https://www.cnblogs.com/gaojian/p/2694748.html
Copyright © 2011-2022 走看看