GNU Make:如何运行make到不同的目录将全部给出选项

问题描述 投票:0回答:1

假设我有以下目录结构: MyApplication Module_A mylib.c Module_B main.c more.c Configuration Config1 Makefile Config2 Makefile

当在make目录中使用任何目标和任何选项启动MyApplication时,我希望它在MyApplication/Configuration/Conig1目录而不是顶层目录中运行。如果不对顶级Makefile中的目标进行硬编码,我怎样才能实现这一目标?

makefile build
1个回答
1
投票

您可以在MyApplication / Makefile中创建一个makefile,如下所示:

CONFIG?=Config1
include Configuration/$(CONFIG)

如果要构建config1,可以键入makemake CONFIG=Config1。如果你想构建config2,你输入make CONFIG=Config2 ...

© www.soinside.com 2019 - 2024. All rights reserved.