摘要: 继续翻译6.9 Undefining Variables========================If you want to clear a variable, setting its value to empty is usuallysufficient. Expanding such a variable will yield the same result (emptystring) regardless of whether it was set or not. However, if you areusing the `flavor' (*note Flavor Fu 阅读全文
posted @ 2012-10-04 16:55 健哥的数据花园 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 上例子foo:=foobar=barall: @echo $(flavor $(foo)) @echo $(flavor $(bar))结果:simplerecursive结束 阅读全文
posted @ 2012-10-04 16:53 健哥的数据花园 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 You may nest `define' directives: `make' will keep track of nesteddirectives and report an error if they are not all properly closed with`endef'. Note that lines beginning with the recipe prefix characterare considered part of a recipe, so any `define' or `endef' stringsappe 阅读全文
posted @ 2012-10-04 16:19 健哥的数据花园 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 上例子define funcfoo: @echo "at foo"endefall: foo @echo "final"$(eval $(call func, foo,abc.c))先不整那些函数参数传递之类的幺蛾子,做一个个简单的例子,运行 make结果是:at foofinal然后再变化下:define func$1: @echo "at foo"endefall: foo @echo "final"$(eval $(call func, foo,abc.c))这次,传递 foo 作为 $1,得到结果相同。基本 阅读全文
posted @ 2012-10-04 15:52 健哥的数据花园 阅读(7336) 评论(0) 推荐(1) 编辑
摘要: 上例子reverse=$(2) $(1)foo=$(call reverse, a, b)all: @echo $(foo)运行结果: makeb a结束 阅读全文
posted @ 2012-10-04 15:03 健哥的数据花园 阅读(6668) 评论(0) 推荐(0) 编辑
摘要: 继续翻译6.8 Defining Multi-Line Variables=================================Another way to set the value of a variable is to use the `define'directive. This directive has an unusual syntax which allows newlinecharacters to be included in the value, which is convenient fordefining both canned sequences 阅读全文
posted @ 2012-10-04 14:31 健哥的数据花园 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 上例子override gao=abcgao=12345all: @echo $(gao)运行的结果,makeabcoverride 指令比其他的变量赋值优先级要高。结束 阅读全文
posted @ 2012-10-04 13:46 健哥的数据花园 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 上例子override gao += abcall: @echo $(gao)如果执行 make gao=12345结果为:12345 abc直接写gao += abcall: @echo $(gao)执行 make gao=12345结果是:12345当然,如果直接 make,结果就是 abc 了。结束 阅读全文
posted @ 2012-10-04 13:36 健哥的数据花园 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 继续翻译6.7 The `override' Directive============================If a variable has been set with a command argument (*note OverridingVariables: Overriding.), then ordinary assignments in the makefile areignored. If you want to set the variable in the makefile even thoughit was set with a command argu 阅读全文
posted @ 2012-10-04 13:06 健哥的数据花园 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 When you add to a variable's value with `+=', `make' actsessentially as if you had included the extra text in the initialdefinition of the variable. If you defined it first with `:=', makingit a simply-expanded variable, `+=' adds to that simply-expandeddefinition, and expan 阅读全文
posted @ 2012-10-04 10:55 健哥的数据花园 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 继续翻译6.6 Appending More Text to Variables====================================Often it is useful to add more text to the value of a variable alreadydefined. You do this with a line containing `+=', like this: objects += another.oThis takes the value of the variable `objects', and adds the text 阅读全文
posted @ 2012-10-04 10:28 健哥的数据花园 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 继续翻译6.5 Setting Variables=====================To set a variable from the makefile, write a line starting with thevariable name followed by `=' or `:='. Whatever follows the `=' or`:=' on the line becomes the value. For example, objects = main.o foo.o bar.o utils.odefines a variable n 阅读全文
posted @ 2012-10-04 10:05 健哥的数据花园 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 继续翻译6.4 How Variables Get Their Values==================================Variables can get values in several different ways: * You can specify an overriding value when you run `make'. *Note Overriding Variables: Overriding. * You can specify a value in the makefile, either with an assignment... 阅读全文
posted @ 2012-10-04 09:32 健哥的数据花园 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 上例子首先,在linux 环境中,如此设置:#test=1234567#export test#echo $test1234567#然后编辑 Makefileall: @echo $(test)运行结果:#make 1234567#结束 阅读全文
posted @ 2012-10-04 09:29 健哥的数据花园 阅读(2560) 评论(0) 推荐(0) 编辑
摘要: 上例子gao:=123all: @echo $(gao)如果运行 make ,结果是 123如果运行 make gao=456, 结果是456那么如果改变一下呢。比如我们想要:即便你在命令行给出了变量的值,我也不想放弃呢?修改例子:override gao:=123all: @echo $(gao)如果运行 make ,结果是 123因为有 override 的存在,make gao=456 的结果仍然是 123结束 阅读全文
posted @ 2012-10-04 09:02 健哥的数据花园 阅读(625) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 The only restriction on this sort of use of nested variablereferences is that they cannot specify part of the name of a functionto be called. This is because the test for a recognized function nameis done before the expansion of nested references. For example, ifdef do_sort func := sort ... 阅读全文
posted @ 2012-10-04 08:51 健哥的数据花园 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 A computed variable name need not consist entirely of a singlevariable reference. It can contain several variable references, aswell 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)"... 阅读全文
posted @ 2012-10-04 08:10 健哥的数据花园 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 The previous example shows two levels of nesting, but any number oflevels is possible. For example, here are three levels: x = y y = z z = u a := $($($(x)))Here the innermost `$(x)' expands to `y', so `$($(x))' expands to`$(y)' which in turn expands to `z'; now we have `$(z) 阅读全文
posted @ 2012-10-04 08:04 健哥的数据花园 阅读(200) 评论(0) 推荐(0) 编辑