Here is a straightforward makefile that describes the way an executable
file called `edit' depends on eight object files which, in turn, depend
on eight C source and three header files.
In this example, all the C files include `defs.h', but only those
defining editing commands include `command.h', and only low level files
that change the editor buffer include `buffer.h'.
edit : main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
cc -o edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
kbd.o : kbd.c defs.h command.h
command.o : command.c defs.h command.h
display.o : display.c defs.h buffer.h
insert.o : insert.c defs.h buffer.h
search.o : search.c defs.h buffer.h
files.o : files.c defs.h buffer.h command.h
rm edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
Here is a straightforward makefile that describes the way an executable
file called `edit' depends on eight object files which, in turn, depend
on eight C source and three header files.
这里有一个很直接的makefile例子, 描述了个名为edit的可执行文件,
依赖于 8个目标文件,而这8个目标文件依赖于8个C源文件和3个头文件。
在这个例子中,所有的C文件都包含 defs.h, 但是只有那些定义了编辑命令的文件才会包含 command.h.
并且,只有一个改变编辑缓冲区的底层文件才包含 buffer.h。
edit : main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
cc -o edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
kbd.o : kbd.c defs.h command.h
command.o : command.c defs.h command.h
display.o : display.c defs.h buffer.h
insert.o : insert.c defs.h buffer.h
search.o : search.c defs.h buffer.h
files.o : files.c defs.h buffer.h command.h
rm edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/12/2681822.html,如需转载请自行联系原作者