diff --git a/src/Makefile b/src/Makefile index a061f834b..210c6aa50 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 fce49288b..f607c4d30 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 8b8959e18..3d6d2bf34 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 #include #include +#include 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 c516bb2ec..d3e523e92 100644 --- a/src/arch/i386/image/nbi.c +++ b/src/arch/i386/image/nbi.c @@ -10,6 +10,7 @@ #include #include #include +#include /** @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 3eee584ce..fbf605f33 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 #include #include +#include #include #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 9ee31d2db..7b7755c94 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include #include #include @@ -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 000000000..1aa22d8ec --- /dev/null +++ b/src/core/version.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 Michael Brown . + * + * 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 +#include + +/** 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 000000000..aa894d7e8 --- /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 90f94984d..3a1193a38 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 #include #include +#include #include #include #include @@ -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 7f178cc81..bccb35f5f 100644 --- a/src/net/tcp/httpcore.c +++ b/src/net/tcp/httpcore.c @@ -48,6 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include /* 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 e652503dc..e63c3e422 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",