更新时间:2022-10-20 19:03:58
在你的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