2009-10-19 45 views
4

如果makefile包含“include”,是否可以获得“完整的”makefile?例如:如果Makefile包含“include”,我如何获得“完整的”makefile?

#here is the contents of Makefile 
    include inc1.i 
    include inc2.i 
    clean: 
     rm -rf * 

    #here is the contents of inc1.i 
    abc: 
     touch abc 

    #here is the contents of inc2.i 
    def: 
     touch def 

如何在没有include的情况下获得“完整的”Makefile?因为当Makefile包含其他公司时,inc文件也包含另一个子公司......它很难阅读!

我希望得到一个“全”生成文件,如:从make -p

abc: 
     touch abc 
    def: 
     touch def 
    clean: 
     rm -rf * 

回答

3

当使用GNU做,我经常发现输出是非常有用的(它将包含比你问更多)。

0

对于GNU调试Makefile文件制作,您可以使用

make -p 

打印(全!)做数据库,请处理完成你的Makefile文件后一切。请参阅GNU Make manual: Options Summary(这是info节点“(make)Options Summary”)。

这可能比您提供的信息多得多 - 您可能需要挖掘才能找到您需要的信息。


注意,使用C预处理器(“CC-E”)将用于处理生成文件不工作包括:C预处理处理“的#include”,而生成文件处理需要处理“包括”和“-include ”。

0

天儿真好,

我觉得进入make -np 2>&1 | tee results来检查Makefile的行为,你执行使自身非常有用了。 (假设bash,zsh或类似的stderr的愚蠢投入标准输出。)

N.B.只有当makefile中包含一个创建本地代码环境的命令时,在输入和运行递归make之前,解压缩tarball或制作源树的递归副本。对于这些情况下分两个阶段进行分析,即:

  1. 创建本地副本的要求和注释掉“CP -r”或“焦油-xvf”命令适用于makefile文件,并且
  2. 现在像以前一样执行你的make -np 2>&1 | tee results命令。

顺便说一句,这是我理解构建一个超过2500个kSLOC代码的20+ makefile的超棒项目的唯一方法。构建也有代码生成阶段,只是为了让生活更有趣。 ( - :

HTH

0

你可以不喜欢下面真正得到你想要的东西

% cat include.mk 
define include-func 
dummy:=$(shell cat $(1) > /dev/stderr) 
include $(1) 
dummy:=$(info include-func $(1) evaled, going to be included) 
endef 

dummy:=$(eval $(call include-func,include1.mk)) 
dummy:=$(eval $(call include-func,include2.mk)) 


all: include1-target include2-target 
     #all done 
% cat include1.mk 
dummy:=$(info include1 being included) 

include1-target: 
     @echo include1-target executed 
% cat include2.mk 
dummy:=$(info include2 being included) 

include2-target: 
     @echo include2-target executed 

实际输出:

% make -f include.mk all 
dummy:=$(info include1 being included) 

include1-target: 
     @echo include1-target executed 
include-func include1.mk evaled, going to be included 
include1 being included 
dummy:=$(info include2 being included) 

include2-target: 
     @echo include2-target executed 
include-func include2.mk evaled, going to be included 
include2 being included 
include1-target executed 
include2-target executed 
#all done