diff --git a/tools/export/makefile/Makefile.tmpl b/tools/export/makefile/Makefile.tmpl index ed49fecd72..2c7240d5ba 100644 --- a/tools/export/makefile/Makefile.tmpl +++ b/tools/export/makefile/Makefile.tmpl @@ -97,20 +97,26 @@ all: $(PROJECT).bin $(PROJECT)-combined.hex size 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 $<)" + {% if needs_asm_preproc %} + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -E -o $(@:.o=.E.s) $< + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $(@:.o=.E.s) + {% else %} @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $< + {% endif %} + .S.o: +@$(call MAKEDIR,$(dir $@)) +@echo "Assemble: $(notdir $<)" + {% if needs_asm_preproc %} + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -E -o $(@:.o=.E.s) $< + @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $(@:.o=.E.s) + {% else %} @$(AS) -c $(ASM_FLAGS) $(INCLUDE_PATHS) -o $@ $< + {% endif %} .c.o: +@$(call MAKEDIR,$(dir $@)) diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index d67e83ff98..cab92260f9 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -35,6 +35,8 @@ class Makefile(Exporter): MBED_CONFIG_HEADER_SUPPORTED = True + PREPROCESS_ASM = False + POST_BINARY_WHITELIST = set([ "MCU_NRF51Code.binary_hook", "TEENSY3_1Code.binary_hook", @@ -96,6 +98,7 @@ class Makefile(Exporter): 'link_script_ext': self.toolchain.LINKER_EXT, 'link_script_option': self.LINK_SCRIPT_OPTION, 'user_library_flag': self.USER_LIBRARY_FLAG, + 'needs_asm_preproc': self.PREPROCESS_ASM, } if hasattr(self.toolchain, "preproc"): @@ -236,6 +239,7 @@ class Armc5(Arm): """ARM Compiler 5 (armcc) specific makefile target""" NAME = 'Make-ARMc5' TOOLCHAIN = "ARM" + PREPROCESS_ASM = True class Armc6(Arm): """ARM Compiler 6 (armclang) specific generic makefile target"""