GNU make manual 翻译( 一百五十四)
继续翻译
6.1 Basics of Variable References =================================To substitute a variable's value, write a dollar sign followed by the name of the variable in parentheses or braces: either `$(foo)' or `${foo}' is a valid reference to the variable `foo'. This special significance of `$' is why you must write `$$' to have the effect of a single dollar sign in a file name or recipe.Variable references can be used in any context: targets, prerequisites, recipes, most directives, and new variable values. Here is an example of a common case, where a variable holds the names of all the object files in a program:objects = program.o foo.o utils.oprogram : $(objects)cc -o program $(objects)$(objects) : defs.hVariable references work by strict textual substitution. Thus, the rulefoo = cprog.o : prog.$(foo)$(foo)$(foo) -$(foo) prog.$(foo)could be used to compile a C program `prog.c'. Since spaces before the variable value are ignored in variable assignments, the value of `foo' is precisely `c'. (Don't actually write your makefiles this way!)A dollar sign followed by a character other than a dollar sign, open-parenthesis or open-brace treats that single character as the variable name. Thus, you could reference the variable `x' with `$x'. However, this practice is strongly discouraged, except in the case of the automatic variables (*note Automatic Variables::).
6.1 变量参照的基本
=================================
为了替换一个变量的值,要写一个美元符号后面跟着括号或者大括号,里面是变量名成:或者$(foo) 或者 ${foo}是一个对变量 foo的有效参照。这个$的特殊重要性就是为什么你必须写 $$来在文件名或者片段中来代表$符号本身。
变量参照可以用在任何上下文中:目的,前提条件,片段,大多数的指令,还有几个变量值中。这里有一个一般情况的例子,此处变量持有在一个程序中的所有的目标文件名:
objects = program.o foo.o utils.o
program : $(objects)
cc -o program $(objects)
$(objects) : defs.h
变量参照采用严格的文本替换因此,下列规则
foo = c
prog.o : prog.$(foo)
$(foo)$(foo) -$(foo) prog.$(foo)
可以被用来编译一个C 程序 prog.c, 因为变量前的空格会被在变量赋值的时候被忽略,foo的值就是精确的c(当然,实际上不要像这样来写你的makefile)。
一个非美元符号,非开放括号或者非开放打括号前面有一个美元符号的,被当作一个变量对待。因此你你可以用$X来参照x,但是这个实践是强烈不推荐的。除了在自动变量的场合(*note Automatic Variables::)。
后文待续
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/10/03/2710715.html,如需转载请自行联系原作者
GNU make manual 翻译( 一百五十四)相关推荐
- 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 翻译( 一百五十九)
继续翻译 A computed variable name need not consist entirely of a single variable reference. It can conta ...
- GNU make manual 翻译( 一百六十四)
继续翻译 When you add to a variable's value with `+=', `make' acts essentially as if you had included th ...
- GNU make manual 翻译( 一百七十五)
继续翻译 `.DEFAULT_GOAL' Sets the default goal to be used if no targets were specified onthe command lin ...
- GNU make manual 翻译( 一百一十四)
继续翻译 4.10 Multiple Targets in a Rule ===============================A rule with multiple targets is ...
- GNU make manual 翻译( 一百六十)
继续翻译 The only restriction on this sort of use of nested variable references is that they cannot spec ...
- GNU make manual 翻译( 一百六十二)
继续翻译 6.5 Setting Variables =====================To set a variable from the makefile, write a line st ...
- GNU make manual 翻译( 一百八十二)
继续翻译 `ifdef VARIABLE-NAME' The `ifdef' form takes the _name_ of a variable as its argument, not a re ...
最新文章
- 计算机视觉(AI)的算法有哪些,具体都有哪些特点?
- print_r php encode,详细介绍PHP在调试时echo print() print_r() var_dump()的区别分享
- 支付业务流程图--扫码付
- windows10自动填充密码开机自动登陆
- mysql+sqlplus命令找不到_bash: sqlplus: command not found 解决方法
- C++11-long long
- 理解并实施:VRRP(200-120新增考点)
- javascript基本功
- 图片服务 - thumbor过滤器
- MyBatis使用MySQL存储过程
- 自己的本事比领导大,对自己有利还是有弊?
- TP框架控制器的空操作
- win2003系统自动登录两法
- LSTM 手动实现车牌识别 Pytorch代码
- ffmpeg【百度百科】
- Vue组件动态(异步)传值
- 设计模式 - 桥接模式 ( Bridge ) 平时用的少
- 计算机无线模块怎样关闭,台式机无线上网设置_台式电脑如何关闭WIFI?
- gin-binding参数效验
- 外星人做系统logo_外星人开机logo win10
热门文章
- python pandas DataFrame 修改数据
- python 字符串转字典,字典转字符串 Expecting property name enclosed in double quotes
- 决策树算法详解(2)
- 模型量化--TBN:Convolutional Neural Network with Ternary Inputs and Binary Weights
- 有方向的CNN--Oriented Response Networks
- rtk服务器协议,rtk的服务器ip地址
- @NotNull-JSR-303验证
- vim command(vim命令)
- 软件测试员,你该如何快速提高自己的测试技术?
- Python matplotlib 绘制散点图 还不收藏起来