0

在现有的 GNU Make 构建系统中,我希望看到 makefile 包含的树。我该怎么做?像你知道项目\文件中包含文件的工具构建树吗?但对于 GNU Make 而不是 C 和 C++。

我感兴趣的一个相关但略有不同的功能:能够将 $(info ...) 语句放入 makefile 并让它打印出包含该 info 语句的回溯。

4

1 回答 1

1

如果您只需要包含的 makefile 列表,$(info Included files: ${MAKEFILE_LIST})主 makefile 底部的 a 就可以满足要求。

但是,如果您确实想要一棵树,则必须将所有内容替换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 $@ success
于 2013-02-27T19:42:02.090 回答