summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2012-11-02 15:46:39 +0100
committerMichael Brown2012-11-02 15:46:39 +0100
commit4867085c0cd334004e8d67dff7bd53996f23ade6 (patch)
tree31f92c7844273c3b495c105a4c24d98dc54917ac /src
parent[build] Inhibit .eh_frame on newer gcc versions (diff)
downloadipxe-4867085c0cd334004e8d67dff7bd53996f23ade6.tar.gz
ipxe-4867085c0cd334004e8d67dff7bd53996f23ade6.tar.xz
ipxe-4867085c0cd334004e8d67dff7bd53996f23ade6.zip
[build] Include version number within only a single object file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile5
-rw-r--r--src/Makefile.housekeeping7
-rw-r--r--src/arch/i386/image/multiboot.c5
-rw-r--r--src/arch/i386/image/nbi.c11
-rw-r--r--src/arch/i386/interface/syslinux/comboot_call.c7
-rw-r--r--src/core/main.c5
-rw-r--r--src/core/version.c41
-rw-r--r--src/include/ipxe/version.h16
-rw-r--r--src/interface/efi/efi_snp_hii.c3
-rw-r--r--src/net/tcp/httpcore.c5
-rw-r--r--src/net/udp/dhcp.c3
11 files changed, 87 insertions, 21 deletions
diff --git a/src/Makefile b/src/Makefile
index a061f834..210c6aa5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -169,11 +169,6 @@ GITVERSION := $(shell git describe --always --abbrev=1 --match "" 2>/dev/null)
ifneq ($(GITVERSION),)
VERSION += ($(GITVERSION))
endif
-CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
- -DVERSION_MINOR=$(VERSION_MINOR) \
- -DVERSION_PATCH=$(VERSION_PATCH) \
- -DVERSION="\"$(VERSION)\""
-IDENT = '$(@F) $(VERSION) (GPL) ipxe.org'
version :
@$(ECHO) "$(VERSION)"
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index fce49288..f607c4d3 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -653,6 +653,13 @@ $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
$(BIN)/clientcert.o : 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)\""
+
# We automatically generate rules for any file mentioned in AUTO_SRCS
# using the following set of templates. It would be cleaner to use
# $(eval ...), but this function exists only in GNU make >= 3.80.
diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c
index 8b8959e1..3d6d2bf3 100644
--- a/src/arch/i386/image/multiboot.c
+++ b/src/arch/i386/image/multiboot.c
@@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/init.h>
#include <ipxe/features.h>
#include <ipxe/uri.h>
+#include <ipxe/version.h>
FEATURE ( FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1 );
@@ -247,7 +248,7 @@ static struct multiboot_info __bss16 ( mbinfo );
#define mbinfo __use_data16 ( mbinfo )
/** The multiboot bootloader name */
-static char __data16_array ( mb_bootloader_name, [] ) = "iPXE " VERSION;
+static char __bss16_array ( mb_bootloader_name, [32] );
#define mb_bootloader_name __use_data16 ( mb_bootloader_name )
/** The multiboot memory map */
@@ -420,6 +421,8 @@ static int multiboot_exec ( struct image *image ) {
mbinfo.cmdline = multiboot_add_cmdline ( image );
mbinfo.mods_addr = virt_to_phys ( mbmodules );
mbinfo.mmap_addr = virt_to_phys ( mbmemmap );
+ snprintf ( mb_bootloader_name, sizeof ( mb_bootloader_name ),
+ "iPXE %s", product_version );
mbinfo.boot_loader_name = virt_to_phys ( mb_bootloader_name );
if ( ( rc = multiboot_add_modules ( image, max, &mbinfo, mbmodules,
( sizeof ( mbmodules ) /
diff --git a/src/arch/i386/image/nbi.c b/src/arch/i386/image/nbi.c
index c516bb2e..d3e523e9 100644
--- a/src/arch/i386/image/nbi.c
+++ b/src/arch/i386/image/nbi.c
@@ -10,6 +10,7 @@
#include <ipxe/fakedhcp.h>
#include <ipxe/image.h>
#include <ipxe/features.h>
+#include <ipxe/version.h>
/** @file
*
@@ -94,12 +95,6 @@ struct ebinfo {
uint16_t flags; /* Bit flags */
};
-/** Info passed to NBI image */
-static struct ebinfo loaderinfo = {
- VERSION_MAJOR, VERSION_MINOR,
- 0
-};
-
/**
* Prepare a segment for an NBI image
*
@@ -281,6 +276,10 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
* @ret rc Return status code, if image returns
*/
static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
+ struct ebinfo loaderinfo = {
+ product_major_version, product_minor_version,
+ 0
+ };
int discard_D, discard_S, discard_b;
int rc;
diff --git a/src/arch/i386/interface/syslinux/comboot_call.c b/src/arch/i386/interface/syslinux/comboot_call.c
index 3eee584c..fbf605f3 100644
--- a/src/arch/i386/interface/syslinux/comboot_call.c
+++ b/src/arch/i386/interface/syslinux/comboot_call.c
@@ -39,12 +39,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/serial.h>
#include <ipxe/init.h>
#include <ipxe/image.h>
+#include <ipxe/version.h>
#include <usr/imgmgmt.h>
#include "config/console.h"
#include "config/serial.h"
/** The "SYSLINUX" version string */
-static char __data16_array ( syslinux_version, [] ) = "\r\niPXE " VERSION;
+static char __bss16_array ( syslinux_version, [32] );
#define syslinux_version __use_data16 ( syslinux_version )
/** The "SYSLINUX" copyright string */
@@ -326,6 +327,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
/* SYSLINUX derivative ID */
ix86->regs.dl = BZI_LOADER_TYPE_IPXE;
+ /* SYSLINUX version */
+ snprintf ( syslinux_version, sizeof ( syslinux_version ),
+ "\r\niPXE %s", product_version );
+
/* SYSLINUX version and copyright strings */
ix86->segs.es = rm_ds;
ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );
diff --git a/src/core/main.c b/src/core/main.c
index 9ee31d2d..7b7755c9 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/shell.h>
#include <ipxe/image.h>
#include <ipxe/keys.h>
+#include <ipxe/version.h>
#include <usr/prompt.h>
#include <usr/autoboot.h>
#include <config/general.h>
@@ -82,10 +83,10 @@ __asmcall int main ( void ) {
* do so.
*
*/
- printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE " VERSION
+ printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE %s"
NORMAL " -- Open Source Network Boot Firmware -- "
CYAN "http://ipxe.org" NORMAL "\n"
- "Features:" );
+ "Features:", product_version );
for_each_table_entry ( feature, FEATURES )
printf ( " %s", feature->name );
printf ( "\n" );
diff --git a/src/core/version.c b/src/core/version.c
new file mode 100644
index 00000000..1aa22d8e
--- /dev/null
+++ b/src/core/version.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Version number
+ *
+ */
+
+#include <ipxe/features.h>
+#include <ipxe/version.h>
+
+/** Version number feature */
+FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
+
+/** Product major version */
+const int product_major_version = VERSION_MAJOR;
+
+/** Product minor version */
+const int product_minor_version = VERSION_MINOR;
+
+/** Product version string */
+const char *product_version = VERSION;
diff --git a/src/include/ipxe/version.h b/src/include/ipxe/version.h
new file mode 100644
index 00000000..aa894d7e
--- /dev/null
+++ b/src/include/ipxe/version.h
@@ -0,0 +1,16 @@
+#ifndef _IPXE_VERSION_H
+#define _IPXE_VERSION_H
+
+/** @file
+ *
+ * Version number
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+extern const int product_major_version;
+extern const int product_minor_version;
+extern const char *product_version;
+
+#endif /* _IPXE_VERSION_H */
diff --git a/src/interface/efi/efi_snp_hii.c b/src/interface/efi/efi_snp_hii.c
index 90f94984..3a1193a3 100644
--- a/src/interface/efi/efi_snp_hii.c
+++ b/src/interface/efi/efi_snp_hii.c
@@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/nvo.h>
#include <ipxe/device.h>
#include <ipxe/netdevice.h>
+#include <ipxe/version.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_hii.h>
#include <ipxe/efi/efi_snp.h>
@@ -196,7 +197,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Version" ),
efi_ifr_string ( &ifr, "Firmware version" ),
- efi_ifr_string ( &ifr, VERSION ) );
+ efi_ifr_string ( &ifr, "%s", product_version ) );
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Driver" ),
efi_ifr_string ( &ifr, "Firmware driver" ),
diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c
index 7f178cc8..bccb35f5 100644
--- a/src/net/tcp/httpcore.c
+++ b/src/net/tcp/httpcore.c
@@ -48,6 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/md5.h>
#include <ipxe/blockdev.h>
#include <ipxe/acpi.h>
+#include <ipxe/version.h>
#include <ipxe/http.h>
/* Disambiguate the various error causes */
@@ -1141,11 +1142,11 @@ static void http_step ( struct http_request *http ) {
/* Send request */
if ( ( rc = xfer_printf ( &http->socket,
"%s %s HTTP/1.1\r\n"
- "User-Agent: iPXE/" VERSION "\r\n"
+ "User-Agent: iPXE/%s\r\n"
"Host: %s%s%s\r\n"
"%s%s%s"
"\r\n",
- method, uri, http->uri->host,
+ method, uri, product_version, http->uri->host,
( http->uri->port ?
":" : "" ),
( http->uri->port ?
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index e652503d..e63c3e42 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -91,9 +91,6 @@ static uint8_t dhcp_request_options_data[] = {
DHCP_END
};
-/** Version number feature */
-FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
-
/** DHCP server address setting */
struct setting dhcp_server_setting __setting ( SETTING_MISC ) = {
.name = "dhcp-server",