GNU make manual 翻译(二十二)

继续翻译

Then, each place we want to put a list of the object file names, we can 
substitute the variable's value by writing `$(objects)' (*note How to
Use Variables: Using Variables.).                        
                        
   Here is how the complete simple makefile looks when you use a 
variable for the object files:                        
                        
     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 : main.c defs.h                        
             cc -c main.c                        
     kbd.o : kbd.c defs.h command.h                        
             cc -c kbd.c                        
     command.o : command.c defs.h command.h                        
             cc -c command.c                        
     display.o : display.c defs.h buffer.h                        
             cc -c display.c                        
     insert.o : insert.c defs.h buffer.h                        
             cc -c insert.c                        
     search.o : search.c defs.h buffer.h                        
             cc -c search.c                        
     files.o : files.c defs.h buffer.h command.h                        
             cc -c files.c                        
     utils.o : utils.c defs.h                        
             cc -c utils.c                        
     clean :                        
             rm edit $(objects)                        

然后,在每一个我们想要列举目标文件名称的地方,我们都可以用 $(objects) 来表达

(*note How to Use Variables: Using Variables)

Here is how the complete simple makefile looks when you use a
variable for the object files:

下面是完整而简单的 makefile使用了 上述变量后的样子:

     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 : main.c defs.h                
             cc -c main.c                
     kbd.o : kbd.c defs.h command.h                
             cc -c kbd.c                
     command.o : command.c defs.h command.h                
             cc -c command.c                
     display.o : display.c defs.h buffer.h                
             cc -c display.c                
     insert.o : insert.c defs.h buffer.h                
             cc -c insert.c                
     search.o : search.c defs.h buffer.h                
             cc -c search.c                
     files.o : files.c defs.h buffer.h command.h                
             cc -c files.c                
     utils.o : utils.c defs.h                
             cc -c utils.c                
     clean :                
             rm edit $(objects)

后文待续

你可能感兴趣的:(Make)