I have a basic makefile-based project on Linux. It also builds in Visual Studio on Windows.
I’d like to modify my Linux makefile to create multiple builds with different binaries, Debug and Release to start, but will probably add others.
How do I set up a Makefile project to build source in different ways to different paths?
For instance, debug build would be something like:
g++ -ggdb -Wall -DDEBUG
.o files in ./Debug/obj
.so and binary files in ./Debug/bin
And release output would be:
g++ -Os -Wall
.o files in ./Release/obj
.so and binary files in ./Release/bin
Make debug or make release would make them, or make all would do everything.
I how to create multiple build types in a Makefile, but the part I’m really unclear on is setting output directory and setting which .o file directory to check to see whether source files have been built.
A pointer to relevant examples and docs would be welcome.
Make some time for reading, head over to Paul Smith’s homepage, who is the maintainer of GNU Make, and read these two articles:
You will then probably understand that it’s not a good idea to build in directories other than the current one because it means going against the grain of Make.
The articles will also guide you on how to organise a build, and it might just fit your particular situation.