summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile1
-rw-r--r--src/Makefile.housekeeping37
-rw-r--r--src/core/main.c4
-rw-r--r--src/core/version.c50
-rw-r--r--src/include/ipxe/version.h13
-rw-r--r--src/interface/efi/efi_driver.c4
-rw-r--r--src/interface/efi/efi_snp.c8
-rw-r--r--src/interface/efi/efi_snp_hii.c13
-rw-r--r--src/net/tcp/oncrpc.c4
-rw-r--r--src/usr/autoboot.c4
10 files changed, 101 insertions, 37 deletions
diff --git a/src/Makefile b/src/Makefile
index ea987b84..22a73352 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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
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)
diff --git a/src/core/main.c b/src/core/main.c
index c55ca26c..db09e4c3 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -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" );
diff --git a/src/core/version.c b/src/core/version.c
index 1aa22d8e..1e1e9dac 100644
--- a/src/core/version.c
+++ b/src/core/version.c
@@ -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;
diff --git a/src/include/ipxe/version.h b/src/include/ipxe/version.h
index aa894d7e..ae4275db 100644
--- a/src/include/ipxe/version.h
+++ b/src/include/ipxe/version.h
@@ -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 */
diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c
index 1bc28e7c..6d49eca5 100644
--- a/src/interface/efi/efi_driver.c
+++ b/src/interface/efi/efi_driver.c
@@ -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 : "" ) );
diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c
index 9c541552..e9dd2132 100644
--- a/src/interface/efi/efi_snp.c
+++ b/src/interface/efi/efi_snp.c
@@ -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";
diff --git a/src/interface/efi/efi_snp_hii.c b/src/interface/efi/efi_snp_hii.c
index 797a6d83..51634a09 100644
--- a/src/interface/efi/efi_snp_hii.c
+++ b/src/interface/efi/efi_snp_hii.c
@@ -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" ),
diff --git a/src/net/tcp/oncrpc.c b/src/net/tcp/oncrpc.c
index cd33ece0..6469867e 100644
--- a/src/net/tcp/oncrpc.c
+++ b/src/net/tcp/oncrpc.c
@@ -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 );
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index af3d1f7b..01c55ef1 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -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" );