GNU make manual 翻译(七)

继续翻译

2 An Introduction to Makefiles    
******************************    
    
You need a file called a "makefile" to tell `make' what to do.  Most    
often, the makefile tells `make' how to compile and link a program.      
    
   In this chapter, we will discuss a simple makefile that describes    
how to compile and link a text editor which consists of eight C source    
files and three header files.  The makefile can also tell `make' how to    
run miscellaneous commands when explicitly asked (for example, to remove    
certain files as a clean-up operation).  To see a more complex example    
of a makefile, see *note Complex Makefile::.    
    
   When `make' recompiles the editor, each changed C source file must    
be recompiled.  If a header file has changed, each C source file that    
includes the header file must be recompiled to be safe.  Each    
compilation produces an object file corresponding to the source file.    
Finally, if any source file has been recompiled, all the object files,    
whether newly made or saved from previous compilations, must be linked    
together to produce the new executable editor.      

Makefile介绍

你需要一个 makefile 来告诉make 作什么。在大多数场合,makefile 告诉make 如何编译和链接一个程序项目。

在这一章,我们将要讨论一个简单的 makefile,它描述如何编译和链接一个文本编辑器。

此程序项目由8个C源文件和3个头文件组成。

此makefile 也能告诉make,当被明确指定时, 如何运行各种杂七杂八的命令

(例如,作为clean-up 操作的一部分,删除一些文件)

如果想要看更复杂的例子,可以参考 *note Complex Makefile

当 make 重新编译此编辑器程序的时候,每一个改变了的C源文件都必须被重新变异。

如果某个头文件改变了,每一个包含了此头文件的C源文件都需要被重新编译以保证万无一失。 

每一个编译动作都会产生一个和源文件对应的目标文件,无论是重新编译好的,

还是已经在以前的编译中生成的文件,都需要被链接到一起以生成这个新的可执行的编辑器程序。

后文待续

posted @ 2012-09-12 14:21  健哥的数据花园  阅读(287)  评论(0编辑  收藏  举报