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::),这是为何定义伪目标有利于提高性能,甚至你根本不需担心是否实际的文件存在。

    后文待续

  • 相关阅读:
    Winform—C#读写config配置文件
    C# 中Web.config文件的读取与写入
    Redis配置文件详解
    三层架构之泛型抽象
    Linq To Sql语法及实例大全
    junit单元测试(keeps the bar green to keeps the code clean)
    观 GT Java语言管理系统的感悟
    java考核完的心得
    15个C++项目列表
    C++文件操作(fstream)
  • 原文地址:https://www.cnblogs.com/gaojian/p/2694748.html
Copyright © 2011-2022 走看看