From a57b44b91e73a72a8b2133971476066db210a05a Mon Sep 17 00:00:00 2001 From: batt Date: Tue, 5 Aug 2008 14:12:28 +0000 Subject: [PATCH] Factor out debug stuff from project makefiles. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1548 38d2e660-2303-0410-9eaa-f027e97ec537 --- app/at91sam7s/at91sam7s.mk | 6 ------ app/demo/demo.mk | 6 +----- app/triface/triface.mk | 17 ++--------------- bertos/rules.mk | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/app/at91sam7s/at91sam7s.mk b/app/at91sam7s/at91sam7s.mk index d75c396a..0d14890a 100644 --- a/app/at91sam7s/at91sam7s.mk +++ b/app/at91sam7s/at91sam7s.mk @@ -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 - diff --git a/app/demo/demo.mk b/app/demo/demo.mk index 88475516..a836d007 100644 --- a/app/demo/demo.mk +++ b/app/demo/demo.mk @@ -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 diff --git a/app/triface/triface.mk b/app/triface/triface.mk index 4d9fc963..fe5fdcfe 100644 --- a/app/triface/triface.mk +++ b/app/triface/triface.mk @@ -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 - diff --git a/bertos/rules.mk b/bertos/rules.mk index ef364d1d..beb8f047 100644 --- a/bertos/rules.mk +++ b/bertos/rules.mk @@ -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) -- 2.25.1