zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百五十二)

    继续翻译

    5.9 Using Empty Recipes
    =======================
    
    It is sometimes useful to define recipes which do nothing.  This is done
    simply by giving a recipe that consists of nothing but whitespace.  For
    example:
    
         target: ;
    
    defines an empty recipe for `target'.  You could also use a line
    beginning with a recipe prefix character to define an empty recipe, but
    this would be confusing because such a line looks empty.
    
       You may be wondering why you would want to define a recipe that does
    nothing.  The only reason this is useful is to prevent a target from
    getting implicit recipes (from implicit rules or the `.DEFAULT' special
    target; *note Implicit Rules:: and *note Defining Last-Resort Default
    Rules: Last Resort.).
    
       You may be inclined to define empty recipes for targets that are not
    actual files, but only exist so that their prerequisites can be remade.
    However, this is not the best way to do that, because the prerequisites
    may not be remade properly if the target file actually does exist.
    *Note Phony Targets: Phony Targets, for a better way to do this.

    5.9 使用空片段
    =======================

    有时候定义什么也不做的片段也是有用的。这是由给出一个只有空格的片段来实现。例如:

    target: ;

    定义了了对'target' 的空片段。你可以用一个开头有片段前缀符的行来开始一个空片段,但是这样会造成困扰因为这个行看起来像空的。

    你也许会奇怪,为何你需要定义一个什么也不做的片段。唯一的原因是可以防止一个目的获得隐式的片段(从隐式规则或者从 .DEFAULT 特殊目的中获得;*note Implicit Rules:: 和 *note Defining Last-Resort Default Rules: Last Resort)

    为不是实际文件的目的而定义空片段也许比较怪异,但是仅仅是当它们的前提条件可以被重新建立时才应该这么做。但是这不是最佳的方式,因为,如果目的文件真实存在,前提脚尖可能不会被正确的重建。更好地办法,应当参考:*Note Phony Targets: Phony Targets。

    后文待续

  • 相关阅读:
    Python学习(五)函数 —— 自定义函数
    Python学习(四)数据结构 —— dict
    Python学习(四)数据结构 —— set frozenset
    C++ —— 构建开源的开发环境
    Oracle 数据库 Database Express Edition 11g Release 2 (11.2) 错误解决集锦(使用语法)
    Web —— tomcat 问题解决
    web —— jsp笔记
    Web 前端 —— javaScript
    编程杂谈—— 浮点数
    Web —— java web 项目开发 笔记
  • 原文地址:https://www.cnblogs.com/gaojian/p/2710333.html
Copyright © 2011-2022 走看看