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

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

继续翻译

Thus, you first write the line that states that `clean' is a phony target, then you write the rule, like this:     .PHONY: clean     clean:             rm *.o temp   Another example of the usefulness of phony targets is in conjunction with recursive invocations of `make' (for more information, see *note Recursive Use of `make': Recursion.).  In this case the makefile will often contain a variable which lists a number of subdirectories to be built.  One way to handle this is with one rule whose recipe is a shell loop over the subdirectories, like this:     SUBDIRS = foo bar baz     subdirs:             for dir in $(SUBDIRS); do \               $(MAKE) -C $$dir; \             done   There are problems with this method, however.  First, any error detected in a submake is ignored by this rule, so it will continue to build the rest of the directories even when one fails.  This can be overcome by adding shell commands to note the error and exit, but then it will do so even if `make' is invoked with the `-k' option, which is unfortunate.  Second, and perhaps more importantly, you cannot takeadvantage of `make''s ability to build targets in parallel (*note Parallel Execution: Parallel.), since there is only one rule.

Thus, you first write the line that states that `clean' is a phony

target, then you write the rule, like this:

因此,你先写了生命 clean 是伪目的的行,然后再写规则,像这样:

.PHONY: clean

clean:
rm *.o temp

另一个说明伪目的用途的例子是和 对make 的递归调用合并在一起的。(为了得到更多相关情报,请参阅 *note Recursive Use of 'make': Recursion) 在这个例子里,makefile 经常会包含一个变量值,列出若干个子目录。一种办法是定义一个规则,在其片段里用一个 shell 循环对这些子目录进行处理,像这样:

SUBDIRS = foo bar baz

subdirs:

for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done

Second, and perhaps more importantly, you cannot take

advantage of `make''s ability to build targets in parallel (*note
Parallel Execution: Parallel.), since there is only one rule.

但是 用这个方法会有问题。首先,在子make中任何错误都会被忽略,所以它将继续执行剩余的指令。这个可以通过shell 命令注意到错误并退出来克服,但是如果make 使用了 -k 选项,很不幸仍然会有退出的问题。第二,也许更为重要的是,你无法利用 make 的并发编译的能力(*note Parallel Execution :Parallel.),因为这里面只有一个规则。

后文待续

转载地址:http://fhvkm.baihongyu.com/

你可能感兴趣的文章
获取一个表单字段中多条数据并转化为json格式
查看>>
c#中的变量,属性,字段
查看>>
JS实现延迟载入图片
查看>>
游戏开发中的人工智能
查看>>
Ubuntu 安装BCM 43142无线网卡驱动
查看>>
iOS 疑难杂症 — — UIButton 点击卡顿/延迟
查看>>
免费 官方的ASP.NET MVC电子书-Professional ASP.NET MVC 1.0
查看>>
PL/SQL DEVELOPER
查看>>
Least Common Ancestors
查看>>
Oracle数据库 之 使用DBLink访问时,提示ORA-01017
查看>>
「学习总结-Haskell-4」Haskell数据类型
查看>>
接口抽取及依赖版本统一介绍
查看>>
Andriod开发学习笔记
查看>>
phpcms_v9 多图字段 内容页,首页,分页自定义字段调用
查看>>
Linux下MySQL导入文件出错ERROR 1290 (HY000)
查看>>
POS开发问题 - 缓存问题 - 02
查看>>
JDBC编程,从入门到精通
查看>>
模板类中的友元函数
查看>>
Eclipse设置项目默认编码和换行符类型
查看>>
【实用性程序】弧微分计算圆周长
查看>>