-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Consolidated export templates for gcc_arm target and maintained purity of the source folders #1769
Changes from all commits
c52227d
284810b
4259533
60fb4ff
edd1932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
# 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 | ||
MAKETARGET = $(MAKE) --no-print-directory -C $@ -f $(CURDIR)/Makefile \ | ||
SRCDIR=$(CURDIR) $(MAKECMDGOALS) | ||
.PHONY: $(OBJDIR) clean | ||
$(OBJDIR): | ||
+@[ -d $@ ] || $(MKDIR) $@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is a bash conditional. do you know how to do the same thing on windows? |
||
+@$(MAKETARGET) | ||
Makefile : ; | ||
% :: $(OBJDIR) ; : | ||
clean : | ||
rm -rf $(OBJDIR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this clean target work on Windows? I would expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it works. You wont have to use rd since Atmel Studio comes with shellutils which in turn supports a list of commands for Linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @akhilpanayamparambil Thanks. we need to assume also windows only. I'll give it a run in the cmd windows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably going to break horribly, I assumed bash was the shell make was running. I have to ask for my curiosity though: how does someone install make without bash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gnu packages like make for windows :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well then. I'm all ears for suggestions regarding how to do an equivalent of |
||
{% 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 +80,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) $(dir $@) | ||
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< | ||
.s.o: | ||
@[ -d $(dir $@)] || $(MKDIR) $(dir $@) | ||
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< | ||
.S.o: | ||
@[ -d $(dir $@)] || $(MKDIR) $(dir $@) | ||
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< | ||
|
||
.c.o: | ||
@[ -d $(dir $@)] || $(MKDIR) $(dir $@) | ||
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< | ||
|
||
.cpp.o: | ||
@[ -d $(dir $@)] || $(MKDIR) $(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_SCRIPT) | ||
$(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 +129,4 @@ DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) | |
|
||
{% block additional_targets %}{% endblock %} | ||
|
||
endif |
This file was deleted.
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 %} |
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 %} |
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 %} |
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 %} |
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 %} |
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 %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit hacky. Would it be better to add the bin/ prefix to your OBJECTS and switch to pattern based rules for compiling/assembling that take into account the slight difference in pathname? That way you don't need to recursively call make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that style of rules does have a drawback: any rule added to the makefile also has to have that style. On the other hand, the way I am recursively calling make has few drawbacks, as I remove all of the rules from the first invocation of make.