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

简介:

继续翻译

复制代码
`ifndef VARIABLE-NAME'
     If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE
     is effective; otherwise, the TEXT-IF-FALSE, if any, is effective.
     The rules for expansion and testing of VARIABLE-NAME are identical
     to the `ifdef' directive.

   Extra spaces are allowed and ignored at the beginning of the
conditional directive line, but a tab is not allowed.  (If the line
begins with a tab, it will be considered part of a recipe for a rule.)
Aside from this, extra spaces or tabs may be inserted with no effect
anywhere except within the directive name or within an argument.  A
comment starting with `#' may appear at the end of the line.

   The other two directives that play a part in a conditional are `else'
and `endif'.  Each of these directives is written as one word, with no
arguments.  Extra spaces are allowed and ignored at the beginning of the
line, and spaces or tabs at the end.  A comment starting with `#' may
appear at the end of the line.

   Conditionals affect which lines of the makefile `make' uses.  If the
condition is true, `make' reads the lines of the TEXT-IF-TRUE as part
of the makefile; if the condition is false, `make' ignores those lines
completely.  It follows that syntactic units of the makefile, such as
rules, may safely be split across the beginning or the end of the
conditional.

   `make' evaluates conditionals when it reads a makefile.
Consequently, you cannot use automatic variables in the tests of
conditionals because they are not defined until recipes are run (*note
Automatic Variables::).

   To prevent intolerable confusion, it is not permitted to start a
conditional in one makefile and end it in another.  However, you may
write an `include' directive within a conditional, provided you do not
attempt to terminate the conditional inside the included file.
复制代码

`ifndef VARIABLE-NAME'

如果变量 VARIABLE-NAME 有一个空的值,那么 TEXT-IF-TRUE 是有效的;否则,如果存在TEXT-IF-FALSE, 则 TEXT-IF-FALSE 是有效的。对变量 VARAIBLE-NAME 的扩展和测试与 ifdef 指令中的相同。

在条件式指令行的开始处允许有额外的空格,这些空格将被忽略,但是tab符号是不被允许的(如果一行开始与tab符号,那么它将被认为是规则的片段的一部分。)。此外,额外的空格或者tab符号可以插入到其他任何地方并被忽略,但是不能在指令名字里或者参数里面。以#开头的注释可以被放入一行的末尾。

另外两个在条件式中起到作用的指令else 和 endif 。这些指令的每一个都是写作一个单词,没有参数。在行首的额外空格被允许而且会被忽略,末尾的空格和tab符号也是如此。开始于#的注释会出现在行的末尾。 

条件式影响到哪些行会被make所使用。如果条件为真,make 读取 TEXT-IF-TRUE 为makefile的部分;如果条件为假,make 完全忽略那些行。它遵循makefile的语法规则,如规则的语法规则,规则可以跨越条件式的开始或结束。

make 读取一个makefile的时候,要评估条件式,因此你不能在测试条件式的时候使用自动变量因为在片段没有运行的时候它们还没有定义呢(*note Automatic Variables::)。

为了防止难堪的困惑,不允许在一个makefile中开始一个条件式却在另一个makefile中结束之。但是你可以在一个条件式中写一个 include 指令,此时你不能试图在包含的文件中结束条件式。

后文待续





本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/09/2716078.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
142 0