GNU make manual 翻译( 一百五十九)

简介:

继续翻译

复制代码
   A computed variable name need not consist entirely of a single
variable reference.  It can contain several variable references, as
well as some invariant text.  For example,

     a_dirs := dira dirb
     1_dirs := dir1 dir2

     a_files := filea fileb
     1_files := file1 file2

     ifeq "$(use_a)" "yes"
     a1 := a
     else
     a1 := 1
     endif

     ifeq "$(use_dirs)" "yes"
     df := dirs
     else
     df := files
     endif

     dirs := $($(a1)_$(df))

will give `dirs' the same value as `a_dirs', `1_dirs', `a_files' or
`1_files' depending on the settings of `use_a' and `use_dirs'.

   Computed variable names can also be used in substitution references:

     a_objects := a.o b.o c.o
     1_objects := 1.o 2.o 3.o

     sources := $($(a1)_objects:.o=.c)

defines `sources' as either `a.c b.c c.c' or `1.c 2.c 3.c', depending
on the value of `a1'.
复制代码

一个被计算的变量名不需要有一个单独的变量参照组成。它可以包含几个变量参照,也可以包含静态文本。例如,

  a_dirs := dira dirb

  1_dirs := dir1 dir2

  a_files := filea fileb
1_files := file1 file2

  ifeq "$(use_a)" "yes"
a1 := a
else
a1 := 1
endif

  ifeq "$(use_dirs)" "yes"
df := dirs
else
df := files
endif

  dirs := $($(a1)_$(df))

将要给出 `dirs' 的值为 `a_dirs', `1_dirs', `a_files' 或者
`1_files' ,这取决于 `use_a' 或者 `use_dirs'.

被计算的变量名字也可以用在替换参照中:

  a_objects := a.o b.o c.o

  1_objects := 1.o 2.o 3.o

  sources := $($(a1)_objects:.o=.c)

定义 `sources' 为 `a.c b.c c.c' 或者 `1.c 2.c 3.c', 取决于`a1'的值。

后文待续





本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/04/2711255.html,如需转载请自行联系原作者

目录
相关文章
|
Linux C语言
make: gcc:命令未找到
make: gcc:命令未找到
make: gcc:命令未找到