继续翻译
复制代码
2.5 Letting `make' Deduce the Recipes
=====================================
It is not necessary to spell out the recipes for compiling the
individual C source files, because `make' can figure them out: it has an
implicit rule for updating a `.o' file from a correspondingly named
`.c' file using a `cc -c' command. For example, it will use the recipe
`cc -c main.c -o main.o' to compile `main.c' into `main.o'. We can
therefore omit the recipes from the rules for the object files. *Note
Using Implicit Rules: Implicit Rules.
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.
复制代码
让 make 减少 片段数量
为了编译单独的 C 源文件,没有必要写出单独的片段。
因为 make 可以把他们识别出来:
这里有一个隐含的规则:需要改变一个.o文件的时候,要用 cc -c 命令来处理 .c 文件。
例如,make 将用 cc -c main.c -o main.o 来编译 main.c 为 main.o。
我们因此可以省略 这些为 目标文件而定的片段。
*Note Using Implicit Rules: Implicit Rules
后文待续
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/13/2683516.html,如需转载请自行联系原作者