2009-10-19 73 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