GNU Make implicit rules



I wish to build both debug and release builds of my programs with
a makefile (simplified version below).
I have a problem when using implicit rule though in that I wish to
have separate CFLAGS for both my debug and release builds.
How should I specify implicit rule correctly so that my CFLAGS_DBG
gets picked up when building the debug target?
Any help with this appreciated.

CC = g++
CFLAGS = -O3 -I/usr/include/SDL -I/usr/X11R6/include
CFLAGS_DBG = -O0 -g -I/usr/include/SDL -I/usr/X11R6/include
LDFLAGS = -L/usr/X11R6/lib -lSDL -ldl -lm -lX11

OBJECT = main.o dialog.o cfgparser.o sprite.o ai.o actor.o

release: $(OBJECT)
$(CC) -o release.bin $(LDFLAGS) $(OBJECT)

debug: $(OBJECT)
$(CC) -o debug.bin $(LDFLAGS) $(OBJECT)

..cpp.o:
$(CC) -c $(CFLAGS) $<

all: release

.



Relevant Pages

  • Re: GNU Make implicit rules
    ... a makefile. ... have separate CFLAGS for both my debug and release builds. ... How should I specify implicit rule correctly so that my CFLAGS_DBG ...
    (comp.os.linux.development.apps)
  • Re: Assertions
    ... it doesn't seem to work quite how I expected (i.e. zero runtime overhead in Release build). ... macro actually always expands to NIL when the debug variable is NIL. ... I have not used a Makefile for Common Lisp ...
    (comp.lang.lisp)
  • Makefiel Q: Multiple rules for one target
    ... "All the dependencies mentioned in all the rules are merged into one list of dependencies for the target." ... What I would like to do is have a makefile which builds either a release or debug version of my binary. ... ..PHONY: clean ...
    (comp.os.linux.misc)
  • Re: How to make a library with g95
    ... That makefile looks ok on the surface in isolation (though makefiles are ... I can't debug from such insufficient ... See the prior post for a list of needed data, ... exact command you use to link. ...
    (comp.lang.fortran)
  • How to make different targets with make
    ... I have a Makefile where I simply comment out the commands ... "make debug" builds debug version. ... vpath %.cpp src ...
    (comp.unix.programmer)