主makefile套用子目录下的makefile

来源:互联网 发布:javascript取整 编辑:程序博客网 时间:2024/05/20 09:49

主 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'

0 0