From 96c2ad4228faba94b8d12f8ebcd5919f5bbf7b04 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 4 Aug 2015 22:45:08 +0200 Subject: [PATCH] Proper DEBUG flag --- Makefile | 27 +++++++++++++++------------ ion/src/platform/stm32f429/init.c | 1 + liba/include/assert.h | 6 +++--- liba/src/assert.c | 6 ------ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 43900b805..6de043e5e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ PLATFORM ?= stm32f429 +DEBUG ?= 1 #PLATFORM=simulator include Makefile.$(PLATFORM) ifndef USE_LIBA @@ -13,12 +14,12 @@ SFLAGS += -Ilib -I. SFLAGS += -Wall # Flags - Optimizations -ifeq ($(PRODUCTION),1) -#echo "*** PRODUCTION BUILD ***" -SFLAGS += -Os -fdata-sections -ffunction-sections -LDFLAGS += --gc-sections +ifeq ($(DEBUG),1) +SFLAGS += -g -DDEBUG=1 else -SFLAGS += -g +SFLAGS += -Os -fdata-sections -ffunction-sections +#LDFLAGS += --gc-sections +#FIXME: --gc-sections doesn't seem to be working endif # Language-specific flags @@ -35,11 +36,13 @@ lib/private/mem5.o: CFLAGS += -w #objs += src/hello.o .PHONY: default info -default: info clean boot.elf +default: info clean boot.elf size ifeq ($(VERBOSE),1) +size: boot.elf info: @echo "========= BUILD SETTINGS ======" + @echo "DEBUG = $(DEBUG)" @echo "PLATFORM = $(PLATFORM)" @echo "CC = $(CC)" @echo "CXX = $(CXX)" @@ -49,8 +52,14 @@ info: @echo "SFLAGS = $(SFLAGS)" @echo "LDFLAGS = $(LDFLAGS)" @echo "===============================" +size: boot.elf + @echo "========= BUILD OUTPUT ========" + @echo "File: $<" + @arm-none-eabi-size $< | tail -n 1 | awk '{print "Code: " $$1 " bytes";print "Data: " $$2 " bytes"; print "Total: " int(($$1+$$2)/1024) " kB (" $$1 + $$2 " bytes)";}' + @echo "===============================" else info: +size: boot.elf endif include boot/Makefile @@ -67,12 +76,6 @@ include poincare/Makefile objs += src/hello.o -size: boot.elf - @echo "========= BUILD OUTPUT ========" - @echo "File: $<" - @arm-none-eabi-size $< | tail -n 1 | awk '{print "Code: " $$1 " bytes";print "Data: " $$2 " bytes"; print "Total: " int(($$1+$$2)/1024) " kB (" $$1 + $$2 " bytes)";}' - @echo "===============================" - run: boot.elf $(GDB) -x gdb_script.gdb boot.elf diff --git a/ion/src/platform/stm32f429/init.c b/ion/src/platform/stm32f429/init.c index ab5fc1296..91bb9780d 100644 --- a/ion/src/platform/stm32f429/init.c +++ b/ion/src/platform/stm32f429/init.c @@ -1,4 +1,5 @@ #include +#include #include "display.h" #include "init_kbd.h" diff --git a/liba/include/assert.h b/liba/include/assert.h index ccbf4d8a3..76522148e 100644 --- a/liba/include/assert.h +++ b/liba/include/assert.h @@ -3,10 +3,10 @@ #include "private/macros.h" -#ifdef NDEBUG -#define assert(e) ((void)0) -#else +#ifdef DEBUG #define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__))) +#else +#define assert(e) ((void)0) #endif LIBA_BEGIN_DECLS diff --git a/liba/src/assert.c b/liba/src/assert.c index 94a7c4f41..89a1f585b 100644 --- a/liba/src/assert.c +++ b/liba/src/assert.c @@ -1,12 +1,6 @@ #include #include -#ifdef NDEBUG -#define assert(e) ((void)0) -#else -#define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__))) -#endif - void __assert(const char * expression, const char * file, int line) { abort(); }