Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-sdk-tools by
Diff: export/makefile/Makefile.tmpl
- Revision:
- 32:8ea194f6145b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/export/makefile/Makefile.tmpl Wed Jan 04 11:58:24 2017 -0600 @@ -0,0 +1,151 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +############################################################################### +# Boiler-plate + +# cross-platform directory manipulation +ifeq ($(shell echo $$OS),$$OS) + MAKEDIR = if not exist "$(1)" mkdir "$(1)" + RM = rmdir /S /Q "$(1)" +else + MAKEDIR = '$(SHELL)' -c "mkdir -p \"$(1)\"" + RM = '$(SHELL)' -c "rm -rf \"$(1)\"" +endif + +OBJDIR := BUILD +# Move to the build directory +ifeq (,$(filter $(OBJDIR),$(notdir $(CURDIR)))) +.SUFFIXES: +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +MAKETARGET = '$(MAKE)' --no-print-directory -C $(OBJDIR) -f '$(mkfile_path)' \ + 'SRCDIR=$(CURDIR)' $(MAKECMDGOALS) +.PHONY: $(OBJDIR) clean +all: + +@$(call MAKEDIR,$(OBJDIR)) + +@$(MAKETARGET) +$(OBJDIR): all +Makefile : ; +% :: $(OBJDIR) ; : +clean : + $(call RM,$(OBJDIR)) +{% block target_clean -%} +{% endblock %} +else + +# trick rules into thinking we are in the root, when we are in the bulid dir +VPATH = {{vpath|join(" ")}} + +# Boiler-plate +############################################################################### +# Project settings + +PROJECT := {{name}} + + +# Project settings +############################################################################### +# Objects and Paths + +{% for obj in to_be_compiled %}OBJECTS += {{obj}} +{% endfor %} +{% for obj in object_files %} SYS_OBJECTS += {{obj}} +{% endfor %} +{% for path in include_paths %}INCLUDE_PATHS += -I{{path}} +{% endfor %} +LIBRARY_PATHS :={% for p in library_paths %} {{user_library_flag}}{{p}} {% endfor %} +LIBRARIES :={% for lib in libraries %} {{lib}} {% endfor %} +LINKER_SCRIPT := {{linker_script}} +{%- block additional_variables -%}{% endblock %} + +# Objects and Paths +############################################################################### +# Tools and Flags + +AS = {{asm_cmd}} +CC = {{cc_cmd}} +CPP = {{cppc_cmd}} +LD = {{ld_cmd}} +ELF2BIN = {{elf2bin_cmd}} +{% if hex_files %} +SREC_CAT = srec_cat +{%- endif %} +{%- block additional_executables -%}{%- endblock %} + +{% for flag in c_flags %}C_FLAGS += {{flag}} +{% endfor %} +{% for flag in cxx_flags %}CXX_FLAGS += {{flag}} +{% endfor %} +{% for flag in asm_flags %}ASM_FLAGS += {{flag}} +{% endfor %} + +LD_FLAGS :={%- block ld_flags -%} {{ld_flags|join(" ")}} {% endblock %} +{% block sys_libs -%}{%- endblock %} + +# Tools and Flags +############################################################################### +# Rules + +.PHONY: all lst size + +{% if hex_files -%} +all: $(PROJECT).bin $(PROJECT)-combined.hex size +{% else %} +all: $(PROJECT).bin $(PROJECT).hex size +{% endif %} + +.asm.o: + +@$(call MAKEDIR,$(dir $@)) + +@echo "Assemble: $(notdir $<)" + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $< + +.s.o: + +@$(call MAKEDIR,$(dir $@)) + +@echo "Assemble: $(notdir $<)" + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $< + +.S.o: + +@$(call MAKEDIR,$(dir $@)) + +@echo "Assemble: $(notdir $<)" + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $< + +.c.o: + +@$(call MAKEDIR,$(dir $@)) + +@echo "Compile: $(notdir $<)" + @$(CC) $(C_FLAGS) $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + +@$(call MAKEDIR,$(dir $@)) + +@echo "Compile: $(notdir $<)" + @$(CPP) $(CXX_FLAGS) $(INCLUDE_PATHS) -o $@ $< + +{% block target_project_elf %} +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SCRIPT) + +@echo "link: $(notdir $@)" + @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter %{{link_script_ext}}, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS) +{% endblock %} + +$(PROJECT).bin: $(PROJECT).elf +{%- block elf2bin -%}{%- endblock %} +{% if not hex_files %} +@echo "===== bin file ready to flash: $(OBJDIR)/$@ =====" {% endif %} + +$(PROJECT).hex: $(PROJECT).elf +{%- block elf2hex -%}{%- endblock %} + +{% if hex_files %} +$(PROJECT)-combined.hex: $(PROJECT).hex + +@echo "NOTE: the $(SREC_CAT) binary is required to be present in your PATH. Please see http://srecord.sourceforge.net/ for more information." + $(SREC_CAT) {% for f in hex_files %}{{f}} {% endfor %} -intel $(PROJECT).hex -intel -o $(PROJECT)-combined.hex -intel --line-length=44 + +@echo "===== hex file ready to flash: $(OBJDIR)/$@ =====" +{% endif %} +# Rules +############################################################################### +# Dependencies + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) +endif + +# Dependencies +############################################################################### +