From 9255ce37b0f7375b0f16b55a59e4843ab465ac75 Mon Sep 17 00:00:00 2001 From: Jean THOMAS Date: Fri, 2 Dec 2022 19:01:00 +0100 Subject: [PATCH] Rework Makefile for multiple platform support --- Makefile | 10 ++++++++-- Makefile.stm32f1 | 22 ++++------------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 144d7e9..fb034ba 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ MAKE := make -all: +all: stm32f1-builds + +unicore-mx/lib/libucmx_stm32f1.a: + $(MAKE) -C unicore-mx lib/stm32/f1 + +stm32f1-builds: unicore-mx/lib/libucmx_stm32f1.a $(MAKE) -f Makefile.stm32f1 PLATFORM=bluepill LOADER=noloader $(MAKE) -f Makefile.stm32f1 PLATFORM=baite LOADER=noloader $(MAKE) -f Makefile.stm32f1 PLATFORM=olimexstm32h103 LOADER=noloader @@ -18,6 +23,7 @@ all: $(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2white LOADER=loader4k clean: + $(MAKE) -C unicore-mx clean $(MAKE) -f Makefile.stm32f1 clean -.PHONY: all clean +.PHONY: all clean stm32f1-builds diff --git a/Makefile.stm32f1 b/Makefile.stm32f1 index e8ad5cf..498f2ce 100644 --- a/Makefile.stm32f1 +++ b/Makefile.stm32f1 @@ -1,11 +1,9 @@ -SUPPORTED_PLATFORMS = baite bluepill olimexstm32h103 stlinkv2 stlinkv2white PLATFORM ?= bluepill LOADER ?= noloader OBJS := src/dirtyjtag.$(PLATFORM).o src/jtag.$(PLATFORM).o src/usb.$(PLATFORM).o src/delay.$(PLATFORM).o src/cmd.$(PLATFORM).o PREFIX ?= arm-none-eabi -TARGETS := stm32/f1 DEFS += -DSTM32F1 ARCH_FLAGS := -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd LD_SCRIPT := ld/stm32f1-$(LOADER).ld @@ -40,23 +38,11 @@ AS := $(PREFIX)-as SIZE := $(PREFIX)-size OBJCOPY := $(PREFIX)-objcopy -all: dirtyjtag +all: src/dirtyjtag.$(PLATFORM).$(LOADER).elf src/dirtyjtag.$(PLATFORM).$(LOADER).bin -clean: dirtyjtag-clean ucmx-clean - -dirtyjtag: src/dirtyjtag.$(PLATFORM).$(LOADER).elf src/dirtyjtag.$(PLATFORM).$(LOADER).bin - -#dirtyjtag-release: $(patsubst %, src/dirtyjtag.%.bin, $(SUPPORTED_PLATFORMS)) - -dirtyjtag-clean: +clean: $(Q)$(RM) src/*.d src/*.o src/*.map src/*.bin src/*.elf *.bin *.elf -ucmx: - $(Q)$(MAKE) -C $(UCMX_DIR) lib/stm32/f1 - -ucmx-clean: - $(Q)$(MAKE) -C $(UCMX_DIR) clean - %.bin: %.elf $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin @@ -64,7 +50,7 @@ ucmx-clean: $(Q)$(CC) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(*).$(LOADER).elf $(Q)$(SIZE) $(*).$(LOADER).elf -%.$(PLATFORM).o: %.c | ucmx +%.$(PLATFORM).o: %.c $(UCMX_LIB_DIR)/libucmx_stm32f1.a $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $@ -c $< -.PHONY: clean dirtyjtag dirtyjtag-release dirtyjtag-clean ucmx ucmx-clean +.PHONY: all clean \ No newline at end of file