GNU make manual 翻译( 九十八)

本文解释了Makefile中伪目标的概念,包括它们的作用、如何使用以及实例演示。

继续翻译

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 命令都会得到执行。

后文翻译

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值