LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   GNU Make and GNU GCC DEBUG vs RELEASE compiler options (http://www.linuxquestions.org/questions/programming-9/gnu-make-and-gnu-gcc-debug-vs-release-compiler-options-781643/)

aryan1 01-12-2010 03: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 ?

Thanks.

ForzaItalia2006 01-12-2010 12:29 PM

Hey,

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:

Code:

CFLAGS = some_options

release: build

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 02:48 AM.