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。

后文待续






本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/02/2710333.html,如需转载请自行联系原作者

目录
相关文章
|
Linux C语言
make: gcc:命令未找到
make: gcc:命令未找到
make: gcc:命令未找到
|
编译器 Linux 开发工具
|
9月前
|
存储 编译器 C语言
深入理解GCC 和 G++ 编译器
GCC 和 G++ 是 GNU 工具链中的核心编译器,支持 C 和 C++ 程序开发。本文详细介绍其编译流程、常用选项及动态链接与静态链接的区别。编译过程分为预处理、编译、汇编和链接四个阶段,每个阶段有特定任务和命令选项。常用选项如 `-E`、`-S`、`-c` 和 `-o` 分别用于预处理、生成汇编代码、生成目标文件和指定输出文件。动态链接节省空间且易于更新,但依赖运行时库;静态链接独立高效,但文件较大且更新困难。合理选择优化选项(如 `-O0` 至 `-O3`)可提升程序性能。掌握这些知识有助于开发者更高效地编写、调试和优化代码。
382 23
深入理解GCC 和 G++ 编译器