博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GNU make manual 翻译( 一百三十五)
阅读量:6886 次
发布时间:2019-06-27

本文共 3355 字,大约阅读时间需要 11 分钟。

继续翻译

If `.ONESHELL' is provided, then only the first line of the recipewill be checked for the special prefix characters (`@', `-', and `+').Subsequent lines will include the special characters in the recipe linewhen the `SHELL' is invoked.  If you want your recipe to start with oneof these special characters you'll need to arrange for them to not bethe first characters on the first line, perhaps by adding a comment orsimilar.  For example, this would be a syntax error in Perl because thefirst `@' is removed by make:     .ONESHELL:     SHELL = /usr/bin/perl     .SHELLFLAGS = -e     show :             @f = qw(a b c);             print "@f\n";However, either of these alternatives would work properly:     .ONESHELL:     SHELL = /usr/bin/perl     .SHELLFLAGS = -e     show :             # Make sure "@" is not the first character on the first line             @f = qw(a b c);             print "@f\n";or     .ONESHELL:     SHELL = /usr/bin/perl     .SHELLFLAGS = -e     show :             my @f = qw(a b c);             print "@f\n";   As a special feature, if `SHELL' is determined to be a POSIX-styleshell, the special prefix characters in "internal" recipe lines will_removed_ before the recipe is processed.  This feature is intended toallow existing makefiles to add the `.ONESHELL' special target andstill run properly without extensive modifications.  Since the specialprefix characters are not legal at the beginning of a line in a POSIXshell script this is not a loss in functionality.  For example, thisworks as expected:     .ONESHELL:     foo : bar/lose             @cd $(@D)             @gobble $(@F) > ../$@   Even with this special feature, however, makefiles with `.ONESHELL'will behave differently in ways that could be noticeable.  For example,normally if any line in the recipe fails, that causes the rule to failand no more recipe lines are processed.  Under `.ONESHELL' a failure ofany but the final recipe line will not be noticed by `make'.  You canmodify `.SHELLFLAGS' to add the `-e' option to the shell which willcause any failure anywhere in the command line to cause the shell tofail, but this could itself cause your recipe to behave differently.Ultimately you may need to harden your recipe lines to allow them towork with `.ONESHELL'.

如果提供了 .ONESHELL, 那么只有片段的第一行才会被进行特殊前缀字符检查(@,-,+)。后续的行会在shell激活的时候包含这些片段行中的特殊符号。如果你想要你的片段开始于这些特殊符号,你需要是的它们不要成为第一行的第一个字符,比如通过加入一个注释之类。例如,在Perl 中,由于@ 被移出,可能导致语法错误:

.ONESHELL:

SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show :
@f = qw(a b c);
print "@f\n";

然而, 下面两者都会正常工作:

.ONESHELL:

SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show:
# Make sure "@" is not the first character on the first line
@f = qw(a b c);
print "@f\n";

或者

.ONESHELL:

SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show :
my @f = qw(a b c);
print "@f\n";

作为一项特殊的功能, 如果shell 是一个 POSIX-类型的shell, 在片段行内部的特殊前缀字符将在片段被执行前移出。此功能致力于允许现存的makefile通过加入.ONESHELL 特殊目的后不需要代价太大的改变仍然可以正常运行。 因为在POSIX shell中,特殊的前缀字符在一行的开头是不合法的, 这并不是一个功能性的顺损失。例如,如下可以很好地工作:

.ONESHELL:

foo : bar/lose
@cd $(@D)
@gobble $(@F) > ../$@

即便是有这个特殊功能, 带有.ONESHELL 的makefile,将会表现得有所不同。例如,通常如果任何片段中的任何一行失败,会导致规则失败并且没有其它行再被执行。在使用 .ONESHELL的时候, 除了片段最后一个行的失败,其它的失败不会被通知到 make。你可以改变 .SHELLFLAGS 标志,加入 -e 选项给shell,此时任何错误都会导致片段报错,但是这个行为本身能造成你的片段行为异常。

基本上你需要强化你的片段行,使它们能够适应 .ONESHELL

后文待续

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

你可能感兴趣的文章
C++11中的原子操作(atomic operation)(转)
查看>>
std::nothrow
查看>>
通俗讲解:PoW共识机制与以太坊的关系、Ghost协议 及 PoS共识机制的变种---Casper...
查看>>
给想雇佣我的人说的话/Some words to somebody who want to hire me.
查看>>
网站程序(案例)
查看>>
spring依赖注入单元测试:expected single matching bean but found 2
查看>>
ubuntu下安装xlrd模块,Mysqldb模块
查看>>
Git_自定义Git
查看>>
js手机适配
查看>>
软件测试书籍推荐
查看>>
[linux]执行pip安装的程序:command not found
查看>>
dcm4che tools 之dicomdir
查看>>
HDU 4849-Wow! Such City!(最短路)
查看>>
关于IM的一些思考与实践
查看>>
SimInfo获取(MCC, MNC, PLMN)
查看>>
[置顶] 我的Android进阶之旅------>介绍一款集录制与剪辑为一体的屏幕GIF 动画制作工具 GifCam...
查看>>
IMP导入数据 出现ORA-01691问题 解决办法
查看>>
dll常规安装方法
查看>>
【转】一个安全测试的CheckList
查看>>
【转】教你Ruby快速入门
查看>>