zoukankan      html  css  js  c++  java
  • 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有效。

    后文待续

  • 相关阅读:
    wireshark 实用过滤表达式(针对ip、协议、端口、长度和内容)
    32:从1到n整数中1出现的次数
    31:连续子数组的最大和
    30:最小的K个数
    29:数组中出现次数超过一半的数字
    28:字符串的排列
    27:二叉搜索树与双向链表
    26:复杂链表的复制
    25:二叉树中和为某一个定值的路径
    24:二叉搜索树的后序遍历序列
  • 原文地址:https://www.cnblogs.com/gaojian/p/2715152.html
Copyright © 2011-2022 走看看