Advertisement
Guest User

Untitled

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