diff --git a/flasher_stub/Makefile b/flasher_stub/Makefile index 2faf371622..41eae45585 100644 --- a/flasher_stub/Makefile +++ b/flasher_stub/Makefile @@ -93,13 +93,21 @@ endif .PHONY: all clean embed -all: $(STUBS_ELF) - @echo " WRAP $^ -> $(BUILD_DIR)" - $(Q) $(WRAP_STUB) $^ +all: $(STUBS_ELF:.elf=.json) + +embed: $(patsubst $(BUILD_DIR)/%.elf,$(ESPTOOL_STUBS_DIR)/%.json,$(STUBS_ELF)) $(BUILD_DIR): $(Q) mkdir $@ +$(BUILD_DIR)/%.json: $(BUILD_DIR)/%.elf + @echo " WRAP $^ -> $(BUILD_DIR)" + $(Q) $(WRAP_STUB) $^ + +$(ESPTOOL_STUBS_DIR)/%.json: $(BUILD_DIR)/%.elf + @echo " WRAP $^ -> $(ESPTOOL_STUBS_DIR)" + $(Q) $(WRAP_STUB) --embed $^ + CFLAGS = -std=c99 -Wall -Werror -Os \ -mtext-section-literals -mlongcalls -nostdlib -fno-builtin -flto \ -Wl,-static -g -ffunction-sections -Wl,--gc-sections -Iinclude -Lld @@ -157,9 +165,5 @@ $(STUB_ELF_32H2): $(SRCS) $(BUILD_DIR) ld/stub_32h2.ld @echo " CC(32H2) $^ -> $@" $(Q) $(CROSS_ESPRISCV32)gcc $(CFLAGS_ESPRISCV32) -DESP32H2=1 -Tstub_32h2.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -embed: $(STUBS_ELF) - @echo " WRAP $^ -> $(ESPTOOL_STUBS_DIR)" - $(Q) $(WRAP_STUB) --embed $^ - clean: $(Q) rm -rf $(BUILD_DIR)