zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百七十九)

    继续翻译

       As this example illustrates, conditionals work at the textual level:
    the lines of the conditional are treated as part of the makefile, or
    ignored, according to the condition.  This is why the larger syntactic
    units of the makefile, such as rules, may cross the beginning or the
    end of the conditional.
    
       When the variable `CC' has the value `gcc', the above example has
    this effect:
    
         foo: $(objects)
                 $(CC) -o foo $(objects) $(libs_for_gcc)
    
    When the variable `CC' has any other value, the effect is this:
    
         foo: $(objects)
                 $(CC) -o foo $(objects) $(normal_libs)
    
       Equivalent results can be obtained in another way by
    conditionalizing a variable assignment and then using the variable
    unconditionally:
    
         libs_for_gcc = -lgnu
         normal_libs =
    
         ifeq ($(CC),gcc)
           libs=$(libs_for_gcc)
         else
           libs=$(normal_libs)
         endif
    
         foo: $(objects)
                 $(CC) -o foo $(objects) $(libs) 

    正如这个例子所揭示的那样,条件式在文本层面上工作:条件式的行被当作makefile的一部分,或者被忽略,这取决于条件本身。这就是为什么makefile中的大一些的语法单位,例如规则,可以跨越条件式的开始或终了之处。

    当变量CC拥有值gcc, 上述的例子有如下的效果:

    foo: $(objects)
    $(CC) -o foo $(objects) $(libs_for_gcc)

    如果变量 CC 有其他的值,则效果如下:

    foo: $(objects)
    $(CC) -o foo $(objects) $(normal_libs)

    用另外的方法可以得到同样的结果--把一个对变量的赋值进行条件化,然后使用此变量。

    libs_for_gcc = -lgnu
    normal_libs =

    ifeq ($(CC),gcc)
    libs=$(libs_for_gcc)
    else
    libs=$(normal_libs)
    endif

    foo: $(objects)
    $(CC) -o foo $(objects) $(libs)

    后文待续

  • 相关阅读:
    $(document).ready(function() {。。。。。})里面的所有的代码都不执行(不执行初始化脚本)
    checkbox使用示例
    js中数组元素的添加和删除
    maven构建项目里classpath的位置
    Docker相关释义
    linux的systemctl服务及其使用
    RabbitMQ中客户端的Channel类里各方法释义
    java四种内部类详解
    生成随机字符串(三种方式)
    RabbitMQ在java中基础使用
  • 原文地址:https://www.cnblogs.com/gaojian/p/2712244.html
Copyright © 2011-2022 走看看