From c52227d850bd851d00f56a020d437cebb2cc13aa Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 24 May 2016 10:40:00 -0500 Subject: [PATCH 1/5] makefile exports now create and use bin for all built files I know this looks really weird, here is why: The first time the makefile is run, in the project root, the first part of the if is triggered. This part of the makefile records the root directory and creates the bin diretory. Then it runs itself in the bin diretory. This triggers the else part of the makefile. The last bit of magic is that VPATH=... line. The VPATH is a special make variable that specifies extra directories to search for dependencies in. This particular assignment of VPATH allows make to find sources from the root, but forces all results to be in the bin dir. This has two benifits: 1. the makefile is written as if it's in the project root, but results are always in bin 2. the clean phony target may just remove bin, as this is always correct --- workspace_tools/export/gcc_arm_common.tmpl | 41 ++++++++++++++++------ workspace_tools/export/gccarm.py | 2 ++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/workspace_tools/export/gcc_arm_common.tmpl b/workspace_tools/export/gcc_arm_common.tmpl index d641b0af3dd..0136f5fedbb 100644 --- a/workspace_tools/export/gcc_arm_common.tmpl +++ b/workspace_tools/export/gcc_arm_common.tmpl @@ -1,12 +1,32 @@ # This file was automagically generated by mbed.org. For more information, # see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded +ifeq (,$(filter bin,$(notdir $(CURDIR)))) +.SUFFIXES: +OBJDIR := bin +MAKETARGET = $(MAKE) --no-print-directory -C $@ -f $(CURDIR)/Makefile \ + SRCDIR=$(CURDIR) $(MAKECMDGOALS) +.PHONY: $(OBJDIR) clean +$(OBJDIR): + +@[ -d $@ ] || mkdir -p $@ + +@$(MAKETARGET) +Makefile : ; +% :: $(OBJDIR) ; : +clean : + rm -rf $(OBJDIR) +{% block target_clean -%} +{% endblock %} +else + +VPATH = $(SRCDIR) + + GCC_BIN = PROJECT = {{name}} OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} +INCLUDE_PATHS = {% for p in include_paths %}-I../{{p}} {% endfor %} +LIBRARY_PATHS = {% for p in library_paths %}-L../{{p}} {% endfor %} LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} LINKER_SCRIPT = {{linker_script}} {%- block additional_variables -%}{% endblock %} @@ -54,34 +74,34 @@ else CC_FLAGS += -DNDEBUG -Os endif -.PHONY: all clean lst size +.PHONY: all lst size {% block target_all -%} all: $(PROJECT).bin $(PROJECT).hex size {% endblock %} -{% block target_clean -%} -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) -{% endblock %} - .asm.o: + @[ -d $(dir $@)] || mkdir -p $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .s.o: + @[ -d $(dir $@)] || mkdir -p $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .S.o: + @[ -d $(dir $@)] || mkdir -p $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .c.o: + @[ -d $(dir $@)] || mkdir -p $(dir $@) $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< .cpp.o: + @[ -d $(dir $@)] || mkdir -p $(dir $@) $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< {% block target_project_elf %} -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SRCIPT) + $(LD) $(LD_FLAGS) -T$(filter-out %.o,$^) $(LIBRARY_PATHS) -o $@ $(filter %.o,$^) -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group {% endblock %} $(PROJECT).bin: $(PROJECT).elf @@ -103,3 +123,4 @@ DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) {% block additional_targets %}{% endblock %} +endif diff --git a/workspace_tools/export/gccarm.py b/workspace_tools/export/gccarm.py index 18e67f55ad9..5f48a58477f 100755 --- a/workspace_tools/export/gccarm.py +++ b/workspace_tools/export/gccarm.py @@ -16,6 +16,7 @@ """ from exporters import Exporter from os.path import splitext, basename +from os import curdir class GccArm(Exporter): @@ -122,6 +123,7 @@ class GccArm(Exporter): def generate(self): # "make" wants Unix paths self.resources.win_to_unix() + self.resources.relative_to(curdir) to_be_compiled = [] for r_type in ['s_sources', 'c_sources', 'cpp_sources']: From 284810b3656d37c4935974794481fcca8650cef2 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 24 May 2016 10:46:09 -0500 Subject: [PATCH 2/5] sam*::gcc_arm targets extend the common makefile --- .../export/gcc_arm_samd21g18a.tmpl | 75 +------------------ .../export/gcc_arm_samd21j18a.tmpl | 75 +------------------ .../export/gcc_arm_saml21j18a.tmpl | 75 +------------------ .../export/gcc_arm_samr21g18a.tmpl | 75 +------------------ 4 files changed, 12 insertions(+), 288 deletions(-) diff --git a/workspace_tools/export/gcc_arm_samd21g18a.tmpl b/workspace_tools/export/gcc_arm_samd21g18a.tmpl index b71f60c6bb9..ef369548cc2 100644 --- a/workspace_tools/export/gcc_arm_samd21g18a.tmpl +++ b/workspace_tools/export/gcc_arm_samd21g18a.tmpl @@ -1,72 +1,3 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = {{name}} -OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} -SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} -LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} -LINKER_SCRIPT = {{linker_script}} - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-g++ -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -CC_FLAGS += -MMD -MP -CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -all: $(PROJECT).bin $(PROJECT).hex - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - -.s.o: - $(AS) $(CPU) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - $(SIZE) $@ - -$(PROJECT).bin: $(PROJECT).elf - @$(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - +{% extends "gcc_arm_common.tmpl" %} +{% block cpu %} -mcpu=cortex-m0plus -mthumb {% endblock %} +{% block ld_sys_libs %}{{ super() }} -Wl,--start-group -lc -lc -lnosys -Wl,--end-group {% endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_samd21j18a.tmpl b/workspace_tools/export/gcc_arm_samd21j18a.tmpl index b71f60c6bb9..ef369548cc2 100644 --- a/workspace_tools/export/gcc_arm_samd21j18a.tmpl +++ b/workspace_tools/export/gcc_arm_samd21j18a.tmpl @@ -1,72 +1,3 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = {{name}} -OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} -SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} -LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} -LINKER_SCRIPT = {{linker_script}} - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-g++ -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -CC_FLAGS += -MMD -MP -CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -all: $(PROJECT).bin $(PROJECT).hex - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - -.s.o: - $(AS) $(CPU) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - $(SIZE) $@ - -$(PROJECT).bin: $(PROJECT).elf - @$(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - +{% extends "gcc_arm_common.tmpl" %} +{% block cpu %} -mcpu=cortex-m0plus -mthumb {% endblock %} +{% block ld_sys_libs %}{{ super() }} -Wl,--start-group -lc -lc -lnosys -Wl,--end-group {% endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_saml21j18a.tmpl b/workspace_tools/export/gcc_arm_saml21j18a.tmpl index b71f60c6bb9..ef369548cc2 100644 --- a/workspace_tools/export/gcc_arm_saml21j18a.tmpl +++ b/workspace_tools/export/gcc_arm_saml21j18a.tmpl @@ -1,72 +1,3 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = {{name}} -OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} -SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} -LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} -LINKER_SCRIPT = {{linker_script}} - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-g++ -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -CC_FLAGS += -MMD -MP -CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -all: $(PROJECT).bin $(PROJECT).hex - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - -.s.o: - $(AS) $(CPU) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - $(SIZE) $@ - -$(PROJECT).bin: $(PROJECT).elf - @$(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - +{% extends "gcc_arm_common.tmpl" %} +{% block cpu %} -mcpu=cortex-m0plus -mthumb {% endblock %} +{% block ld_sys_libs %}{{ super() }} -Wl,--start-group -lc -lc -lnosys -Wl,--end-group {% endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_samr21g18a.tmpl b/workspace_tools/export/gcc_arm_samr21g18a.tmpl index b71f60c6bb9..ef369548cc2 100644 --- a/workspace_tools/export/gcc_arm_samr21g18a.tmpl +++ b/workspace_tools/export/gcc_arm_samr21g18a.tmpl @@ -1,72 +1,3 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = {{name}} -OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} -SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} -LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} -LINKER_SCRIPT = {{linker_script}} - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-g++ -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -CPU = -mcpu=cortex-m0plus -mthumb -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -CC_FLAGS += -MMD -MP -CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -all: $(PROJECT).bin $(PROJECT).hex - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - -.s.o: - $(AS) $(CPU) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - $(SIZE) $@ - -$(PROJECT).bin: $(PROJECT).elf - @$(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - +{% extends "gcc_arm_common.tmpl" %} +{% block cpu %} -mcpu=cortex-m0plus -mthumb {% endblock %} +{% block ld_sys_libs %}{{ super() }} -Wl,--start-group -lc -lc -lnosys -Wl,--end-group {% endblock %} \ No newline at end of file From 4259533d36eb50df263d40e287917f5b4b02795b Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 24 May 2016 10:50:05 -0500 Subject: [PATCH 3/5] Made the efm32 targets use the common makefile template The prior implementation of the efm32 makefile templates used a custom version of the bin diretory creation. My version has a few advantages: 1. the targets are always forced into bin. this is different from the old style, where any custom rules might polute the project root directory 2. smaller templates 3. fewer total templates --- .../export/gcc_arm_efm32_common.tmpl | 115 ------------------ .../export/gcc_arm_efm32gg_stk3700.tmpl | 9 +- .../export/gcc_arm_efm32hg_stk3400.tmpl | 9 +- .../export/gcc_arm_efm32lg_stk3600.tmpl | 9 +- .../export/gcc_arm_efm32pg_stk3401.tmpl | 9 +- .../export/gcc_arm_efm32wg_stk3800.tmpl | 9 +- .../export/gcc_arm_efm32zg_stk3200.tmpl | 9 +- 7 files changed, 48 insertions(+), 121 deletions(-) delete mode 100644 workspace_tools/export/gcc_arm_efm32_common.tmpl diff --git a/workspace_tools/export/gcc_arm_efm32_common.tmpl b/workspace_tools/export/gcc_arm_efm32_common.tmpl deleted file mode 100644 index c73a8c3588c..00000000000 --- a/workspace_tools/export/gcc_arm_efm32_common.tmpl +++ /dev/null @@ -1,115 +0,0 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = {{name}} -OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} -SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} -INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} -LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} -LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} -LINKER_SCRIPT = {{linker_script}} - -OUT_DIR = bin -OBJ_FOLDER = $(strip $(OUT_DIR))/ - -{%- block additional_variables -%}{% endblock %} - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-gcc -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size -{%- block additional_executables -%}{% endblock %} - -{%- block flags -%} - -{% block hardfp %} -{% if "-mfloat-abi=softfp" in cpu_flags %} -ifeq ($(HARDFP),1) - FLOAT_ABI = hard -else - FLOAT_ABI = softfp -endif -{% endif %} -{%- endblock %} - -CPU = {% block cpu %}{% for cf in cpu_flags %}{{cf|replace("-mfloat-abi=softfp","-mfloat-abi=$(FLOAT_ABI)")}} {% endfor %}{% endblock %} -CC_FLAGS = {% block cc_flags %}$(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP{% endblock %} -CC_SYMBOLS = {% block cc_symbols %}{% for s in symbols %}-D{{s}} {% endfor %}{% endblock %} - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -LD_FLAGS = {%- block ld_flags -%} -{%- if "-mcpu=cortex-m0" in cpu_flags or "-mcpu=cortex-m0plus" in cpu_flags -%} -{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -Wl,--wrap,main -Wl,-Map=$(OBJ_FOLDER)$(PROJECT).map,--cref -#LD_FLAGS += -u _printf_float -u _scanf_float -{%- else -%} -{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(OBJ_FOLDER)$(PROJECT).map,--cref -{%- endif -%} -{% endblock %} -LD_SYS_LIBS = {% block ld_sys_libs %}-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys{% endblock %} -{% endblock %} - -.PHONY: all clean lst size - -{% block target_all -%} -all: create_outputdir $(OBJ_FOLDER)$(PROJECT).bin $(OBJ_FOLDER)$(PROJECT).hex size -{% endblock %} - -{% block target_create_outputdir -%} -create_outputdir: - $(shell mkdir $(OBJ_FOLDER) 2>/dev/null) -{% endblock %} - -{% block target_clean -%} -clean: - rm -f $(OBJ_FOLDER)$(PROJECT).bin $(OBJ_FOLDER)$(PROJECT).axf $(OBJ_FOLDER)$(PROJECT).hex $(OBJ_FOLDER)$(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) -{% endblock %} - -.s.o: - $(AS) $(CPU) -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - -{% block target_project_axf %} -$(OBJ_FOLDER)$(PROJECT).axf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - @echo "" - @echo "*****" - @echo "***** You must modify vector checksum value in *.bin and *.hex files." - @echo "*****" - @echo "" -{% endblock %} - -$(OBJ_FOLDER)$(PROJECT).bin: $(OBJ_FOLDER)$(PROJECT).axf - @$(OBJCOPY) -O binary $< $@ - -$(OBJ_FOLDER)$(PROJECT).hex: $(OBJ_FOLDER)$(PROJECT).axf - @$(OBJCOPY) -O ihex $< $@ - -$(OBJ_FOLDER)$(PROJECT).lst: $(OBJ_FOLDER)$(PROJECT).axf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(OBJ_FOLDER)$(PROJECT).lst - -size: $(OBJ_FOLDER)$(PROJECT).axf - $(SIZE) $(OBJ_FOLDER)$(PROJECT).axf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - -{% block additional_targets %}{% endblock %} - diff --git a/workspace_tools/export/gcc_arm_efm32gg_stk3700.tmpl b/workspace_tools/export/gcc_arm_efm32gg_stk3700.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32gg_stk3700.tmpl +++ b/workspace_tools/export/gcc_arm_efm32gg_stk3700.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_efm32hg_stk3400.tmpl b/workspace_tools/export/gcc_arm_efm32hg_stk3400.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32hg_stk3400.tmpl +++ b/workspace_tools/export/gcc_arm_efm32hg_stk3400.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_efm32lg_stk3600.tmpl b/workspace_tools/export/gcc_arm_efm32lg_stk3600.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32lg_stk3600.tmpl +++ b/workspace_tools/export/gcc_arm_efm32lg_stk3600.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_efm32pg_stk3401.tmpl b/workspace_tools/export/gcc_arm_efm32pg_stk3401.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32pg_stk3401.tmpl +++ b/workspace_tools/export/gcc_arm_efm32pg_stk3401.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_efm32wg_stk3800.tmpl b/workspace_tools/export/gcc_arm_efm32wg_stk3800.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32wg_stk3800.tmpl +++ b/workspace_tools/export/gcc_arm_efm32wg_stk3800.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file diff --git a/workspace_tools/export/gcc_arm_efm32zg_stk3200.tmpl b/workspace_tools/export/gcc_arm_efm32zg_stk3200.tmpl index 7187abc9ca3..f5ee4148d39 100644 --- a/workspace_tools/export/gcc_arm_efm32zg_stk3200.tmpl +++ b/workspace_tools/export/gcc_arm_efm32zg_stk3200.tmpl @@ -1 +1,8 @@ -{% extends "gcc_arm_efm32_common.tmpl" %} +{% extends "gcc_arm_common.tmpl" %} + +{% block target_project_elf %} {{ super() }} @echo "" + @echo "*****" + @echo "***** You must modify vector checksum value in *.bin and *.hex files." + @echo "*****" + @echo "" +{%- endblock %} \ No newline at end of file From 60fb4ff4183c10b3c2861b9ccfbd246ab9ae788a Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Fri, 3 Jun 2016 11:02:46 -0500 Subject: [PATCH 4/5] removed -p from mkdir from windows --- workspace_tools/export/gcc_arm_common.tmpl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/workspace_tools/export/gcc_arm_common.tmpl b/workspace_tools/export/gcc_arm_common.tmpl index 0136f5fedbb..16d0168f097 100644 --- a/workspace_tools/export/gcc_arm_common.tmpl +++ b/workspace_tools/export/gcc_arm_common.tmpl @@ -1,6 +1,12 @@ # This file was automagically generated by mbed.org. For more information, # see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded +ifeq ($(OS),Windows_NT) +MKDIR := mkdir +else +MKDIR := mkdir -p +endif + ifeq (,$(filter bin,$(notdir $(CURDIR)))) .SUFFIXES: OBJDIR := bin @@ -8,7 +14,7 @@ MAKETARGET = $(MAKE) --no-print-directory -C $@ -f $(CURDIR)/Makefile \ SRCDIR=$(CURDIR) $(MAKECMDGOALS) .PHONY: $(OBJDIR) clean $(OBJDIR): - +@[ -d $@ ] || mkdir -p $@ + +@[ -d $@ ] || $(MKDIR) $@ +@$(MAKETARGET) Makefile : ; % :: $(OBJDIR) ; : @@ -81,21 +87,21 @@ all: $(PROJECT).bin $(PROJECT).hex size {% endblock %} .asm.o: - @[ -d $(dir $@)] || mkdir -p $(dir $@) + @[ -d $(dir $@)] || $(MKDIR) $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .s.o: - @[ -d $(dir $@)] || mkdir -p $(dir $@) + @[ -d $(dir $@)] || $(MKDIR) $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .S.o: - @[ -d $(dir $@)] || mkdir -p $(dir $@) + @[ -d $(dir $@)] || $(MKDIR) $(dir $@) $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .c.o: - @[ -d $(dir $@)] || mkdir -p $(dir $@) + @[ -d $(dir $@)] || $(MKDIR) $(dir $@) $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< .cpp.o: - @[ -d $(dir $@)] || mkdir -p $(dir $@) + @[ -d $(dir $@)] || $(MKDIR) $(dir $@) $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< From edd1932fe813f59e3772d2468ef4589885e1f112 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Mon, 6 Jun 2016 11:09:14 -0500 Subject: [PATCH 5/5] Fix typo in `LINKER_SCRIPT` variable name --- workspace_tools/export/gcc_arm_common.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/gcc_arm_common.tmpl b/workspace_tools/export/gcc_arm_common.tmpl index 16d0168f097..cc2ec6fc127 100644 --- a/workspace_tools/export/gcc_arm_common.tmpl +++ b/workspace_tools/export/gcc_arm_common.tmpl @@ -106,7 +106,7 @@ all: $(PROJECT).bin $(PROJECT).hex size {% block target_project_elf %} -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SRCIPT) +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SCRIPT) $(LD) $(LD_FLAGS) -T$(filter-out %.o,$^) $(LIBRARY_PATHS) -o $@ $(filter %.o,$^) -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group {% endblock %}