GNU make manual 翻译( 一百零一)

继续翻译

   By declaring the subdirectories as phony targets (you must do this as
the subdirectory obviously always exists; otherwise it won't be built)
you can remove these problems:

     SUBDIRS = foo bar baz

     .PHONY: subdirs $(SUBDIRS)

     subdirs: $(SUBDIRS)

     $(SUBDIRS):
             $(MAKE) -C $@

     foo: baz

   Here we've also declared that the `foo' subdirectory cannot be built
until after the `baz' subdirectory is complete; this kind of
relationship declaration is particularly important when attempting
parallel builds.

通过把子目录宣布为伪目标(如果子目录明显存在,你必须这么做,否则就无法运行),你可以避免前述问题:

SUBDIRS = foo bar baz

.PHONY: subdirs $(SUBDIRS)

subdirs: $(SUBDIRS)

$(SUBDIRS):
  $(MAKE) -C $@

foo: baz

这里我们也声明了 foo 子目录要在 baz 子目录处理完毕后再处理;这种关系在并行编译的时候很重要。

后文待续

posted @ 2012-09-20 14:38  健哥的数据花园  阅读(246)  评论(0编辑  收藏  举报