Browse Source

[build] Include version number within only a single object file

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
4867085c0c

+ 0
- 5
src/Makefile View File

@@ -169,11 +169,6 @@ GITVERSION := $(shell git describe --always --abbrev=1 --match "" 2>/dev/null)
169 169
 ifneq ($(GITVERSION),)
170 170
 VERSION		+= ($(GITVERSION))
171 171
 endif
172
-CFLAGS		+= -DVERSION_MAJOR=$(VERSION_MAJOR) \
173
-		   -DVERSION_MINOR=$(VERSION_MINOR) \
174
-		   -DVERSION_PATCH=$(VERSION_PATCH) \
175
-		   -DVERSION="\"$(VERSION)\""
176
-IDENT		= '$(@F) $(VERSION) (GPL) ipxe.org'
177 172
 version :
178 173
 	@$(ECHO) "$(VERSION)"
179 174
 

+ 7
- 0
src/Makefile.housekeeping View File

@@ -653,6 +653,13 @@ $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
653 653
 
654 654
 $(BIN)/clientcert.o : override CC := env CCACHE_DISABLE=1 $(CC)
655 655
 
656
+# Version number
657
+#
658
+CFLAGS_version += -DVERSION_MAJOR=$(VERSION_MAJOR) \
659
+		  -DVERSION_MINOR=$(VERSION_MINOR) \
660
+		  -DVERSION_PATCH=$(VERSION_PATCH) \
661
+		  -DVERSION="\"$(VERSION)\""
662
+
656 663
 # We automatically generate rules for any file mentioned in AUTO_SRCS
657 664
 # using the following set of templates.  It would be cleaner to use
658 665
 # $(eval ...), but this function exists only in GNU make >= 3.80.

+ 4
- 1
src/arch/i386/image/multiboot.c View File

@@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
39 39
 #include <ipxe/init.h>
40 40
 #include <ipxe/features.h>
41 41
 #include <ipxe/uri.h>
42
+#include <ipxe/version.h>
42 43
 
43 44
 FEATURE ( FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1 );
44 45
 
@@ -247,7 +248,7 @@ static struct multiboot_info __bss16 ( mbinfo );
247 248
 #define mbinfo __use_data16 ( mbinfo )
248 249
 
249 250
 /** The multiboot bootloader name */
250
-static char __data16_array ( mb_bootloader_name, [] ) = "iPXE " VERSION;
251
+static char __bss16_array ( mb_bootloader_name, [32] );
251 252
 #define mb_bootloader_name __use_data16 ( mb_bootloader_name )
252 253
 
253 254
 /** The multiboot memory map */
@@ -420,6 +421,8 @@ static int multiboot_exec ( struct image *image ) {
420 421
 	mbinfo.cmdline = multiboot_add_cmdline ( image );
421 422
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );
422 423
 	mbinfo.mmap_addr = virt_to_phys ( mbmemmap );
424
+	snprintf ( mb_bootloader_name, sizeof ( mb_bootloader_name ),
425
+		   "iPXE %s", product_version );
423 426
 	mbinfo.boot_loader_name = virt_to_phys ( mb_bootloader_name );
