-   Programming (
-   -   GNU Make and GNU GCC DEBUG vs RELEASE compiler options (

aryan1 01-12-2010 04:11 AM

GNU Make and GNU GCC DEBUG vs RELEASE compiler options
Hi All,

I have an application which has several source/header files along with their corresponding Makefiles.

I want to define two common modes for compilation of all source files contained in the project: DEBUG and RELEASE

What is the best practice to define common DEBUG and RELEASE modes with their own compiler options for all the source/header files contained in the project ?


ForzaItalia2006 01-12-2010 01:29 PM


I don't want to say that the following solution is the ultimate common practice, but it might serve as the basis for some discussion about what is good style and what is bad style ;-)

Assuming the use of GNU make:


CFLAGS = some_options

release: build

        @echo $(CFLAGS)

debug: override CFLAGS += some_debugging_opts
debug: build

Just FYI, the variable CFLAGS should be used, because this then simplifies the handling of implicit actions like for example:

main: main.o file.o

- Andi -

All times are GMT -5. The time now is 12:45 PM.