Factor out debug stuff from project makefiles.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Aug 2008 14:12:28 +0000 (14:12 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Aug 2008 14:12:28 +0000 (14:12 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1548 38d2e660-2303-0410-9eaa-f027e97ec537

app/at91sam7s/at91sam7s.mk
app/demo/demo.mk
app/triface/triface.mk
bertos/rules.mk

index d75c396ae088945213855b36973cb495b2587cc9..0d14890a5be2a84311ec9c28b42c8a8c78936a8e 100644 (file)
@@ -42,9 +42,3 @@ at91sam7s_LDFLAGS = -nostartfiles -T bertos/cpu/arm/scripts/at91sam7_256_ram.ld
 
 at91sam7s_CPU = arm7tdmi
 
-# Debug stuff
-ifeq ($(at91sam7s_DEBUG),1)
-       at91sam7s_CFLAGS += -D_DEBUG
-       at91sam7s_CSRC += bertos/drv/kdebug.c
-endif
-
index 884755165f5983aa056f6c5b173460abd501b7db..a836d007f682d4663565286c92e66509a57481ba 100644 (file)
@@ -76,11 +76,7 @@ demo_CXXFLAGS = -D_QT=4 -D'ARCH=ARCH_EMUL' -Iapp/demo $(EMUL_CFLAGS)
 demo_LDFLAGS = $(EMUL_LDFLAGS)
 
 # Debug stuff
-ifeq ($(demo_DEBUG),1)
-       demo_CFLAGS += -D_DEBUG
-       demo_CXXFLAGS += -D_DEBUG
-       demo_CSRC += bertos/drv/kdebug.c
-else
+ifeq ($(demo_DEBUG),0)
        demo_CFLAGS += -Os
        demo_CXXFLAGS += -Os
 endif
index 4d9fc96304fcb1efebfabef067983657637e1dc1..fe5fdcfea9489e7720d13e1ea9929d4e2f4ebd3d 100644 (file)
@@ -47,12 +47,6 @@ triface_LDFLAGS = -Wl
 triface_MCU = atmega64
 triface_CROSS = avr-
 
-# Debug stuff
-ifeq ($(triface_DEBUG),1)
-       triface_CFLAGS += -D_DEBUG
-       triface_PCSRC += bertos/drv/kdebug.c
-endif
-
 # Set to 1 for debug builds
 boot_DEBUG = 0
 
@@ -69,17 +63,10 @@ boot_CSRC = \
        bertos/drv/timer.c \
        bertos/algo/crc.c \
        bertos/mware/hex.c \
-    bertos/kern/kfile.c \
-    #
+       bertos/kern/kfile.c \
+       #
 boot_CROSS = avr-
 boot_CPPFLAGS = -D'ARCH=(ARCH_TRIFACE|ARCH_BOOT)' -Iapp/triface/boot -Ibertos/cpu/avr
 boot_CFLAGS = -Os -mcall-prologues
 boot_LDSCRIPT = app/triface/boot/boot.ld
 boot_LDFLAGS = -Wl,--relax
-
-# Debug stuff
-ifeq ($(boot_DEBUG),1)
-       boot_CFLAGS += -D_DEBUG
-       boot_PCSRC += bertos/drv/kdebug.c bertos/mware/formatwr.c
-endif
-
index ef364d1d601dede45c326c5281047d5eab4c7aa2..beb8f04723f3c6c41f9391f961bbc851c68da7f6 100644 (file)
@@ -111,6 +111,28 @@ ifneq ($$(strip $$($(1)_LDSCRIPT)),)
 $(1)_LDFLAGS += -Wl,-T$$($(1)_LDSCRIPT)
 endif
 
+# Debug stuff
+ifeq ($$($(1)_DEBUG),1)
+       # AVR is an harvard processor
+       # and needs debug module
+       # to be compiled in program memory
+       ifeq ($$(findstring avr, $$($(1)_CROSS)),avr)
+               $(1)_DEBUGSRC = $(1)_PCSRC
+       else
+               $(1)_DEBUGSRC = $(1)_CSRC
+       endif
+       
+       $$($(1)_DEBUGSRC) += bertos/drv/kdebug.c
+
+       # Also add formatwr.c (printf) if not already present
+       ifneq ($$(findstring formatwr.c, $$($$($(1)_DEBUGSRC))),formatwr.c)
+               $$($(1)_DEBUGSRC) += bertos/mware/formatwr.c
+       endif
+
+       $(1)_CFLAGS += -D_DEBUG 
+       $(1)_CXXFLAGS += -D_DEBUG
+endif
+
 $(1)_CC      = $$($(1)_CROSS)$$(CC)
 $(1)_CXX     = $$($(1)_CROSS)$$(CXX)
 $(1)_AS      = $$($(1)_CROSS)$$(AS)