对 makefile 中 $(MAKE) 的学习体会

上例子

主 Makefile内容:

SUBDIRS=foo bar baz
subdirs:
  for dir in $(SUBDIRS); do\
    $(MAKE) -C $$dir; \
  done

当前目录下各个子目录的Makfile内容:

./foo/Makefile:

foo:   
    @echo "foo..."

./bar/Makefile:

bar:
    @echo "bar..."

./baz/Makefile:

baz:
    @echo "baz..."

执行结果:

for dir in foo bar baz;do\

  make -C $dir; \

done

make[1]:Entering directory '/soft/gao/test/foo'

foo...

make[1]:Leaving directory '/soft/gao/test/foo'

make[1]:Entering directory '/soft/gao/test/bar'

bar...

make[1]:Leaving directory '/soft/gao/test/bar'

make[1]:Entering directory '/soft/gao/test/baz'

baz...

make[1]:Leaving directory '/soft/gao/test/baz'

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