GNU make manual 翻译(七十四)
继续翻译
4.1 Rule Example ================ Here is an example of a rule: foo.o : foo.c defs.h # module for twiddling the frobs cc -c -g foo.c Its target is `foo.o' and its prerequisites are `foo.c' and `defs.h'. It has one command in the recipe: `cc -c -g foo.c'. The recipe starts with a tab to identify it as a recipe. This rule says two things: * How to decide whether `foo.o' is out of date: it is out of date if it does not exist, or if either `foo.c' or `defs.h' is more recent than it. * How to update the file `foo.o': by running `cc' as stated. The recipe does not explicitly mention `defs.h', but we presume that `foo.c' includes it, and that that is why `defs.h' was added to the prerequisites.
4.1 规则例子
================
这里有一个规则的例子:
foo.o : foo.c defs.h # module for twiddling the frobs
cc -c -g foo.c
目标是 foo.o, 它的前提条件是 foo.c 和 defs.h。它的片段拥有一个命令行:
cc -c -g foo.c 片段行开头有一个tab 符号,表明其为片段。
此规则说了两件事情:
*如何判定,是否 foo.o已经过期:如果它不存在,或者 foo.c 或 defs.h 比它新。
*如何通过运行 片段中声明的 cc命令来更改 foo.o 文件。此片段没有显式地提及 defs.h, 但是我们假设foo.c 包含了它,这也是 defs.h 出现在 前提条件中的原因。
后文待续