From 8290a955130e0a6d6112ad8f269d8f617103e070 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 19 Jun 2014 00:35:04 +0100 Subject: [build] Expose build timestamp, build name, and product names Expose the build timestamp (measured in seconds since the Epoch) and the build name (e.g. "rtl8139.rom" or "ipxe.efi"), and provide the product name and product short name in a single centralised location. Signed-off-by: Michael Brown --- src/Makefile.housekeeping | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/Makefile.housekeeping') diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index e40e7132..1b2a9b97 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -697,19 +697,6 @@ $(BIN)/embedded.% : override CC := env CCACHE_DISABLE=1 $(CC) $(BIN)/certstore.% : override CC := env CCACHE_DISABLE=1 $(CC) $(BIN)/privkey.% : override CC := env CCACHE_DISABLE=1 $(CC) -# Version number -# -CFLAGS_version += -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) \ - -DVERSION_PATCH=$(VERSION_PATCH) \ - -DVERSION="\"$(VERSION)\"" -# Make sure the version number gets updated on every git checkout -ifneq ($(GITVERSION),) -ifneq ($(wildcard ../.git/index),) -$(BIN)/version.o : ../.git/index -endif -endif - # Debug message autocolourisation range # DBGCOL_LIST := $(BIN)/.dbgcol.list @@ -1004,13 +991,31 @@ blib : $(BLIB) # BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );' +# Build timestamp +# +BUILD_TIMESTAMP := $(shell date +%s) + +# Build version +# +GIT_INDEX := $(if $(GITVERSION),$(if $(wildcard ../.git/index),../.git/index)) +$(BIN)/%.version.o : core/version.c $(MAKEDEPS) $(GIT_INDEX) + $(QM)$(ECHO) " [VERSION] $@" + $(Q)$(COMPILE_c) -DBUILD_NAME="\"$*\"" \ + -DVERSION_MAJOR=$(VERSION_MAJOR) \ + -DVERSION_MINOR=$(VERSION_MINOR) \ + -DVERSION_PATCH=$(VERSION_PATCH) \ + -DVERSION="\"$(VERSION)\"" \ + -c $< -o $@ + # Build an intermediate object file from the objects required for the # specified target. # -$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) +$(BIN)/%.tmp : $(BIN)/%.version.o $(BLIB) $(MAKEDEPS) $(LDSCRIPT) $(QM)$(ECHO) " [LD] $@" - $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \ - --defsym _build_id=`$(BUILD_ID_CMD)` -Map $(BIN)/$*.tmp.map + $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< $(BLIB) -o $@ \ + --defsym _build_id=`$(BUILD_ID_CMD)` \ + --defsym _build_timestamp=$(BUILD_TIMESTAMP) \ + -Map $(BIN)/$*.tmp.map $(Q)$(OBJDUMP) -ht $@ | $(PERL) $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map # Keep intermediate object file (useful for debugging) -- cgit v1.2.3-55-g7522