GNU make manual 翻译( 一百零二)

继续翻译

复制代码
   A phony target should not be a prerequisite of a real target file;if it is, its recipe will be run every time `make' goes to update that file.  As long as a phony target is never a prerequisite of a real target, the phony target recipe will be executed only when the phony target is a specified goal (*note Arguments to Specify the Goals:
Goals.).

   Phony targets can have prerequisites.  When one directory contains multiple programs, it is most convenient to describe all of the programs in one makefile `./Makefile'.  Since the target remade bydefault will be the first one in the makefile, it is common to make this a phony target named `all' and give it, as prerequisites, all the individual programs.  For example:

     all : prog1 prog2 prog3
     .PHONY : all

     prog1 : prog1.o utils.o
             cc -o prog1 prog1.o utils.o

     prog2 : prog2.o
             cc -o prog2 prog2.o

     prog3 : prog3.o sort.o utils.o
             cc -o prog3 prog3.o sort.o utils.o
复制代码

一个伪目的不应当是一个真的目的的前提条件;如果是,它的片段将会在每次运行make 时被执行。正因为伪目的永远不会是一个真正的目的,所以伪目的的片段才能在仅当其为特殊终点时才获得运行。(*note Arguments to Specify the Goals:Goals)

伪目的自身可以有前提条件。当一个目录包含多个程序,把所有的程序均包含到一个 ./Makefile中是最为方便的。因为缺省的目的重建会针对第一个目的,把此目的命名为伪目的 all ,让它拥有所有其他单独的程序作为前提条件。例如:

all : prog1 prog2 prog3
.PHONY : all

prog1 : prog1.o utils.o
cc -o prog1 prog1.o utils.o

prog2 : prog2.o
cc -o prog2 prog2.o

prog3 : prog3.o sort.o utils.o
cc -o prog3 prog3.o sort.o utils.o

 后文待续





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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值