GNU make manual 翻译(二十四)

简介:
继续翻译

复制代码
   When a `.c' file is used automatically in this way, it is also 
automatically added to the list of prerequisites.  We can therefore omit 
the `.c' files from the prerequisites, provided we omit the recipe.                    
                    
   Here is the entire example, with both of these changes, and a 
variable `objects' as suggested above:                    
                    
     objects = main.o kbd.o command.o display.o \                    
               insert.o search.o files.o utils.o                    
                    
     edit : $(objects)                    
             cc -o edit $(objects)                    
                    
     main.o : defs.h                    
     kbd.o : defs.h command.h                    
     command.o : defs.h command.h                    
     display.o : defs.h buffer.h                    
     insert.o : defs.h buffer.h                    
     search.o : defs.h buffer.h                    
     files.o : defs.h buffer.h command.h                    
     utils.o : defs.h                    
                    
     .PHONY : clean                    
     clean :                    
             rm edit $(objects)                    
复制代码
当一个.c 文件被这样自动使用的时候,它也将被自动加入到 前提条件里。

因此在我们省略掉片段的时候,我们也可以在前提条件中省略掉 .c 文件。

下面就是一个完整的例子,包含上面所说的改变,和对 变量 objects的使用:

objects = main.o kbd.o command.o display.o \ 
insert.o search.o files.o utils.o

edit : $(objects)
cc -o edit $(objects)

main.o : defs.h
kbd.o : defs.h command.h
command.o : defs.h command.h
display.o : defs.h buffer.h
insert.o : defs.h buffer.h
search.o : defs.h buffer.h
files.o : defs.h buffer.h command.h
utils.o : defs.h

.PHONY : clean
clean :
rm edit $(objects)
 

后文待续



本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/13/2683537.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
143 0
|
4月前
|
NoSQL 编译器 开发工具
006.gcc编译器
gcc是什么?
45 0
006.gcc编译器