zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百)

    继续翻译

       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 take
    advantage 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.),因为这里面只有一个规则。

    后文待续

  • 相关阅读:
    SpringBoot-web场景-静态资源访问 & 欢迎页支持 & 自定义Favicon & 静态资源配置原理
    SpringBoot配置文件yaml文件的用法 & 自定义类绑定的配置提示
    设置 TabBarItem 选中时的图片及文字颜色
    iOS 9 使用HTTP的方法
    php单双引号嵌套解决方案
    github desktop项目版本控制
    数据库-内 | 左| 右| 全连接
    05_总结一下,以软件开发周期说明不同的测试使用
    04_用户需求 自己产品 竞争对手产品关系
    03_P52 课后作业
  • 原文地址:https://www.cnblogs.com/gaojian/p/2694793.html
Copyright © 2011-2022 走看看