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,如需转载请自行联系原作者

目录
相关文章
|
Linux C语言
make: gcc:命令未找到
make: gcc:命令未找到
make: gcc:命令未找到
|
C语言 C++ Perl
如何处理错误消息Please install the gcc make perl packages
如何处理错误消息Please install the gcc make perl packages
144 0
|
4月前
|
NoSQL 编译器 开发工具
006.gcc编译器
gcc是什么?
47 0
006.gcc编译器