[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 <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2014-06-19 00:35:04 +01:00
parent 13a74e0d27
commit 8290a95513
10 changed files with 101 additions and 37 deletions

View File

@@ -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)