GNU make manual 翻译(十五)

本文解析了Makefile中的phony targets概念,解释了为何某些目标仅作为动作而非文件引用,并介绍了如何处理这些目标及其相关的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

继续翻译

复制代码
   The target `clean' is not a file, but merely the name of an action.    
Since you normally do not want to carry out the actions in this rule,    
`clean' is not a prerequisite of any other rule.  Consequently, `make'    
never does anything with it unless you tell it specifically.  Note that    
this rule not only is not a prerequisite, it also does not have any    
prerequisites, so the only purpose of the rule is to run the specified    
recipe.  Targets that do not refer to files but are just actions are    
called "phony targets".  *Note Phony Targets::, for information about    
this kind of target.  *Note Errors in Recipes: Errors, to see how to    
cause `make' to ignore errors from `rm' or any other command.      
复制代码
 目的 clean 不是一个文件,是一个动作的名称。

 由于通常你不会想要执行此规则中的动作,clean 不是任何其他 rule 的 前提条条件。

除非你只告诉它要这么做,make 绝不会执行 clean 的。

注意这个规则(的目的)不但不是任何其他规则的前提条件,它自身也没有任何前提条件。

所以,各个规则的唯一作用就是要运行特定的片段。

与文件无关只是执行动作的 目的,被称为伪目的(phony targets)。

可以参考 (*Note Phony Targets) 进行相应的了解。

可以参考 (*Note Errors in Recipes:Errors),了解如何使得 make 忽略错误(如执行rm导致)。

后文待续


本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/12/2681993.html,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值