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

    继续翻译

    5.1.2 Using Variables in Recipes
    --------------------------------
    
    The other way in which `make' processes recipes is by expanding any
    variable references in them (*note Basics of Variable References:
    Reference.).  This occurs after make has finished reading all the
    makefiles and the target is determined to be out of date; so, the
    recipes for targets which are not rebuilt are never expanded.
    
       Variable and function references in recipes have identical syntax and
    semantics to references elsewhere in the makefile.  They also have the
    same quoting rules: if you want a dollar sign to appear in your recipe,
    you must double it (`$$').  For shells like the default shell, that use
    dollar signs to introduce variables, it's important to keep clear in
    your mind whether the variable you want to reference is a `make'
    variable (use a single dollar sign) or a shell variable (use two dollar
    signs).  For example:
    
         LIST = one two three
         all:
                 for i in $(LIST); do \
                     echo $$i; \
                 done
    
    results in the following command being passed to the shell:
    
         for i in one two three; do \
             echo $i; \
         done
    
    which generates the expected result:
    
         one
         two
         three

    5.1.2 在片段中使用变量
    --------------------------------

    make 处理片段的另一个方式是通过扩展任何的片段中的变量参照(*note Basics of Variable References: Reference.) 。这发生在当make 读取完毕所有的makefile并且目的被认为是过期的时候;因此,未被重新构建的目的的片段不会被展开。

    makefile中的片段的变量和函数参照有着相同的语法和语义。它们也有同样的引用规则。如果你想要你的片段中出现一个美元符号,你必须使用$$。

    对于缺省shell那样的shell, 使用美元符号来引入变量,保持头脑清醒地了解你所要使用的变量是否是 make 的变量(使用一个美元符)还是说是shell 的变量(使用两个美元符),是很重要的。例如:

    LIST = one two three
    all:
    for i in $(LIST); do \
    echo $$i; \
    done

    形成如下传递给shell的命令:

    for i in one two three; do \
    echo $i; \
    done

    得到如下的结果:

    one
    two
    three

    后文待续

  • 相关阅读:
    媒体格式分析之flv -- 基于FFMPEG
    x264源代码分析-转
    比特币的相关问题整理(详细的)
    比特币价格首超黄金 年涨幅超7600%
    比特币不是虚拟货币,这是一个真实世界----李笑来
    比特币投机者嘲笑称比特币为泡沫的人原因
    比特币:一个让投资人为之疯狂的神奇货币
    比特币沉浮录
    比特币淘金热席卷中国专业“挖矿机”受疯抢
    国内首起比特币交易平台诈骗案涉案人被捕
  • 原文地址:https://www.cnblogs.com/gaojian/p/2705654.html
Copyright © 2011-2022 走看看