]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Expose build timestamp, build name, and product names
authorMichael Brown <mcb30@ipxe.org>
Wed, 18 Jun 2014 23:35:04 +0000 (00:35 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 24 Jun 2014 14:32:35 +0000 (15:32 +0100)
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>
src/Makefile
src/Makefile.housekeeping
src/core/main.c
src/core/version.c
src/include/ipxe/version.h
src/interface/efi/efi_driver.c
src/interface/efi/efi_snp.c
src/interface/efi/efi_snp_hii.c
src/net/tcp/oncrpc.c
src/usr/autoboot.c

index ea987b84cea40f63af48e2bc4f0a93863380bb2c..22a733524e4f920512c1c29c85bd2b7916e54d28 100644 (file)
@@ -96,6 +96,7 @@ SRCDIRS               += config
 # automatic build system.
 #
 NON_AUTO_SRCS  :=
+NON_AUTO_SRCS  += core/version.c
 NON_AUTO_SRCS  += drivers/net/prism2.c
 
 # INCDIRS lists the include path
index e40e713225556efd0c6aa8a8360d223e21df224d..1b2a9b97391de29ac1afb4ef9ac5c39193b6c2aa 100644 (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)
index c55ca26cbf821f8dd4c38fab3f50cc0a4357648d..db09e4c39eaaffd6fda122bb8967fb88a81b8801 100644 (file)
@@ -17,8 +17,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <stddef.h>
 #include <stdio.h>
 #include <ipxe/init.h>
+#include <ipxe/version.h>
 #include <usr/autoboot.h>
-#include <config/general.h>
 
 /**
  * Main entry point
@@ -31,7 +31,7 @@ __asmcall int main ( void ) {
        initialise();
 
        /* Some devices take an unreasonably long time to initialise */
-       printf ( PRODUCT_SHORT_NAME " initialising devices..." );
+       printf ( "%s initialising devices...", product_short_name );
        startup();
        printf ( "ok\n" );
 
index 1aa22d8ecf0c266699baa00d5782355f0a51272b..1e1e9daca3f29bdc951428b37f672a9181ca701c 100644 (file)
@@ -25,12 +25,35 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+#include <wchar.h>
 #include <ipxe/features.h>
 #include <ipxe/version.h>
+#include <config/general.h>
+
+/**
+ * Create wide-character version of string
+ *
+ * @v string           String
+ * @ret wstring                Wide-character version of string
+ */
+#define WSTRING( string ) _WSTRING ( string )
+#define _WSTRING( string ) L ## string
 
 /** Version number feature */
 FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
 
+/** Build timestamp (generated by linker) */
+extern char _build_timestamp[];
+
+/** Build ID (generated by linker) */
+extern char _build_id[];
+
+/** Build timestamp */
+unsigned long build_timestamp = ( ( unsigned long ) _build_timestamp );
+
+/** Build ID */
+unsigned long build_id = ( ( unsigned long ) _build_id );
+
 /** Product major version */
 const int product_major_version = VERSION_MAJOR;
 
@@ -38,4 +61,29 @@ const int product_major_version = VERSION_MAJOR;
 const int product_minor_version = VERSION_MINOR;
 
 /** Product version string */
-const char *product_version = VERSION;
+const char product_version[] = VERSION;
+
+/** Product name string */
+const char product_name[] = PRODUCT_NAME;
+
+/** Product short name string */
+const char product_short_name[] = PRODUCT_SHORT_NAME;
+
+/** Build name string */
+const char build_name[] = BUILD_NAME;
+
+/** Wide-character product version string */
+const wchar_t product_wversion[] = WSTRING ( VERSION );
+
+/** Wide-character product name string */
+const wchar_t product_wname[] = WSTRING ( PRODUCT_NAME );
+
+/** Wide-character product short name string */
+const wchar_t product_short_wname[] = WSTRING ( PRODUCT_SHORT_NAME );
+
+/** Wide-character build name string */
+const wchar_t build_wname[] = WSTRING ( BUILD_NAME );
+
+/** Copy of build name string within ".prefix" */
+const char build_name_prefix[] __attribute__ (( section ( ".prefix.name" ) ))
+       = BUILD_NAME;
index aa894d7e8df878ed4517374c0ceb758e2f120dbf..ae4275db1fdab2065f798e431ff11c3b128ae5e4 100644 (file)
@@ -9,8 +9,19 @@
 
 FILE_LICENCE ( GPL2_OR_LATER );
 
+#include <wchar.h>
+
+extern unsigned long build_timestamp;
+extern unsigned long build_id;
 extern const int product_major_version;
 extern const int product_minor_version;
-extern const char *product_version;
+extern const char product_version[];
+extern const char product_name[];
+extern const char product_short_name[];
+extern const char build_name[];
+extern const wchar_t product_wversion[];
+extern const wchar_t product_wname[];
+extern const wchar_t product_short_wname[];
+extern const wchar_t build_wname[];
 
 #endif /* _IPXE_VERSION_H */
index 1bc28e7c339400592bbd57d2a605d1ce80b00de7..6d49eca52ad74992e378ac23043e7ae042fd3641 100644 (file)
@@ -23,12 +23,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <ipxe/version.h>
 #include <ipxe/efi/efi.h>
 #include <ipxe/efi/Protocol/DriverBinding.h>
 #include <ipxe/efi/Protocol/ComponentName2.h>
 #include <ipxe/efi/efi_strings.h>
 #include <ipxe/efi/efi_driver.h>
-#include <config/general.h>
 
 /** @file
  *
@@ -207,7 +207,7 @@ int efi_driver_install ( struct efi_driver *efidrv ) {
        efi_snprintf ( efidrv->wname,
                       ( sizeof ( efidrv->wname ) /
                         sizeof ( efidrv->wname[0] ) ),
-                      PRODUCT_SHORT_NAME "%s%s",
+                      "%s%s%s", product_short_name,
                       ( efidrv->name ? " - " : "" ),
                       ( efidrv->name ? efidrv->name : "" ) );
 
index 9c541552bef75ff96ed5cc44e2722501e480923e..e9dd21326802b8636c28015dfe60d46c9d911036 100644 (file)
@@ -28,12 +28,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/iobuf.h>
 #include <ipxe/in.h>
 #include <ipxe/pci.h>
+#include <ipxe/version.h>
 #include <ipxe/efi/efi.h>
 #include <ipxe/efi/efi_pci.h>
 #include <ipxe/efi/efi_driver.h>
 #include <ipxe/efi/efi_strings.h>
 #include <ipxe/efi/efi_snp.h>
-#include <config/general.h>
 #include <usr/autoboot.h>
 
 /** EFI simple network protocol GUID */
@@ -988,12 +988,12 @@ static int efi_snp_probe ( struct net_device *netdev ) {
        efi_snprintf ( snpdev->driver_name,
                       ( sizeof ( snpdev->driver_name ) /
                         sizeof ( snpdev->driver_name[0] ) ),
-                      PRODUCT_SHORT_NAME " %s", netdev->dev->driver_name );
+                      "%s %s", product_short_name, netdev->dev->driver_name );
        efi_snprintf ( snpdev->controller_name,
                       ( sizeof ( snpdev->controller_name ) /
                         sizeof ( snpdev->controller_name[0] ) ),
-                      PRODUCT_SHORT_NAME " %s (%s)",
-                      netdev->name, netdev_addr ( netdev ) );
+                      "%s %s (%s)", product_short_name, netdev->name,
+                      netdev_addr ( netdev ) );
        snpdev->name2.GetDriverName = efi_snp_get_driver_name;
        snpdev->name2.GetControllerName = efi_snp_get_controller_name;
        snpdev->name2.SupportedLanguages = "en";
