GNU make manual 翻译( 一百四十三)

简介:

继续翻译

复制代码
5.7.1 How the `MAKE' Variable Works
-----------------------------------

Recursive `make' commands should always use the variable `MAKE', not
the explicit command name `make', as shown here:

     subsystem:
             cd subdir && $(MAKE)

   The value of this variable is the file name with which `make' was
invoked.  If this file name was `/bin/make', then the recipe executed
is `cd subdir && /bin/make'.  If you use a special version of `make' to
run the top-level makefile, the same special version will be executed
for recursive invocations.  

   As a special feature, using the variable `MAKE' in the recipe of a
rule alters the effects of the `-t' (`--touch'), `-n' (`--just-print'),
or `-q' (`--question') option.  Using the `MAKE' variable has the same
effect as using a `+' character at the beginning of the recipe line.
*Note Instead of Executing the Recipes: Instead of Execution.  This
special feature is only enabled if the `MAKE' variable appears directly
in the recipe: it does not apply if the `MAKE' variable is referenced
through expansion of another variable.  In the latter case you must use
the `+' token to get these special effects.

   Consider the command `make -t' in the above example.  (The `-t'
option marks targets as up to date without actually running any
recipes; see *note Instead of Execution::.)  Following the usual
definition of `-t', a `make -t' command in the example would create a
file named `subsystem' and do nothing else.  What you really want it to
do is run `cd subdir && make -t'; but that would require executing the
recipe, and `-t' says not to execute recipes.  

   The special feature makes this do what you want: whenever a recipe
line of a rule contains the variable `MAKE', the flags `-t', `-n' and
`-q' do not apply to that line.  Recipe lines containing `MAKE' are
executed normally despite the presence of a flag that causes most
recipes not to be run.  The usual `MAKEFLAGS' mechanism passes the
flags to the sub-`make' (*note Communicating Options to a Sub-`make':
Options/Recursion.), so your request to touch the files, or print the
recipes, is propagated to the subsystem.
复制代码

5.7.1 'MAKE' 变量如何工作
-----------------------------------

递归 make 指令应当总是使用变量 MKAE,不是显式命令名称 make ,像如下这样:

subsystem:
cd subdir && $(MAKE)

这个变量的值就是make 被激活所关联的文件名。如果文件名为 /bin/make,那么执行的片段就是 cd subdir && /bin/make。如果你使用一个特殊版本的make 来运行顶层的makefie,那么此版本也会为下层的makefile来递归调用。

作为一个特殊的功能,在一个规则的片段里使用变量 MAKE有 -t(--touch), -n(--just-print), 或者 -q(--question)选项。

使用 MAKE 变量时,在片段行的起始处用 + 符号同样有效。*Note Instead of Executing the Recipes: Instead of Execution

这个特殊的功能只有在 MAKE变量在片段里直接出现的时候才有效。MAKE变量被通过其他变量扩展而来时无效。在之后的场合,你必须使用 + 令牌来获得这些效果。

考虑一下在上述例子中的命令 make -t。(-t 选项标记目的为最新,而没有真正运行任何片段;see *note Instead of Execution::) 

 后面跟着 -t 选项后,此例子中的 make -t 命令会创建一个名字为 subsystem的文件,并且不会做其他的事情。你所真正想要做的是 运行 cd subdir && make -t,但是那样需要执行片段,而 -t 却不需要执行片段。

特殊的功能是的make 作了你想要的。当一个规则的片段行包含了变量 MAKE, 标志 -t -n 和-q 将不会作用到那个行。 包含MAKE的片段行会正常执行而不管标志的存在。通常的 MAKEFLAGS机制传递这些标志到make中(*note Communication Options to a sub-make: Options/Recursion),因此你需要使此文件保持最新,或者打印片段等的要求,会被传播到子系统中。

后文待续






本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/01/2709708.html,如需转载请自行联系原作者

目录
相关文章
|
Linux C语言
make: gcc:命令未找到
make: gcc:命令未找到
make: gcc:命令未找到
|
C语言 C++ Perl
如何处理错误消息Please install the gcc make perl packages
如何处理错误消息Please install the gcc make perl packages
154 0