diff --git a/Makefile b/Makefile index 4d91115ff..eafe09b0b 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,8 @@ objs = $(call object_for,$(src)) # but allows correct yet optimal incremental builds. -include $(objs:.o=.d) +executables = epsilon test + #define platform generic targets $(BUILD_DIR)/epsilon.$(EXE): $(objs) $(call object_for,$(ion_device_dfu_relocated_src) $(epsilon_src)) @@ -91,17 +93,7 @@ $(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(objs) $(call o # We include them before the standard ones to give them precedence. -include scripts/targets.$(PLATFORM).mak -# Define rules for executables -# Those can be built directly with make executable.exe as a shortcut. They also -# depends on $(objs) - -executables = epsilon test -define rules_for_executable -.PHONY: $(1).$$(EXE) -$(1).$$(EXE): $$(BUILD_DIR)/$(1).$$(EXE) -endef - -$(foreach executable,$(executables),$(eval $(call rules_for_executable,$(executable)))) +$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(EXE)))) # Define standard compilation rules diff --git a/scripts/defaults.mak b/scripts/defaults.mak index 460db324c..98aa9f9d0 100644 --- a/scripts/defaults.mak +++ b/scripts/defaults.mak @@ -35,3 +35,12 @@ ifeq ("$(origin V)", "command line") endif BUILD_DIR = build/$(PLATFORM) + +# Define rules for targets +# Those can be built directly with make executable.extension as a shortcut. + +define rules_for_targets +.PHONY: $(1).$(2) +$(1).$(2): $$(BUILD_DIR)/$(1).$(2) +endef + diff --git a/scripts/targets.device.mak b/scripts/targets.device.mak index 0fd110160..cd9a8fd74 100644 --- a/scripts/targets.device.mak +++ b/scripts/targets.device.mak @@ -1,12 +1,17 @@ -%.dfu: %.$(EXE) +executables += flasher.light flasher.verbose bench.RAM bench.flash +extensions = dfu hex bin + +$(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension))))) + +$(BUILD_DIR)/%.dfu: $(BUILD_DIR)/%.$(EXE) @echo "DFUSE $@" $(Q) $(PYTHON) scripts/device/elf2dfu.py $< $@ -%.hex: %.$(EXE) +$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.$(EXE) @echo "OBJCOPY $@" $(Q) $(OBJCOPY) -O ihex $< $@ -%.bin: %.$(EXE) +$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.$(EXE) @echo "OBJCOPY $@" $(Q) $(OBJCOPY) -O binary $< $@ # We pad the device binary files because there was a bug in an older version of diff --git a/scripts/targets.device.n0110.mak b/scripts/targets.device.n0110.mak index 29cb77214..3207d0ee4 100644 --- a/scripts/targets.device.n0110.mak +++ b/scripts/targets.device.n0110.mak @@ -1,2 +1,4 @@ +executables += test_external_flash + $(BUILD_DIR)/test_external_flash.$(EXE): LDSCRIPT = ion/test/external_flash_tests.ld $(BUILD_DIR)/test_external_flash.$(EXE): $(BUILD_DIR)/quiz/src/external_flash_tests_symbols.o $(runner_objs) $(call object_for,$(tests_external_flash)) $(call object_for,$(ion_device_dfu_relocated_src))