Skip to content

Commit

Permalink
Merge pull request #5 from mikeller/add_version_to_name
Browse files Browse the repository at this point in the history
Add the bootloader version to the name of the hex files.
  • Loading branch information
AlkaMotors authored Feb 22, 2021
2 parents 6454fd5 + 69a287b commit dbd20a2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ ARM_SDK_PREFIX ?= arm-none-eabi-
TARGETS := PA2 PB4
TARGET_PREFIX := BOOTLOADER_

.PHONY : clean all
VERSION := $(shell grep "#define BOOTLOADER_VERSION" Core/Src/main.c | awk '{print $$3}' )

.PHONY : clean all version
all : $(TARGETS)
clean :
rm -f Src/*.o
version :
@echo $(VERSION)

$(TARGETS) :
$(MAKE) TARGET=$@ $(TARGET_PREFIX)$@.bin

$(TARGETS:%=$(TARGET_PREFIX)%.bin) : clean $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(TARGET_PREFIX)$(TARGET).elf $(OBJ)
$(CP) -O binary $(TARGET_PREFIX)$(TARGET).elf $(TARGET_PREFIX)$(TARGET).bin
$(CP) $(TARGET_PREFIX)$(TARGET).elf -O ihex $(TARGET_PREFIX)$(TARGET).hex
$(CC) $(CFLAGS) $(LDFLAGS) -o $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf $(OBJ)
$(CP) -O binary $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf $(TARGET_PREFIX)$(TARGET)_$(VERSION).bin
$(CP) $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf -O ihex $(TARGET_PREFIX)$(TARGET)_$(VERSION).hex

0 comments on commit dbd20a2

Please sign in to comment.