GNU make manual 翻译(五十四)
继续翻译
For example, if you have a makefile called `Makefile' that says how to make the target `foo' (and other targets), you can write a makefile called `GNUmakefile' that contains: foo: frobnicate > foo %: force @$(MAKE) -f Makefile $@ force: ; If you say `make foo', `make' will find `GNUmakefile', read it, and see that to make `foo', it needs to run the recipe `frobnicate > foo'. If you say `make bar', `make' will find no way to make `bar' in `GNUmakefile', so it will use the recipe from the pattern rule: `make -f Makefile bar'. If `Makefile' provides a rule for updating `bar', `make' will apply the rule. And likewise for any other target that `GNUmakefile' does not say how to make.
例如,如果你有一个makefile名为 Makefile ,描述了如何把目的 'foo'(和其他的目的)生成,你可以写一个名为 GNUmakefile的makefile,包含如下内容:
foo:
frobnicate > foo
%: force
@$(MAKE) -f Makefile $@
force: ;
如果你输入 make foo, 那么 make 会去寻找 GNUmakefile, 读取这个文件,然后会知道为了生成 foo ,它需要 运行 片段 frobnicate > foo。
如果你输入 make bar, make 会发现它在 GNUmakefile 没有找到 bar, 然后它就会用模式规则中的片段:make -f Makefile bar。如果 Makefile提供了一个变更 bar 的规则,那么 make 就会运用此规则。
当我们遇到其他的 GNUmakefile中没有的规则时,也是如此。
后文待续