Clone of official tools
export/makefile/Makefile.tmpl@47:21ae3e5a7128, 2021-02-04 (annotated)
- Committer:
- Anders Blomdell
- Date:
- Thu Feb 04 17:17:13 2021 +0100
- Revision:
- 47:21ae3e5a7128
- Parent:
- 43:2a7da56ebd24
Add a few normpath calls
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
31:8ea194f6145b | 1 | # This file was automagically generated by mbed.org. For more information, |
The Other Jimmy |
31:8ea194f6145b | 2 | # see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded |
The Other Jimmy |
31:8ea194f6145b | 3 | |
The Other Jimmy |
31:8ea194f6145b | 4 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 5 | # Boiler-plate |
The Other Jimmy |
31:8ea194f6145b | 6 | |
The Other Jimmy |
31:8ea194f6145b | 7 | # cross-platform directory manipulation |
The Other Jimmy |
31:8ea194f6145b | 8 | ifeq ($(shell echo $$OS),$$OS) |
The Other Jimmy |
31:8ea194f6145b | 9 | MAKEDIR = if not exist "$(1)" mkdir "$(1)" |
The Other Jimmy |
31:8ea194f6145b | 10 | RM = rmdir /S /Q "$(1)" |
The Other Jimmy |
31:8ea194f6145b | 11 | else |
The Other Jimmy |
31:8ea194f6145b | 12 | MAKEDIR = '$(SHELL)' -c "mkdir -p \"$(1)\"" |
The Other Jimmy |
31:8ea194f6145b | 13 | RM = '$(SHELL)' -c "rm -rf \"$(1)\"" |
The Other Jimmy |
31:8ea194f6145b | 14 | endif |
The Other Jimmy |
31:8ea194f6145b | 15 | |
The Other Jimmy |
31:8ea194f6145b | 16 | OBJDIR := BUILD |
The Other Jimmy |
31:8ea194f6145b | 17 | # Move to the build directory |
The Other Jimmy |
31:8ea194f6145b | 18 | ifeq (,$(filter $(OBJDIR),$(notdir $(CURDIR)))) |
The Other Jimmy |
31:8ea194f6145b | 19 | .SUFFIXES: |
The Other Jimmy |
31:8ea194f6145b | 20 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) |
The Other Jimmy |
31:8ea194f6145b | 21 | MAKETARGET = '$(MAKE)' --no-print-directory -C $(OBJDIR) -f '$(mkfile_path)' \ |
The Other Jimmy |
31:8ea194f6145b | 22 | 'SRCDIR=$(CURDIR)' $(MAKECMDGOALS) |
The Other Jimmy |
31:8ea194f6145b | 23 | .PHONY: $(OBJDIR) clean |
The Other Jimmy |
31:8ea194f6145b | 24 | all: |
The Other Jimmy |
31:8ea194f6145b | 25 | +@$(call MAKEDIR,$(OBJDIR)) |
The Other Jimmy |
31:8ea194f6145b | 26 | +@$(MAKETARGET) |
The Other Jimmy |
31:8ea194f6145b | 27 | $(OBJDIR): all |
The Other Jimmy |
31:8ea194f6145b | 28 | Makefile : ; |
The Other Jimmy |
31:8ea194f6145b | 29 | % :: $(OBJDIR) ; : |
The Other Jimmy |
31:8ea194f6145b | 30 | clean : |
The Other Jimmy |
31:8ea194f6145b | 31 | $(call RM,$(OBJDIR)) |
The Other Jimmy |
31:8ea194f6145b | 32 | {% block target_clean -%} |
The Other Jimmy |
31:8ea194f6145b | 33 | {% endblock %} |
The Other Jimmy |
31:8ea194f6145b | 34 | else |
The Other Jimmy |
31:8ea194f6145b | 35 | |
The Other Jimmy |
31:8ea194f6145b | 36 | # trick rules into thinking we are in the root, when we are in the bulid dir |
The Other Jimmy |
31:8ea194f6145b | 37 | VPATH = {{vpath|join(" ")}} |
The Other Jimmy |
31:8ea194f6145b | 38 | |
The Other Jimmy |
31:8ea194f6145b | 39 | # Boiler-plate |
The Other Jimmy |
31:8ea194f6145b | 40 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 41 | # Project settings |
The Other Jimmy |
31:8ea194f6145b | 42 | |
The Other Jimmy |
31:8ea194f6145b | 43 | PROJECT := {{name}} |
The Other Jimmy |
31:8ea194f6145b | 44 | |
The Other Jimmy |
31:8ea194f6145b | 45 | |
The Other Jimmy |
31:8ea194f6145b | 46 | # Project settings |
The Other Jimmy |
31:8ea194f6145b | 47 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 48 | # Objects and Paths |
The Other Jimmy |
31:8ea194f6145b | 49 | |
The Other Jimmy |
31:8ea194f6145b | 50 | {% for obj in to_be_compiled %}OBJECTS += {{obj}} |
The Other Jimmy |
31:8ea194f6145b | 51 | {% endfor %} |
The Other Jimmy |
31:8ea194f6145b | 52 | {% for obj in object_files %} SYS_OBJECTS += {{obj}} |
The Other Jimmy |
31:8ea194f6145b | 53 | {% endfor %} |
The Other Jimmy |
31:8ea194f6145b | 54 | {% for path in include_paths %}INCLUDE_PATHS += -I{{path}} |
The Other Jimmy |
31:8ea194f6145b | 55 | {% endfor %} |
The Other Jimmy |
31:8ea194f6145b | 56 | LIBRARY_PATHS :={% for p in library_paths %} {{user_library_flag}}{{p}} {% endfor %} |
The Other Jimmy |
31:8ea194f6145b | 57 | LIBRARIES :={% for lib in libraries %} {{lib}} {% endfor %} |
The Other Jimmy |
35:da9c89f8be7d | 58 | LINKER_SCRIPT ?= {{linker_script}} |
The Other Jimmy |
31:8ea194f6145b | 59 | {%- block additional_variables -%}{% endblock %} |
The Other Jimmy |
31:8ea194f6145b | 60 | |
The Other Jimmy |
31:8ea194f6145b | 61 | # Objects and Paths |
The Other Jimmy |
31:8ea194f6145b | 62 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 63 | # Tools and Flags |
The Other Jimmy |
31:8ea194f6145b | 64 | |
The Other Jimmy |
31:8ea194f6145b | 65 | AS = {{asm_cmd}} |
The Other Jimmy |
31:8ea194f6145b | 66 | CC = {{cc_cmd}} |
The Other Jimmy |
31:8ea194f6145b | 67 | CPP = {{cppc_cmd}} |
The Other Jimmy |
31:8ea194f6145b | 68 | LD = {{ld_cmd}} |
The Other Jimmy |
31:8ea194f6145b | 69 | ELF2BIN = {{elf2bin_cmd}} |
The Other Jimmy |
36:96847d42f010 | 70 | {% if pp_cmd -%} |
The Other Jimmy |
36:96847d42f010 | 71 | PREPROC = {{pp_cmd}} |
The Other Jimmy |
36:96847d42f010 | 72 | {%- endif %} |
The Other Jimmy |
31:8ea194f6145b | 73 | {% if hex_files %} |
The Other Jimmy |
31:8ea194f6145b | 74 | SREC_CAT = srec_cat |
The Other Jimmy |
31:8ea194f6145b | 75 | {%- endif %} |
The Other Jimmy |
31:8ea194f6145b | 76 | {%- block additional_executables -%}{%- endblock %} |
The Other Jimmy |
31:8ea194f6145b | 77 | |
theotherjimmy |
43:2a7da56ebd24 | 78 | {% for flag in c_flags %}C_FLAGS += {{shell_escape(flag)}} |
The Other Jimmy |
31:8ea194f6145b | 79 | {% endfor %} |
theotherjimmy |
43:2a7da56ebd24 | 80 | {% for flag in cxx_flags %}CXX_FLAGS += {{shell_escape(flag)}} |
The Other Jimmy |
31:8ea194f6145b | 81 | {% endfor %} |
theotherjimmy |
43:2a7da56ebd24 | 82 | {% for flag in asm_flags %}ASM_FLAGS += {{shell_escape(flag)}} |
The Other Jimmy |
31:8ea194f6145b | 83 | {% endfor %} |
The Other Jimmy |
31:8ea194f6145b | 84 | |
The Other Jimmy |
31:8ea194f6145b | 85 | LD_FLAGS :={%- block ld_flags -%} {{ld_flags|join(" ")}} {% endblock %} |
The Other Jimmy |
35:da9c89f8be7d | 86 | LD_SYS_LIBS :={%- block sys_libs -%} {{ld_sys_libs|join(" ")}} {% endblock %} |
The Other Jimmy |
31:8ea194f6145b | 87 | |
The Other Jimmy |
31:8ea194f6145b | 88 | # Tools and Flags |
The Other Jimmy |
31:8ea194f6145b | 89 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 90 | # Rules |
The Other Jimmy |
31:8ea194f6145b | 91 | |
The Other Jimmy |
31:8ea194f6145b | 92 | .PHONY: all lst size |
The Other Jimmy |
31:8ea194f6145b | 93 | |
The Other Jimmy |
31:8ea194f6145b | 94 | {% if hex_files -%} |
The Other Jimmy |
31:8ea194f6145b | 95 | all: $(PROJECT).bin $(PROJECT)-combined.hex size |
The Other Jimmy |
31:8ea194f6145b | 96 | {% else %} |
The Other Jimmy |
31:8ea194f6145b | 97 | all: $(PROJECT).bin $(PROJECT).hex size |
The Other Jimmy |
31:8ea194f6145b | 98 | {% endif %} |
The Other Jimmy |
31:8ea194f6145b | 99 | |
The Other Jimmy |
31:8ea194f6145b | 100 | .s.o: |
The Other Jimmy |
31:8ea194f6145b | 101 | +@$(call MAKEDIR,$(dir $@)) |
The Other Jimmy |
31:8ea194f6145b | 102 | +@echo "Assemble: $(notdir $<)" |
theotherjimmy |
40:7d3fa6b99b2b | 103 | {% if needs_asm_preproc %} |
theotherjimmy |
42:2cf3f29fece1 | 104 | @$(AS) -c $(ASM_FLAGS) -E -o $(@:.o=.E.s) $< |
theotherjimmy |
42:2cf3f29fece1 | 105 | @$(AS) -c $(ASM_FLAGS) -o $@ $(@:.o=.E.s) |
theotherjimmy |
40:7d3fa6b99b2b | 106 | {% else %} |
theotherjimmy |
42:2cf3f29fece1 | 107 | @$(AS) -c $(ASM_FLAGS) -o $@ $< |
theotherjimmy |
40:7d3fa6b99b2b | 108 | {% endif %} |
theotherjimmy |
40:7d3fa6b99b2b | 109 | |
The Other Jimmy |
31:8ea194f6145b | 110 | |
The Other Jimmy |
31:8ea194f6145b | 111 | .S.o: |
The Other Jimmy |
31:8ea194f6145b | 112 | +@$(call MAKEDIR,$(dir $@)) |
The Other Jimmy |
31:8ea194f6145b | 113 | +@echo "Assemble: $(notdir $<)" |
theotherjimmy |
40:7d3fa6b99b2b | 114 | {% if needs_asm_preproc %} |
theotherjimmy |
42:2cf3f29fece1 | 115 | @$(AS) -c $(ASM_FLAGS) -E -o $(@:.o=.E.s) $< |
theotherjimmy |
42:2cf3f29fece1 | 116 | @$(AS) -c $(ASM_FLAGS) -o $@ $(@:.o=.E.s) |
theotherjimmy |
40:7d3fa6b99b2b | 117 | {% else %} |
theotherjimmy |
42:2cf3f29fece1 | 118 | @$(AS) -c $(ASM_FLAGS) -o $@ $< |
theotherjimmy |
40:7d3fa6b99b2b | 119 | {% endif %} |
The Other Jimmy |
31:8ea194f6145b | 120 | |
The Other Jimmy |
31:8ea194f6145b | 121 | .c.o: |
The Other Jimmy |
31:8ea194f6145b | 122 | +@$(call MAKEDIR,$(dir $@)) |
The Other Jimmy |
31:8ea194f6145b | 123 | +@echo "Compile: $(notdir $<)" |
The Other Jimmy |
31:8ea194f6145b | 124 | @$(CC) $(C_FLAGS) $(INCLUDE_PATHS) -o $@ $< |
The Other Jimmy |
31:8ea194f6145b | 125 | |
The Other Jimmy |
31:8ea194f6145b | 126 | .cpp.o: |
The Other Jimmy |
31:8ea194f6145b | 127 | +@$(call MAKEDIR,$(dir $@)) |
The Other Jimmy |
31:8ea194f6145b | 128 | +@echo "Compile: $(notdir $<)" |
The Other Jimmy |
31:8ea194f6145b | 129 | @$(CPP) $(CXX_FLAGS) $(INCLUDE_PATHS) -o $@ $< |
The Other Jimmy |
31:8ea194f6145b | 130 | |
The Other Jimmy |
36:96847d42f010 | 131 | {% if pp_cmd %} |
The Other Jimmy |
36:96847d42f010 | 132 | $(PROJECT).link_script{{link_script_ext}}: $(LINKER_SCRIPT) |
The Other Jimmy |
36:96847d42f010 | 133 | @$(PREPROC) $< -o $@ |
The Other Jimmy |
36:96847d42f010 | 134 | {% endif %} |
The Other Jimmy |
36:96847d42f010 | 135 | |
The Other Jimmy |
31:8ea194f6145b | 136 | {% block target_project_elf %} |
The Other Jimmy |
36:96847d42f010 | 137 | $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) {% if pp_cmd -%} $(PROJECT).link_script{{link_script_ext}} {% else%} $(LINKER_SCRIPT) {% endif %} |
The Other Jimmy |
31:8ea194f6145b | 138 | +@echo "link: $(notdir $@)" |
theotherjimmy |
40:7d3fa6b99b2b | 139 | @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS) |
The Other Jimmy |
31:8ea194f6145b | 140 | {% endblock %} |
The Other Jimmy |
31:8ea194f6145b | 141 | |
The Other Jimmy |
31:8ea194f6145b | 142 | $(PROJECT).bin: $(PROJECT).elf |
The Other Jimmy |
31:8ea194f6145b | 143 | {%- block elf2bin -%}{%- endblock %} |
The Other Jimmy |
31:8ea194f6145b | 144 | {% if not hex_files %} +@echo "===== bin file ready to flash: $(OBJDIR)/$@ =====" {% endif %} |
The Other Jimmy |
31:8ea194f6145b | 145 | |
The Other Jimmy |
31:8ea194f6145b | 146 | $(PROJECT).hex: $(PROJECT).elf |
The Other Jimmy |
31:8ea194f6145b | 147 | {%- block elf2hex -%}{%- endblock %} |
The Other Jimmy |
31:8ea194f6145b | 148 | |
The Other Jimmy |
31:8ea194f6145b | 149 | {% if hex_files %} |
The Other Jimmy |
31:8ea194f6145b | 150 | $(PROJECT)-combined.hex: $(PROJECT).hex |
The Other Jimmy |
31:8ea194f6145b | 151 | +@echo "NOTE: the $(SREC_CAT) binary is required to be present in your PATH. Please see http://srecord.sourceforge.net/ for more information." |
The Other Jimmy |
31:8ea194f6145b | 152 | $(SREC_CAT) {% for f in hex_files %}{{f}} {% endfor %} -intel $(PROJECT).hex -intel -o $(PROJECT)-combined.hex -intel --line-length=44 |
The Other Jimmy |
31:8ea194f6145b | 153 | +@echo "===== hex file ready to flash: $(OBJDIR)/$@ =====" |
The Other Jimmy |
31:8ea194f6145b | 154 | {% endif %} |
The Other Jimmy |
31:8ea194f6145b | 155 | # Rules |
The Other Jimmy |
31:8ea194f6145b | 156 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 157 | # Dependencies |
The Other Jimmy |
31:8ea194f6145b | 158 | |
The Other Jimmy |
31:8ea194f6145b | 159 | DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) |
The Other Jimmy |
31:8ea194f6145b | 160 | -include $(DEPS) |
The Other Jimmy |
31:8ea194f6145b | 161 | endif |
The Other Jimmy |
31:8ea194f6145b | 162 | |
The Other Jimmy |
31:8ea194f6145b | 163 | # Dependencies |
The Other Jimmy |
31:8ea194f6145b | 164 | ############################################################################### |
The Other Jimmy |
31:8ea194f6145b | 165 |