424 427
 	if ( ( rc = multiboot_add_modules ( image, max, &mbinfo, mbmodules,
425 428
 					    ( sizeof ( mbmodules ) /

+ 5
- 6
src/arch/i386/image/nbi.c View File

@@ -10,6 +10,7 @@
10 10
 #include <ipxe/fakedhcp.h>
11 11
 #include <ipxe/image.h>
12 12
 #include <ipxe/features.h>
13
+#include <ipxe/version.h>
13 14
 
14 15
 /** @file
15 16
  *
@@ -94,12 +95,6 @@ struct ebinfo {
94 95
 	uint16_t flags;         /* Bit flags */
95 96
 };
96 97
 
97
-/** Info passed to NBI image */
98
-static struct ebinfo loaderinfo = {
99
-	VERSION_MAJOR, VERSION_MINOR,
100
-	0
101
-};
102
-
103 98
 /**
104 99
  * Prepare a segment for an NBI image
105 100
  *
@@ -281,6 +276,10 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
281 276
  * @ret rc		Return status code, if image returns
282 277
  */
283 278
 static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
279
+	struct ebinfo loaderinfo = {
280
+		product_major_version, product_minor_version,
281
+		0
282
+	};
284 283
 	int discard_D, discard_S, discard_b;
285 284
 	int rc;
286 285
 

+ 6
- 1
src/arch/i386/interface/syslinux/comboot_call.c View File

@@ -39,12 +39,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
39 39
 #include <ipxe/serial.h>
40 40
 #include <ipxe/init.h>
41 41
 #include <ipxe/image.h>
42
+#include <ipxe/version.h>
42 43
 #include <usr/imgmgmt.h>
43 44
 #include "config/console.h"
44 45
 #include "config/serial.h"
45 46
 
46 47
 /** The "SYSLINUX" version string */
47
-static char __data16_array ( syslinux_version, [] ) = "\r\niPXE " VERSION;
48
+static char __bss16_array ( syslinux_version, [32] );
48 49
 #define syslinux_version __use_data16 ( syslinux_version )
49 50
 
50 51
 /** The "SYSLINUX" copyright string */
@@ -326,6 +327,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
326 327
 		/* SYSLINUX derivative ID */
327 328
 		ix86->regs.dl = BZI_LOADER_TYPE_IPXE;
328 329
 
330
+		/* SYSLINUX version */
331
+		snprintf ( syslinux_version, sizeof ( syslinux_version ),
332
+			   "\r\niPXE %s", product_version );
333
+
329 334
 		/* SYSLINUX version and copyright strings */
330 335
 		ix86->segs.es = rm_ds;
331 336
 		ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );

+ 3
- 2
src/core/main.c View File

@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
21 21
 #include <ipxe/shell.h>
22 22
 #include <ipxe/image.h>
23 23
 #include <ipxe/keys.h>
24
+#include <ipxe/version.h>
24 25
 #include <usr/prompt.h>
25 26
 #include <usr/autoboot.h>
26 27
 #include <config/general.h>
@@ -82,10 +83,10 @@ __asmcall int main ( void ) {
82 83
 	 * do so.
83 84
 	 *
84 85
 	 */
85
-	printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE " VERSION
86
+	printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE %s"
86 87
 		 NORMAL " -- Open Source Network Boot Firmware -- "
87 88
 		 CYAN "http://ipxe.org" NORMAL "\n"
88
-		 "Features:" );
89
+		 "Features:", product_version );
89 90
 	for_each_table_entry ( feature, FEATURES )
90 91
 		printf ( " %s", feature->name );
91 92
 	printf ( "\n" );

+ 41
- 0
src/core/version.c View File

@@ -0,0 +1,41 @@
1
+/*
2
+ * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ */
19
+
20
+FILE_LICENCE ( GPL2_OR_LATER );
21
+
22
+/** @file
23
+ *
24
+ * Version number
25
+ *
26
+ */
27
+
28
+#include <ipxe/features.h>
29
+#include <ipxe/version.h>
30
+
31
+/** Version number feature */
32
+FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
33
+
34
+/** Product major version */
35
+const int product_major_version = VERSION_MAJOR;
36
+
37
+/** Product minor version */
38
+const int product_minor_version = VERSION_MINOR;
39
+
40
+/** Product version string */
41
+const char *product_version = VERSION;

+ 16
- 0
src/include/ipxe/version.h View File

@@ -0,0 +1,16 @@
1
+#ifndef _IPXE_VERSION_H
2
+#define _IPXE_VERSION_H
3
+
4
+/** @file
5
+ *
6
+ * Version number
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER );
11
+
12
+extern const int product_major_version;
13
+extern const int product_minor_version;
14
+extern const char *product_version;
15
+
16
+#endif /* _IPXE_VERSION_H */

+ 2
- 1
src/interface/efi/efi_snp_hii.c View File

@@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
54 54
 #include <ipxe/nvo.h>
55 55
 #include <ipxe/device.h>
56 56
 #include <ipxe/netdevice.h>
57
+#include <ipxe/version.h>
57 58
 #include <ipxe/efi/efi.h>
58 59
 #include <ipxe/efi/efi_hii.h>
59 60
 #include <ipxe/efi/efi_snp.h>
@@ -196,7 +197,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
196 197
 	efi_ifr_text_op ( &ifr,
197 198
 			  efi_ifr_string ( &ifr, "Version" ),
198 199
 			  efi_ifr_string ( &ifr, "Firmware version" ),
199
-			  efi_ifr_string ( &ifr, VERSION ) );
200
+			  efi_ifr_string ( &ifr, "%s", product_version ) );
200 201
 	efi_ifr_text_op ( &ifr,
201 202
 			  efi_ifr_string ( &ifr, "Driver" ),
202 203
 			  efi_ifr_string ( &ifr, "Firmware driver" ),

+ 3
- 2
src/net/tcp/httpcore.c View File

@@ -48,6 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
48 48
 #include <ipxe/md5.h>
49 49
 #include <ipxe/blockdev.h>
50 50
 #include <ipxe/acpi.h>
51
+#include <ipxe/version.h>
51 52
 #include <ipxe/http.h>
52 53
 
53 54
 /* Disambiguate the various error causes */
@@ -1141,11 +1142,11 @@ static void http_step ( struct http_request *http ) {
1141 1142
 	/* Send request */
1142 1143
 	if ( ( rc = xfer_printf ( &http->socket,
1143 1144
 				  "%s %s HTTP/1.1\r\n"
1144
-				  "User-Agent: iPXE/" VERSION "\r\n"
1145
+				  "User-Agent: iPXE/%s\r\n"
1145 1146
 				  "Host: %s%s%s\r\n"
1146 1147
 				  "%s%s%s"
1147 1148
 				  "\r\n",
1148
-				  method, uri, http->uri->host,
1149
+				  method, uri, product_version, http->uri->host,
1149 1150
 				  ( http->uri->port ?
1150 1151
 				    ":" : "" ),
1151 1152
 				  ( http->uri->port ?

+ 0
- 3
src/net/udp/dhcp.c View File

@@ -91,9 +91,6 @@ static uint8_t dhcp_request_options_data[] = {
91 91
 	DHCP_END
92 92
 };
93 93
 
94
-/** Version number feature */
95
-FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
96
-
97 94
 /** DHCP server address setting */
98 95
 struct setting dhcp_server_setting __setting ( SETTING_MISC ) = {
99 96
 	.name = "dhcp-server",

Loading…
Cancel
Save