I originally posted this in viewtopic.php?p=43841#p43841, but since this is about the generic rules.mk for all ARMCMx and not just about RP2 specifics, emulator asked me to move this discussion here.
Currenly the file os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk contains this part:
Code: Select all
OUTFILES := $(BUILDDIR)/$(PROJECT).elf \
$(BUILDDIR)/$(PROJECT).hex \
$(BUILDDIR)/$(PROJECT).bin \
$(BUILDDIR)/$(PROJECT).dmp \
Code: Select all
all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK
Makefile syntax is very sensitive to ordering. So any .mk files included before rules.mk can't store anything in OUTFILES as it will be overwritten. .mk files included after rules.mk can add something to OUTFILES, but now this isn't used in the "all"-target anymore since it has already been defined.
I suggest to change this in a way that OUTFILES can be modified by .mk files coming before rules.mk:
Code: Select all
--- a/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk
+++ b/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk
@@ -79,7 +79,8 @@ ifeq ($(DEPDIR),.)
DEPDIR = .dep
endif
-OUTFILES := $(BUILDDIR)/$(PROJECT).elf \
+# use += to allow previous .mk files to also add to OUTFILES
+OUTFILES += $(BUILDDIR)/$(PROJECT).elf \
$(BUILDDIR)/$(PROJECT).hex \
$(BUILDDIR)/$(PROJECT).bin \
$(BUILDDIR)/$(PROJECT).dmp \
Please consider merging this.
The patch is available at https://github.com/electroniceel/ChibiO ... k-outfiles and also attached to this post.