From 05965678f60cda32168eae2c70d411e309504821 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 25 Mar 2014 00:49:42 +0000 Subject: [PATCH] Update GNU Makefiles to generate DEBUG binaries * '-g' has been added for all the build to produce debugging information. '-g' allows to get the symbols when debugging with GDB. * introduce the macro 'DEBUG' to enable/disable build optimization. Limitations: * Support in non-Makefile projects has been added. --- workspace_tools/export/codesourcery_lpc1768.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_disco_f051r8.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_disco_f100rb.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_disco_f407vg.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_k20d5m.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_kl05z.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_kl25z.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_kl46z.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc1114.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc11u24.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc11u35_401.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc11u35_501.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc1768.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_lpc4088.tmpl | 8 +++++++- workspace_tools/export/gcc_arm_stm32f407.tmpl | 8 +++++++- 15 files changed, 105 insertions(+), 15 deletions(-) diff --git a/workspace_tools/export/codesourcery_lpc1768.tmpl b/workspace_tools/export/codesourcery_lpc1768.tmpl index 4bfd151c15..0fa0fa6bd8 100644 --- a/workspace_tools/export/codesourcery_lpc1768.tmpl +++ b/workspace_tools/export/codesourcery_lpc1768.tmpl @@ -13,7 +13,7 @@ LINKER_SCRIPT = {{linker_script}} ############################################################################### CC = $(GCC_BIN)arm-none-eabi-gcc CPP = $(GCC_BIN)arm-none-eabi-g++ -CC_FLAGS = -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections +CC_FLAGS = -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections ONLY_C_FLAGS = -std=gnu99 ONLY_CPP_FLAGS = -std=gnu++98 CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} @@ -27,6 +27,12 @@ LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_disco_f051r8.tmpl b/workspace_tools/export/gcc_arm_disco_f051r8.tmpl index d8bcf07d2c..1eb6d9a9b6 100644 --- a/workspace_tools/export/gcc_arm_disco_f051r8.tmpl +++ b/workspace_tools/export/gcc_arm_disco_f051r8.tmpl @@ -20,7 +20,7 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -g +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs @@ -28,6 +28,12 @@ LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_disco_f100rb.tmpl b/workspace_tools/export/gcc_arm_disco_f100rb.tmpl index 6830ab287c..3112e14c64 100644 --- a/workspace_tools/export/gcc_arm_disco_f100rb.tmpl +++ b/workspace_tools/export/gcc_arm_disco_f100rb.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m3 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_disco_f407vg.tmpl b/workspace_tools/export/gcc_arm_disco_f407vg.tmpl index 5384d24d23..dc0236cf49 100644 --- a/workspace_tools/export/gcc_arm_disco_f407vg.tmpl +++ b/workspace_tools/export/gcc_arm_disco_f407vg.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -g3 +CC_FLAGS = $(CPU) -c -g3 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m4 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_k20d5m.tmpl b/workspace_tools/export/gcc_arm_k20d5m.tmpl index a4d9e6f67d..fb2248b198 100644 --- a/workspace_tools/export/gcc_arm_k20d5m.tmpl +++ b/workspace_tools/export/gcc_arm_k20d5m.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m4 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m4 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_kl05z.tmpl b/workspace_tools/export/gcc_arm_kl05z.tmpl index f4dd633871..7e484c02ba 100644 --- a/workspace_tools/export/gcc_arm_kl05z.tmpl +++ b/workspace_tools/export/gcc_arm_kl05z.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0plus -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_kl25z.tmpl b/workspace_tools/export/gcc_arm_kl25z.tmpl index f4dd633871..7e484c02ba 100644 --- a/workspace_tools/export/gcc_arm_kl25z.tmpl +++ b/workspace_tools/export/gcc_arm_kl25z.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0plus -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_kl46z.tmpl b/workspace_tools/export/gcc_arm_kl46z.tmpl index f4dd633871..7e484c02ba 100644 --- a/workspace_tools/export/gcc_arm_kl46z.tmpl +++ b/workspace_tools/export/gcc_arm_kl46z.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0plus -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_lpc1114.tmpl b/workspace_tools/export/gcc_arm_lpc1114.tmpl index f53771ade2..4bbc5e1a0d 100644 --- a/workspace_tools/export/gcc_arm_lpc1114.tmpl +++ b/workspace_tools/export/gcc_arm_lpc1114.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_lpc11u24.tmpl b/workspace_tools/export/gcc_arm_lpc11u24.tmpl index ac89299a93..b1292f6914 100644 --- a/workspace_tools/export/gcc_arm_lpc11u24.tmpl +++ b/workspace_tools/export/gcc_arm_lpc11u24.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_lpc11u35_401.tmpl b/workspace_tools/export/gcc_arm_lpc11u35_401.tmpl index f53771ade2..4bbc5e1a0d 100644 --- a/workspace_tools/export/gcc_arm_lpc11u35_401.tmpl +++ b/workspace_tools/export/gcc_arm_lpc11u35_401.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_lpc11u35_501.tmpl b/workspace_tools/export/gcc_arm_lpc11u35_501.tmpl index f53771ade2..4bbc5e1a0d 100644 --- a/workspace_tools/export/gcc_arm_lpc11u35_501.tmpl +++ b/workspace_tools/export/gcc_arm_lpc11u35_501.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m0 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: diff --git a/workspace_tools/export/gcc_arm_lpc1768.tmpl b/workspace_tools/export/gcc_arm_lpc1768.tmpl index df057ae3c5..5d38d5a164 100644 --- a/workspace_tools/export/gcc_arm_lpc1768.tmpl +++ b/workspace_tools/export/gcc_arm_lpc1768.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m3 -mthumb -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_lpc4088.tmpl b/workspace_tools/export/gcc_arm_lpc4088.tmpl index 4f40755f51..458a73381b 100644 --- a/workspace_tools/export/gcc_arm_lpc4088.tmpl +++ b/workspace_tools/export/gcc_arm_lpc4088.tmpl @@ -18,12 +18,18 @@ LD = $(GCC_BIN)arm-none-eabi-gcc OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m4 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin clean: diff --git a/workspace_tools/export/gcc_arm_stm32f407.tmpl b/workspace_tools/export/gcc_arm_stm32f407.tmpl index d5aebbf48d..e7c442c372 100644 --- a/workspace_tools/export/gcc_arm_stm32f407.tmpl +++ b/workspace_tools/export/gcc_arm_stm32f407.tmpl @@ -20,13 +20,19 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump SIZE = $(GCC_BIN)arm-none-eabi-size CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} LD_FLAGS = -mcpu=cortex-m4 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + all: $(PROJECT).bin $(PROJECT).hex size clean: