]> git.itanic.dy.fi Git - sdl-planets/commitdiff
Makefie: Add debug target
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Apr 2010 11:12:24 +0000 (14:12 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Apr 2010 11:12:24 +0000 (14:12 +0300)
This makes debugging with gdb easier, when there is no need to modify
the makefile in order to disable optimizations while debugging.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
Makefile

index f0f3977f596b5f5df16e29ddfa5178b77fd15296..86498238846db220ad623486f042f47fe5741c8a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,10 +9,14 @@ SPARSE=sparse
 CHECKPATCH=/usr/src/linux/scripts/checkpatch.pl
 
 PLANET_OBJS=main.o random.o vector.o planet.o camera.o
+PLANET_DEBUG_OBJS= $(patsubst %.o,%-debug.o,$(PLANET_OBJS))
 
 sdl-planet: $(PLANET_OBJS)
        gcc $(LIBS) -o $@ $(PLANET_OBJS)
 
+debug-planets: $(PLANET_DEBUG_OBJS)
+       gcc $(LIBS) -o $@ $(PLANET_DEBUG_OBJS)
+
 .c.o:
        @echo -e "\tCC\t" $@
        @$(CC) -MMD -MF .$@.d $(CFLAGS) -c $< -o $@
@@ -23,12 +27,16 @@ ifeq ($(C),2)
        $(CHECKPATCH) -f $<
 endif
 
+%-debug.o: %.c
+       @echo -e "\tCC\t" $@
+       @$(CC) -MMD -MF .$@.d $(CFLAGS) -O0 -c $< -o $@
+
 TAGS:
        @echo -e "\tTAGS\t"
        @etags *.[ch]
 
 clean:
-       rm -rfv $(PLANET_OBJS) *~ sdl-planet TAGS .*.d
+       rm -rfv $(PLANET_OBJS) $(PLANET_DEBUG_OBJS) *~ sdl-planet TAGS .*.d
 
 .PHONY: all clean TAGS