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

    继续翻译

    6.12 Pattern-specific Variable Values
    =====================================
    
    In addition to target-specific variable values (*note Target-specific
    Variable Values: Target-specific.), GNU `make' supports
    pattern-specific variable values.  In this form, the variable is
    defined for any target that matches the pattern specified.
    
       Set a pattern-specific variable value like this:
    
         PATTERN ... : VARIABLE-ASSIGNMENT
       where PATTERN is a %-pattern.  As with target-specific variable
    values, multiple PATTERN values create a pattern-specific variable
    value for each pattern individually.  The VARIABLE-ASSIGNMENT can be
    any valid form of assignment.  Any command line variable setting will
    take precedence, unless `override' is specified.
    
       For example:
    
         %.o : CFLAGS = -O
    
    will assign `CFLAGS' the value of `-O' for all targets matching the
    pattern `%.o'.
    
       If a target matches more than one pattern, the matching
    pattern-specific variables with longer stems are interpreted first.
    This results in more specific variables taking precedence over the more
    generic ones, for example:
    
         %.o: %.c
                 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    
         lib/%.o: CFLAGS := -fPIC -g
         %.o: CFLAGS := -g
    
         all: foo.o lib/bar.o
    
       In this example the first definition of the `CFLAGS' variable will
    be used to update `lib/bar.o' even though the second one also applies
    to this target. Pattern-specific variables which result in the same
    stem length are considered in the order in which they were defined in
    the makefile.
    
       Pattern-specific variables are searched after any target-specific
    variables defined explicitly for that target, and before target-specific
    variables defined for the parent target.

    6.12 模式特定的变量值
    =====================================

    除了目的特定的变量值(*note Target-specific Variable Values: Target-specific.),GNU make 还支持模式特定的变量值。此时,变量会为所有匹配的目的定义变量。

    设置模式特定的变量看起来像这个样子:

    PATTERN ... : VARIABLE-ASSIGNMENT

    PATTERN 是一个 %-模式。多模式的值为每一个模式特定的变量单独赋予一个值。VARIABLE-ASSIGNMENT 可以是任何有效的赋值表达式。命令行变量优先级高于这些变量,除非使用了 override。

    例如:

    %.o : CFLAGS = -O

    对任何匹配%.o的目的,将会给 `CFLAGS' 赋值为`-O' 。

    如果一个目的匹配了多于一个的模式,拥有更长的枝干的模式特定的变量会首先被翻译。这导致更加特定的变量比更加通用的变量优先级高,例如:

    %.o: %.c
    $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

    lib/%.o: CFLAGS := -fPIC -g
    %.o: CFLAGS := -g

    all: foo.o lib/bar.o

    在这个例子中,对 CFLAGS 的第一个定义,将要被运用来更改 lib/bar.o,尽管第二次的定义也满足此目的。拥有同样长度的枝干的模式特定的变量,则按照出现的顺序来确定优先级。

    模式特定的变量是在显式定义的目的特定的变量之后,在父目的的目的特定的变量之前被搜索的。

    后文待续

  • 相关阅读:
    数论算法 剩余系相关 学习笔记 (基础回顾,(ex)CRT,(ex)lucas,(ex)BSGS,原根与指标入门,高次剩余,Miller_Rabin+Pollard_Rho)
    51Nod1123 X^A Mod B 数论 中国剩余定理 原根 BSGS
    BZOJ2219 数论之神 数论 中国剩余定理 原根 BSGS
    BZOJ3583 杰杰的女性朋友 矩阵
    BZOJ2821 作诗(Poetize) 主席树 bitset
    BZOJ2178 圆的面积并 计算几何 辛普森积分
    BZOJ1058 [ZJOI2007]报表统计 set
    BZOJ2480 Spoj3105 Mod 数论 扩展BSGS
    BZOJ1095 [ZJOI2007]Hide 捉迷藏 动态点分治 堆
    AtCoder Regular Contest 101 (ARC101) D
  • 原文地址:https://www.cnblogs.com/gaojian/p/2712106.html
Copyright © 2011-2022 走看看