GNU make manual 翻译( 一百六十)
继续翻译
The only restriction on this sort of use of nested variable
references is that they cannot specify part of the name of a function
to be called. This is because the test for a recognized function name
is done before the expansion of nested references. For example,
ifdef do_sort
func := sort
else
func := strip
endif
bar := a d b g q c
foo := $($(func) $(bar))
attempts to give `foo' the value of the variable `sort a d b g q c' or
`strip a d b g q c', rather than giving `a d b g q c' as the argument
to either the `sort' or the `strip' function. This restriction could
be removed in the future if that change is shown to be a good idea.
You can also use computed variable names in the left-hand side of a
variable assignment, or in a `define' directive, as in:
dir = foo
$(dir)_sources := $(wildcard $(dir)/*.c)
define $(dir)_print =
lpr $($(dir)_sources)
endef
This example defines the variables `dir', `foo_sources', and
`foo_print'.
Note that "nested variable references" are quite different from
recursively expanded variables (*note The Two Flavors of Variables:
Flavors.), though both are used together in complex ways when doing
makefile programming.
对于这种对嵌套式变量参照使用的唯一的限制是他们不能指定一个要调用的函数名称的部分。这是因为对一个被认识的函数名称的测试已经在嵌套参照之前完成了。例如,
ifdef do_sort
func := sort
else
func := strip
endif
bar := a d b g q c
foo := $($(func) $(bar))
试图给出 `foo' 变量值为 `sort a d b g q c' 或 `strip a d b g q c', 而不是给出`a d b g q c' 作为 `sort' 或者 `strip' 函数的参数。如果未来考虑到改变此限制会更好,也许未来会进行改变。
你可以在一个变量赋值或define指令的左边得左边使用被计算的变量名,就像是这样:
dir = foo
$(dir)_sources := $(wildcard $(dir)/*.c)
define $(dir)_print =
lpr $($(dir)_sources)
endef
这个例子定义了变量 `dir', `foo_sources', 和`foo_print'。
要注意这个 "嵌套变量参照" 是和 递归式扩展变量很不一样的。(*note The Two Flavors of Variables: Flavors.) 尽管它们都在 makefile 编程时以复杂的方式进行使用。
这里我插入一句,
dir = foo
$(dir)_sources := $(wildcard $(dir)/*.c)
相当于 把 foo目录下的 所有的.c 文件名 获得后,赋值为 foo_sources
后文待续
转载于:https://www.cnblogs.com/gaojian/archive/2012/10/04/2711261.html
GNU make manual 翻译( 一百六十)相关推荐
- GNU make manual 翻译( 一百六十四)
继续翻译 When you add to a variable's value with `+=', `make' acts essentially as if you had included th ...
- GNU make manual 翻译( 一百六十二)
继续翻译 6.5 Setting Variables =====================To set a variable from the makefile, write a line st ...
- GNU make manual 翻译( 一百五十五)
继续翻译 6.2 The Two Flavors of Variables ================================There are two ways that a vari ...
- GNU make manual 翻译( 一百二十四)
继续翻译 Note that such a prerequisite constitutes mentioning `main.o' in a makefile, so it can never be ...
- GNU make manual 翻译( 一百五十四)
继续翻译 6.1 Basics of Variable References =================================To substitute a variable's v ...
- GNU make manual 翻译( 一百五十九)
继续翻译 A computed variable name need not consist entirely of a single variable reference. It can conta ...
- GNU make manual 翻译( 一百七十五)
继续翻译 `.DEFAULT_GOAL' Sets the default goal to be used if no targets were specified onthe command lin ...
- GNU make manual 翻译( 一百八十二)
继续翻译 `ifdef VARIABLE-NAME' The `ifdef' form takes the _name_ of a variable as its argument, not a re ...
- GNU make manual 翻译( 一百六十三)
继续翻译 6.6 Appending More Text to Variables ====================================Often it is useful to ...
最新文章
- 使用slice和concat对数组的深拷贝和浅拷贝
- jsonp跨域ajax跨域get方法
- 【synchronized底层原理之4】锁的升级过程及比较
- 036_Unicode对照表二
- mysql 热切换_热备服务器中,切换master中切换SQL
- 惊呆了!这篇论文全文都是脏话,可编辑部居然对它评价极佳并发表了!
- python错误提示库没有注册_SpringBoot实现登录注册常见问题解决方案
- 4.7 什么是深度卷积网络?
- java 单例加锁方法的讨论
- Qt QTimer在线程的应用与思考
- mysql order by 自定义
- pycharm控制台打印时显示内容,不用省略号代替
- C语言错题锦集(持续更新)
- 新建网站的长尾词应该如何去做优化
- 做对了什么与留下了什么 小米上市的背后
- 磁力计校正和数据处理
- 大学生如何学习c语言!
- DNS NoteBook
- autocomplete触发事件_如何防止onSelect事件在DevBridge jQuery Autocomplete中触发两次
- 机器学习推导中常用的求导公式
热门文章
- 【NLP】语言模型和迁移学习
- Rails文件上传file_field报错Encoding::UndefinedConversionError
- 使用栈实现队列 Implement Queue using Stacks
- 《企业级ios应用开发实战》一2.2 iOS框架介绍
- Linux系统(五)负载均衡LVS集群之DR模式
- eclipse启动失败:An internal error occurred during: reload maven project
- CentOS 下安装xdebug
- Yii2.0 ActiveForm Input Fields
- leetcode1319. 连通网络的操作次数(并查集)
- leetcode1482. 制作 m 束花所需的最少天数(二分法)