且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GNU make manual 翻译(十三)

更新时间:2022-09-24 20:01:23

继续翻译

复制代码
   In the example makefile, the targets include the executable file    
`edit', and the object files `main.o' and `kbd.o'.  The prerequisites    
are files such as `main.c' and `defs.h'.  In fact, each `.o' file is    
both a target and a prerequisite.  Recipes include `cc -c main.c' and    
`cc -c kbd.c'.    
    
   When a target is a file, it needs to be recompiled or relinked if any    
of its prerequisites change.  In addition, any prerequisites that are    
themselves automatically generated should be updated first.  In this    
example, `edit' depends on each of the eight object files; the object    
file `main.o' depends on the source file `main.c' and on the header    
file `defs.h'.    
复制代码
 在此例子makefile中,目的包括 可执行文件 edit, 还有 目标文件 main.o 和 kbd.o。

前提条件指  mian.c , defs.h 之类的文件。

实际上,每一个 .o 文件都 既是一个目的,又是一个前提条件。

片段包括诸如  cc -c main.c 和 cc -c kbd.c

 

当一个目的是一个文件,如果任何它的前提条件变化了,此目标就需要被重新编译或者链接。

而且,那些自己自动生成的 前提条件需要首先被变更。

在此例子中,edit 依赖于 8个目标文件, 目标文件 main.o 依赖于 源文件 main.c 和头文件 defs.h

后文待续



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