index 797a6d836f2b6b3a7432b6ac24aec041ad27d694..51634a09234ce7b36f60e2d4b6370989c544c021 100644 (file)
@@ -59,7 +59,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/efi/efi_hii.h>
 #include <ipxe/efi/efi_snp.h>
 #include <ipxe/efi/efi_strings.h>
-#include <config/general.h>
 
 /** EFI configuration access protocol GUID */
 static EFI_GUID efi_hii_config_access_protocol_guid
@@ -162,7 +161,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
        struct device *dev = netdev->dev;
        struct efi_ifr_builder ifr;
        EFI_HII_PACKAGE_LIST_HEADER *package;
-       const char *product_name;
+       const char *name;
        EFI_GUID package_guid;
        EFI_GUID formset_guid;
        EFI_GUID varstore_guid;
@@ -173,7 +172,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
        efi_ifr_init ( &ifr );
 
        /* Determine product name */
-       product_name = ( PRODUCT_NAME[0] ? PRODUCT_NAME : PRODUCT_SHORT_NAME );
+       name = ( product_name[0] ? product_name : product_short_name );
 
        /* Generate GUIDs */
        efi_snp_hii_random_guid ( &package_guid );
@@ -181,13 +180,13 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
        efi_snp_hii_random_guid ( &varstore_guid );
 
        /* Generate title string (used more than once) */
