2011-01-24 50 views
3

我在Linux上使用Eclipse CDT来构建C++可执行文件和几个可执行文件依赖的静态库。 一切都很好 - Eclipse按预期为生成调试和发布生成文件。外部makefile调用Eclipse CDT生成的makefile - 根据Debug Release配置

但是,我想在未安装Eclipse的计算机上编译此代码,所以我想写一个调用Eclipse makefile的简单makefile。

于是我开始喜欢的东西:

all: 
cd Lib1/Release && make all 
cd Lib2/Release && make all 
... 
cd Exec/Release && make all 

这适用于仅发行,如你所见......

如何更改makefile文件,所以我可以使用所选用户的配置?

非常感谢。

+0

为什么不写两个剧本,说'集结dbg`和`集结rel`?或者一个获得输入的脚本? – 2011-01-26 12:53:00

回答

0

有了这个在你的makefile,你可以调用“让调试”或“做发行”打造所需要的模式下,所有的项目:

config: 
    cd Lib1/$(CONFIG) && make all 
    ... 
    cd LibN/$(CONFIG) && make all 
    cd Exec/$(CONFIG) && make all 
debug: 
    make config CONFIG=Debug 
release: 
    make config CONFIG=Release 
.PHONY: debug release config