makefile .PHONY

本文介绍了 Makefile 中 PHONY 特殊规则的作用及其使用方法。PHONY 规则告诉 Make 哪些目标不是文件,避免了与同名文件发生冲突,并提高了构建性能。文中通过实例演示了如何定义 PHONY 目标,以及它们在 Make 运行过程中的行为特征。
makefile .PHONY
The special rule .PHONY tells Make which targets are not files. This avoids conflict with files of the same name, and improves performance.
If a phony target is included as a prerequisite for another target, it will be run every time that other target is required. Phony targets are never up-to-date.


请看下面的例子,当你创建了一个叫clean的文件,然后再调用make事,clean不会被调用。

[jialiang@ht191w tmp]$ ll
total 4
-rw-rw-r-- 1 jialiang users 29 May 17 12:51 mk
[jialiang@ht191w tmp]$ cat mk
clean:
        echo "clean running"
[jialiang@ht191w tmp]$ make -f mk
echo "clean running"
clean running
[jialiang@ht191w tmp]$ touch clean
[jialiang@ht191w tmp]$ make -f mk
make: `clean' is up to date.
[jialiang@ht191w tmp]$ vi mk
[jialiang@ht191w tmp]$ cat mk
.PHONY: clean
clean:
        echo "clean running"
[jialiang@ht191w tmp]$ make -f mk
echo "clean running"
clean running




http://hi.baidu.com/%D1%CC%D3%EA%BB%C6%BB%E82009/blog/item/8c5d04762616f400b051b996.html
http://linuxdevcenter.com/pub/a/linux/2002/01/31/make_intro.html?page=2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值