-       title_id = efi_ifr_string ( &ifr, "%s (%s)", product_name,
+       title_id = efi_ifr_string ( &ifr, "%s (%s)", name,
                                    netdev_addr ( netdev ) );
 
        /* Generate opcodes */
        efi_ifr_form_set_op ( &ifr, &formset_guid, title_id,
-                             efi_ifr_string ( &ifr,
-                                              "Configure " PRODUCT_SHORT_NAME),
+                             efi_ifr_string ( &ifr, "Configure %s",
+                                              product_short_name ),
                              &efi_hii_platform_setup_formset_guid,
                              &efi_hii_ibm_ucm_compliant_formset_guid, NULL );
        efi_ifr_guid_class_op ( &ifr, EFI_NETWORK_DEVICE_CLASS );
@@ -197,7 +196,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
        efi_ifr_text_op ( &ifr,
                          efi_ifr_string ( &ifr, "Name" ),
                          efi_ifr_string ( &ifr, "Firmware product name" ),
-                         efi_ifr_string ( &ifr, "%s", product_name ) );
+                         efi_ifr_string ( &ifr, "%s", name ) );
        efi_ifr_text_op ( &ifr,
                          efi_ifr_string ( &ifr, "Version" ),
                          efi_ifr_string ( &ifr, "Firmware version" ),
index cd33ece029359a1b22f1d25315f55667edbb1d41..6469867e910f0f4a5ed7b7f552f4e0590401c89b 100644 (file)
@@ -37,7 +37,7 @@
 #include <ipxe/oncrpc_iob.h>
 #include <ipxe/init.h>
 #include <ipxe/settings.h>
-#include <config/general.h>
+#include <ipxe/version.h>
 
 /** @file
  *
@@ -88,7 +88,7 @@ int oncrpc_init_cred_sys ( struct oncrpc_cred_sys *auth_sys ) {
        fetch_string_setting_copy ( NULL, &hostname_setting,
                                    &auth_sys->hostname );
        if ( ! auth_sys->hostname )
-               if ( ! ( auth_sys->hostname = strdup ( PRODUCT_SHORT_NAME ) ) )
+               if ( ! ( auth_sys->hostname = strdup ( product_short_name ) ) )
                        return -ENOMEM;
 
        auth_sys->uid         = fetch_uintz_setting ( NULL, &uid_setting );
index af3d1f7bb00e34edf6c066ce48889b7fadde09f9..01c55ef1510a64bd813f9a5c41f340b4c78f64c7 100644 (file)
@@ -499,10 +499,10 @@ void ipxe ( struct net_device *netdev ) {
         * do so.
         *
         */
-       printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE %s"
+       printf ( NORMAL "\n\n%s\n" BOLD "iPXE %s"
                 NORMAL " -- Open Source Network Boot Firmware -- "
                 CYAN "http://ipxe.org" NORMAL "\n"
-                "Features:", product_version );
+                "Features:", product_name, product_version );
        for_each_table_entry ( feature, FEATURES )
                printf ( " %s", feature->name );
        printf ( "\n" );