Skip to content

[Exporters-gcc_arm] Clean up the source directory #2060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions tools/export/gcc_arm_common.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
# This file was automagically generated by mbed.org. For more information,
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded

# cross-platform directory manipulation
ifeq ($(OSTYPE),)
MAKEDIR = if not exist "$(1)" mkdir "$(1)"
RM = rmdir /S /Q
else
MAKEDIR = mkdir -p $(1)
RM = rm -rf
endif

ifeq (,$(filter .build,$(notdir $(CURDIR))))
.SUFFIXES:
OBJDIR := .build
MAKETARGET = $(MAKE) --no-print-directory -C $(OBJDIR) -f $(CURDIR)/Makefile \
SRCDIR=$(CURDIR) $(MAKECMDGOALS)
.PHONY: $(OBJDIR) clean
all:
+@$(call MAKEDIR,$(OBJDIR))
+@$(MAKETARGET)
$(OBJDIR): all
Makefile : ;
% :: $(OBJDIR) ; :
clean :
$(RM) $(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 %}
Expand Down Expand Up @@ -49,34 +78,36 @@ 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:
+@$(call MAKEDIR,$(dir $@))
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<
.s.o:
+@$(call MAKEDIR,$(dir $@))
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<
.S.o:
+@$(call MAKEDIR,$(dir $@))
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<

.c.o:
+@$(call MAKEDIR,$(dir $@))
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) $(INCLUDE_PATHS) -o $@ $<

.cpp.o:
+@$(call MAKEDIR,$(dir $@))
$(CPP) $(CPPC_FLAGS) $(CC_SYMBOLS) $(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_SCRIPT)
$(LD) $(LD_FLAGS) -T$(filter %.ld, $^) $(LIBRARY_PATHS) -o $@ $(filter %.o, $^) -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group
{% endblock %}

$(PROJECT).bin: $(PROJECT).elf
Expand All @@ -97,4 +128,5 @@ DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
-include $(DEPS)

{% block additional_targets %}{% endblock %}
endif

115 changes: 0 additions & 115 deletions tools/export/gcc_arm_efm32_common.tmpl

This file was deleted.

9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32gg_stk3700.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32hg_stk3400.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32lg_stk3600.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32pg_stk3401.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32wg_stk3800.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 8 additions & 1 deletion tools/export/gcc_arm_efm32zg_stk3200.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
74 changes: 3 additions & 71 deletions tools/export/gcc_arm_samd21g18a.tmpl
Original file line number Diff line number Diff line change
@@ -1,72 +1,4 @@
# 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 %}
Loading