外部makefile调用Eclipse

外部makefile调用Eclipse

本文介绍了外部makefile调用Eclipse CDT生成的makefile - 根据Debug \ Release配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux上使用Eclipse CDT构建一个c ++可执行文件和可执行文件所依赖的几个静态库。
一切都很好 - Eclipse会按预期的方式生成调试和发布的makefile。



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



所以我开始使用如下的东西:

  all:
cd Lib1 / Release&&使所有
cd Lib2 / Release&&&使所有
...
cd Exec / Release&&使所有

这适用于仅发布,如您所见...



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



非常感谢。

解决方案

在你的makefile中,你可以调用'make debug'或'make release'来以所需的方式构建所有的项目:

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


I'm using Eclipse CDT on Linux to build a c++ executable and several static libraries which the executable depends on.Everything is good - Eclipse generates the makefiles for both Debug and Release as expected.

However, I want to compile this code also on a computer without Eclipse installed, so I thought to write a simple makefile which calls the Eclipse makefile.

So I started with something like:

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

This works for Release only, as you see...

How can I change the makefile so I can use the selected user's configuration ?

Thank you very much.

解决方案

With this in your makefile you can invoke 'make debug' or 'make release' to build all the projects in the required mode :

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

这篇关于外部makefile调用Eclipse CDT生成的makefile - 根据Debug \ Release配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:49