I have a C++ project that compiles to different versions, including release, debug, shared library, and executable, with different compiler flags for each. I am trying out Jam as an alternative to Make, because it looks like a simpler system.
Is Jam capable of this? The main problem is that it always places the .o files into the same folder as the source file, so it overwrites them when building multiple versions.
Update
I found a solution that seems to work. Using this file, I can build debug and release configurations of a library or executable.
Command to build release library:
jam -s config=lib -s release=1
If you only type jam
, it builds the debug executable. Here is the Jamfile:
FILES =
main.cpp
;
BASENAME = steve ;
OBJ = obj ;
if $(release)
{
OBJ = $(OBJ)r ;
}
else
{
DEFINES += DEBUG ;
OBJ = $(OBJ)d ;
}
if $(config) = lib
{
OBJ = $(OBJ)_lib ;
OUTFILE = lib$(BASENAME).so ;
DEFINES += SHARED_LIBRARY ;
LINKFLAGS +=
-shared -Wl,-soname,$(OUTFILE) -fvisibility=hidden -fPICS
;
}
else
{
OUTFILE = $(BASENAME) ;
}
LOCATE_TARGET = $(OBJ) ;
MkDir $(LOCATE_TARGET) ;
Main $(OUTFILE) : $(FILES) ;