]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Include version number within only a single object file
authorMichael Brown <mcb30@ipxe.org>
Fri, 2 Nov 2012 14:46:39 +0000 (14:46 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 2 Nov 2012 14:46:39 +0000 (14:46 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/Makefile
src/Makefile.housekeeping
src/arch/i386/image/multiboot.c
src/arch/i386/image/nbi.c
src/arch/i386/interface/syslinux/comboot_call.c
src/core/main.c
src/core/version.c [new file with mode: 0644]
src/include/ipxe/version.h [new file with mode: 0644]
src/interface/efi/efi_snp_hii.c
src/net/tcp/httpcore.c
src/net/udp/dhcp.c

index a061f834bc3754a099ed02da4584fd2fcfd854ac..210c6aa501df6af281656b7e9c0535621b0f94d6 100644 (file)
@@ -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)"
 
index fce49288b1e62b6c722585badc07670658bbb0b3..f607c4d301582a5b16743ee1f4cdf47842dc2d73 100644 (file)
@@ -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.
index 8b8959e18b663a2acfb5b724270fb07d121fb8e6..3d6d2bf341bace0e85b58c8f939d1a7869af7096 100644 (file)
@@ -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 ) /
index c516bb2ecc64b2d6aa230bedb3f81bc132f4098c..d3e523e9252c08ec01b4d5edcef6c911cca875c3 100644 (file)
@@ -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;
 
index 3eee584ce889f740d1a37c1352a26e373ce3c75a..fbf605f3348a80dcd9dd331b39145cb7f7763478 100644 (file)
@@ -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 ) );
index 9ee31d2dbbe0437737eacb9192570e06de4c49e7..7b7755c9436f75d21acbd3499ed27fd1a821cafb 100644 (file)
@@ -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 (file)
index 0000000..1aa22d8
--- /dev/null
@@ -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 (file)
index 0000000..aa894d7
--- /dev/null
@@ -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 */
index 90f94984d9f3a96a49c52fe23311052a9bf993b3..3a1193a3855f4a6c128d8f5bad18afd18baaa9ee 100644 (file)
@@ -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" ),
index 7f178cc8145b82f6aa32ddf7ffecebfdaf5d3065..bccb35f5f4b7bacc84e73fb41e16bac0df459ee0 100644 (file)
@@ -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 ?
index e652503dced3dcf8182f82b63b0b959a7601e24b..e63c3e4224195831f2b5dd98044b676dd794d19e 100644 (file)
@@ -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",