主makefile在子目录中运行make文件

时间:2012-10-10 02:17:13

标签: makefile

如何创建将在所有子目录中启动所有make文件的makefile。是否可以在主makefile的主目录上运行“make”,这将自动触发子目录的make?

示例:

/makefile   (this is the main makefile)
/subdirectory1/makefile
/subdirectory1/various .c/.h files compiled by the makefile in this directory
/subdirectory2/makefile
/subdirectory2/various .c/.h files compiled by the makefile in this directory
/subdirectory3/makefile
/subdirectory3/various .c/.h files compiled by the makefile in this directory

1 个答案:

答案 0 :(得分:3)

是的,这很简单。在主makefile中:

all:
    $(MAKE) -C subdirectory1
    $(MAKE) -C subdirectory2
    $(MAKE) -C subdirectory3

有了更复杂的变化,一旦你失败了。