假设我有以下目录结构:
MyApplication
Module_A
mylib.c
Module_B
main.c
more.c
Configuration
Config1
Makefile
Config2
Makefile
当在make
目录中使用任何目标和任何选项启动MyApplication
时,我希望它在MyApplication/Configuration/Conig1
目录而不是顶层目录中运行。如果不对顶级Makefile中的目标进行硬编码,我怎样才能实现这一目标?
您可以在MyApplication / Makefile中创建一个makefile,如下所示:
CONFIG?=Config1
include Configuration/$(CONFIG)
如果要构建config1,可以键入make
或make CONFIG=Config1
。如果你想构建config2,你输入make CONFIG=Config2
...