Skip to content

Commit

Permalink
Rework Makefile for multiple platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanthom committed Dec 13, 2022
1 parent f8aaf95 commit 9255ce3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
22 changes: 4 additions & 18 deletions Makefile.stm32f1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -40,31 +38,19 @@ 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

%.$(LOADER).elf %.$(LOADER).map: $(OBJS) $(LD_SCRIPT)
$(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

0 comments on commit 9255ce3

Please sign in to comment.