make:分层的make文件 [英] make: hierarchical make file

查看:90
本文介绍了make:分层的make文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(免责声明:我习惯了骗人……我对make没什么经验)

(disclaimer: I am used to scons ... I am somewhat unexperienced with make)

上下文:我正在使用Eclipse CDT生成生成文件.

Context: I am using Eclipse CDT which generates makefiles.

假设我有一个项目目录"lib",并有2个构建配置"Debug"和"Release". Eclipse CDT为每个构建配置优雅地生成一个makefile.所述makefile最终驻留在"Debug"和"Release"文件夹中.

Let's say I have a project directory 'lib' and 2 build configurations 'Debug' and 'Release'. Eclipse CDT gracefully generates a makefile for each build configuration. The said makefiles end-up residing in 'Debug' and 'Release' folders.

现在,我要做的是在文件夹"lib"中有一个生成文件,该文件会调用生成文件"Debug/makefile"和"Release/makefile".

Now, what I want to do is have a makefile in the folder 'lib' which calls the makefiles 'Debug/makefile' and 'Release/makefile'.

我该怎么做?

我希望能够在文件夹"lib"中启动"make",并且将使用指定的目标调用这两种配置.

I want to be able to launch 'make' in the folder 'lib' and both configurations would be called with the specified target(s).

解决方案 根据这里收集的所有宝贵意见,我设计了以下内容:

Solution Based on all the great input gathered here, I devised the following:

MAKE=make
BUILDS=Release Debug
TARGETS=all clean

$(TARGETS):
    @for b in $(BUILDS) ; do $(MAKE) -C $$b $@ ; done

$(BUILDS):
    @for t in $(TARGETS) ; do $(MAKE) -C $@ $$t ; done

%:
    @for b in $(BUILDS) ; do $(MAKE) -C $$b $@ ; done

推荐答案

取决于什么是通话".您想

depends on what is "calls". You want to either

include $(BUILD)/Makefile

$(MAKE) -C $(BUILD) $@

或类似的东西.我猜你想要后者.也许像

or some such. I'd guess you want the latter. Maybe something like

release debug:
    $(MAKE) -C $@

您明白了.

更多示例:

BUILDS=release debug
TARGETS=all clean

$(TARGETS):
    for b in $(BUILDS) ; do $(MAKE) -C $$b $@ ; done

$(BUILDS):
    for t in $(TARGETS) ; do $(MAKE) -C $@ $$t ; done

这篇关于make:分层的make文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