GNU make manual 翻译( 九十八)

简介:

继续翻译

复制代码
4.6 Phony Targets
=================

   A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request.  There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve performance.

   If you write a rule whose recipe will not create the target file, the recipe will be executed every time the target comes up for remaking. Here is an example:

     clean:
             rm *.o temp

Because the `rm' command does not create a file named `clean', probably no such file will ever exist.  Therefore, the `rm' command will be executed every time you say `make clean'.  
复制代码

4.6 伪目标
=================

伪目标不是一个文件的真实名字,它其实只是一个,你给make显式要求时要执行的片段的名字。

有两个原因需要使用伪目标: 防止和同名的文件冲突,提高性能。

如果你写了一个规则,其片段不是要创建目的文件,这个规则可以每次运行。下面是一个例子:

clean:
rm *.o temp

因为 rm 命令不生成一个名为 clean 的文件,可能这个文件也永远不会存在,因此,每次你输入 make clean 时,这个rm 命令都会得到执行。

后文翻译


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

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