Makefile: Build file names with version suffix

pull/1/head
Harald Welte 2 years ago
parent 3a339ee80b
commit bf11a41c88
  1. 30
      mk/libopencm3.mk

@ -1,9 +1,10 @@
##
## This file is part of the libopencm3 project.
## The original file was part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
## Copyright (C) 2013 Frantisek Burian <BuFran@seznam.cz>
## Copyright (C) 2021 Harald Welte <laforge@gnumonks.org>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
@ -19,6 +20,8 @@
## along with this library. If not, see <http://www.gnu.org/licenses/>.
##
GIT_VERSION=$(shell git describe --tags --dirty)
# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
Q := @
@ -145,6 +148,9 @@ LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
.SECONDEXPANSION:
.SECONDARY:
BINARY_VER = $(BINARY)-$(GIT_VERSION)
all: elf
elf: $(BINARY).elf
@ -152,10 +158,10 @@ bin: $(BINARY).bin
hex: $(BINARY).hex
srec: $(BINARY).srec
list: $(BINARY).list
GENERATED_BINARIES=$(BINARY).elf $(BINARY).bin $(BINARY).hex $(BINARY).srec $(BINARY).list $(BINARY).map
GENERATED_BINARIES=$(BINARY_VER).elf $(BINARY_VER).bin $(BINARY_VER).hex $(BINARY_VER).srec $(BINARY_VER).list $(BINARY_VER).map
images: $(BINARY).images
flash: $(BINARY).flash
images: $(BINARY_VER).images
flash: $(BINARY_VER).flash
# Either verify the user provided LDSCRIPT exists, or generate it.
ifeq ($(strip $(DEVICE)),)
@ -173,6 +179,20 @@ ifeq (,$(wildcard $@))
$(MAKE) -C $(OPENCM3_DIR)
endif
.PHONY: $(BINARY).elf $(BINARY).bin $(BINARY).hex $(BINARY).srec $(BINARY).list $(BINARY).map
$(BINARY).elf: $(BINARY_VER).elf $(BINARY).map
ln -sf $< $@
$(BINARY).bin: $(BINARY_VER).bin
ln -sf $^ $@
$(BINARY).hex: $(BINARY_VER).hex
ln -sf $^ $@
$(BINARY).srec: $(BINARY_VER).srec
ln -sf $^ $@
$(BINARY).list: $(BINARY_VER).list
ln -sf $^ $@
$(BINARY).map: $(BINARY_VER).map
ln -sf $^ $@
# Define a helper macro for debugging make errors online
# you can type "make print-OPENCM3_DIR" and it will show you
# how that ended up being resolved by all of the included
@ -218,6 +238,8 @@ print-%:
clean:
@printf " CLEAN\n"
$(Q)$(RM) $(GENERATED_BINARIES) generated.* $(OBJS) $(OBJS:%.o=%.d)
$(Q)$(RM) $(BINARY)-*.{elf,bin,hex,srec,list,map}
$(Q)$(RM) $(BINARY).{elf,bin,hex,srec,list,map}
stylecheck: $(STYLECHECKFILES:=.stylecheck)
styleclean: $(STYLECHECKFILES:=.styleclean)

Loading…
Cancel
Save