makefile and conditional compilation
Posted on 2002-05-23
I have an application with *many* source files that can be compiled "normally" or with a "debug" option.
The compilation is dependant on the -DDEBUG compiler switch.
How can I set up a makefile so that I can type in either:
make app_debug (to make the debug version)
make app (to make the non-debug version)
Basically the problem is this:
Once I make the debug version (using the -DDEBUG switch) the object files are timestamped as being younger than the source files. So when I try to make the non-debug version nothing gets "re-compiled".
Currently I link the source files to different names which causes differnet object file names to be created.
I link source.c to source_d.c
source.c compiles to source.o
source_d.c compiles to source_d.o
I think this is a clumsy way to do waht I need, can anyone suggest a more elegant approach?