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

简介:

继续翻译

复制代码
   The syntax of the CONDITIONAL-DIRECTIVE is the same whether the
conditional is simple or complex; after an `else' or not.  There are
four different directives that test different conditions.  Here is a
table of them:

`ifeq (ARG1, ARG2)'
`ifeq 'ARG1' 'ARG2''
`ifeq "ARG1" "ARG2"'
`ifeq "ARG1" 'ARG2''
`ifeq 'ARG1' "ARG2"'
     Expand all variable references in ARG1 and ARG2 and compare them.
     If they are identical, the TEXT-IF-TRUE is effective; otherwise,
     the TEXT-IF-FALSE, if any, is effective.

     Often you want to test if a variable has a non-empty value.  When
     the value results from complex expansions of variables and
     functions, expansions you would consider empty may actually
     contain whitespace characters and thus are not seen as empty.
     However, you can use the `strip' function (*note Text Functions::)
     to avoid interpreting whitespace as a non-empty value.  For
     example:

          ifeq ($(strip $(foo)),)
          TEXT-IF-EMPTY
          endif

     will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)'
     contains whitespace characters.

`ifneq (ARG1, ARG2)'
`ifneq 'ARG1' 'ARG2''
`ifneq "ARG1" "ARG2"'
`ifneq "ARG1" 'ARG2''
`ifneq 'ARG1' "ARG2"'
     Expand all variable references in ARG1 and ARG2 and compare them.
     If they are different, the TEXT-IF-TRUE is effective; otherwise,
     the TEXT-IF-FALSE, if any, is effective.
复制代码

对条件式指令的语法而言,无论条件是简单还是复杂,是否在else之后或不适,语法都是相同的。测试不同的条件,可以由四种不同的指令。下面是一个列表:

`ifeq (ARG1, ARG2)'
`ifeq 'ARG1' 'ARG2''
`ifeq "ARG1" "ARG2"'
`ifeq "ARG1" 'ARG2''
`ifeq 'ARG1' "ARG2"'

扩展在ARG1 和 ARG2中所有的变量参照。如果它们是相同的,那么 TEXT-IF-TRUE 生效;否则 如果有TEXT-IF-FALSE, 则 TEXT-IF-FALSE 生效。

经常性地,你可能想要测试是否一个变量是非空值。当一个值来自于复杂的变量扩展或者函数,那么你认为的因当时空的扩展,很可能实际上包含的空格字符,此时不能被认为是空。但是你可以用 strip函数(*note Text Function::)来防止把空格字符翻译为非空值。例如:

ifeq ($(strip $(foo)),)
TEXT-IF-EMPTY
endif

即使$(foo)包含了空格字符,也会获得 TEXT-IF-EMPTY 。

`ifneq (ARG1, ARG2)'
`ifneq 'ARG1' 'ARG2''
`ifneq "ARG1" "ARG2"'
`ifneq "ARG1" 'ARG2''
`ifneq 'ARG1' "ARG2"'
Expand all variable references in ARG1 and ARG2 and compare them.
If they are different, the TEXT-IF-TRUE is effective; otherwise,
the TEXT-IF-FALSE, if any, is effective.

扩展ARG1和ARG2中所有的变量参照并比较它们。如果不同则TEXT-IF-TRUE有效。否则,若TEXT-IF-FALSE存在,则 TEXT-IF-FALSE有效。

后文待续






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