2013-02-27 80 views

回答

0

如果你只是想包括makefile文件的列表,$(info Included files: ${MAKEFILE_LIST})在主makefile文件的底部,符合該法案。

但是,如果您確實需要一棵樹,那麼您必須將所有include <file>替換爲$(call include,<file>)include函數應該是這樣的:

space := 
space += 
${space} := ${space} 

stack := $(firstword ${MAKEFILE_LIST}) 

define includefunc 
    stack := $(subst ${ },|,$(strip ${MAKEFILE_LIST} $1)) ${stack} 
    $(info INCLUDES $(firstword ${stack})) 
    include $1 
    stack := $(wordlist 2,$(words ${stack}),${stack}) 
    MAKEFILE_LIST := $(subst |, ,${stack}) 
endef 

include = $(eval $(value includefunc)) 

$(call include,1.mak) 
$(call include,_1/1.mak) 
$(call include,folder/Makefile) 

.PHONY: all 
all: ; echo [email protected] success 
+0

使用的變量名稱空間('$ {}空間:= $ {空白}')是不是在最新版本的GNU的許可品牌:http://lists.gnu.org/archive/html/help-make/2012 -01/msg00052.html – 2013-02-28 10:30:35

+2

bobbogo完成它的方式仍然有效;從GNU生成NEWS文件:其次,變量名不能再包含空白,_unless你把空白放在一個變量中並使用variable_ – MadScientist 2013-02-28 12:31:44