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 12 years ago
parent
commit
4867085c0c

+ 0
- 5
src/Makefile View File

169
 ifneq ($(GITVERSION),)
169
 ifneq ($(GITVERSION),)
170
 VERSION		+= ($(GITVERSION))
170
 VERSION		+= ($(GITVERSION))
171
 endif
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
 version :
172
 version :
178
 	@$(ECHO) "$(VERSION)"
173
 	@$(ECHO) "$(VERSION)"
179
 
174
 

+ 7
- 0
src/Makefile.housekeeping View File

653
 
653
 
654
 $(BIN)/clientcert.o : override CC := env CCACHE_DISABLE=1 $(CC)
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
 # We automatically generate rules for any file mentioned in AUTO_SRCS
663
 # We automatically generate rules for any file mentioned in AUTO_SRCS
657
 # using the following set of templates.  It would be cleaner to use
664
 # using the following set of templates.  It would be cleaner to use
658
 # $(eval ...), but this function exists only in GNU make >= 3.80.
665
 # $(eval ...), but this function exists only in GNU make >= 3.80.

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

39
 #include <ipxe/init.h>
39
 #include <ipxe/init.h>
40
 #include <ipxe/features.h>
40
 #include <ipxe/features.h>
41
 #include <ipxe/uri.h>
41
 #include <ipxe/uri.h>
42
+#include <ipxe/version.h>
42
 
43
 
43
 FEATURE ( FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1 );
44
 FEATURE ( FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1 );
44
 
45
 
247
 #define mbinfo __use_data16 ( mbinfo )
248
 #define mbinfo __use_data16 ( mbinfo )
248
 
249
 
249
 /** The multiboot bootloader name */
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
 #define mb_bootloader_name __use_data16 ( mb_bootloader_name )
252
 #define mb_bootloader_name __use_data16 ( mb_bootloader_name )
252
 
253
 
253
 /** The multiboot memory map */
254
 /** The multiboot memory map */
420
 	mbinfo.cmdline = multiboot_add_cmdline ( image );
421
 	mbinfo.cmdline = multiboot_add_cmdline ( image );
421
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );
422
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );
422
 	mbinfo.mmap_addr = virt_to_phys ( mbmemmap );
423
 	mbinfo.mmap_addr = virt_to_phys ( mbmemmap );
424
+	snprintf ( mb_bootloader_name, sizeof ( mb_bootloader_name ),
425
+		   "iPXE %s", product_version );
423
 	mbinfo.boot_loader_name = virt_to_phys ( mb_bootloader_name );
426
 	mbinfo.boot_loader_name = virt_to_phys ( mb_bootloader_name );
424
 	if ( ( rc = multiboot_add_modules ( image, max, &mbinfo, mbmodules,
427
 	if ( ( rc = multiboot_add_modules ( image, max, &mbinfo, mbmodules,
425
 					    ( sizeof ( mbmodules ) /
428
 					    ( sizeof ( mbmodules ) /

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

10
 #include <ipxe/fakedhcp.h>
10
 #include <ipxe/fakedhcp.h>
11
 #include <ipxe/image.h>
11
 #include <ipxe/image.h>
12
 #include <ipxe/features.h>
12
 #include <ipxe/features.h>
13
+#include <ipxe/version.h>
13
 
14
 
14
 /** @file
15
 /** @file
15
  *
16
  *
94
 	uint16_t flags;         /* Bit flags */
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
  * Prepare a segment for an NBI image
99
  * Prepare a segment for an NBI image
105
  *
100
  *
281
  * @ret rc		Return status code, if image returns
276
  * @ret rc		Return status code, if image returns
282
  */
277
  */
283
 static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
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
 	int discard_D, discard_S, discard_b;
283
 	int discard_D, discard_S, discard_b;
285
 	int rc;
284
 	int rc;
286
 
285
 

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

39
 #include <ipxe/serial.h>
39
 #include <ipxe/serial.h>
40
 #include <ipxe/init.h>
40
 #include <ipxe/init.h>
41
 #include <ipxe/image.h>
41
 #include <ipxe/image.h>
42
+#include <ipxe/version.h>
42
 #include <usr/imgmgmt.h>
43
 #include <usr/imgmgmt.h>
43
 #include "config/console.h"
44
 #include "config/console.h"
44
 #include "config/serial.h"
45
 #include "config/serial.h"
45
 
46
 
46
 /** The "SYSLINUX" version string */
47
 /** The "SYSLINUX" version string */
47
-static char __data16_array ( syslinux_version, [] ) = "\r\niPXE " VERSION;
48
+static char __bss16_array ( syslinux_version, [32] );
48
 #define syslinux_version __use_data16 ( syslinux_version )
49
 #define syslinux_version __use_data16 ( syslinux_version )
49
 
50
 
50
 /** The "SYSLINUX" copyright string */
51
 /** The "SYSLINUX" copyright string */
326
 		/* SYSLINUX derivative ID */
327
 		/* SYSLINUX derivative ID */
327
 		ix86->regs.dl = BZI_LOADER_TYPE_IPXE;
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
 		/* SYSLINUX version and copyright strings */
334
 		/* SYSLINUX version and copyright strings */
330
 		ix86->segs.es = rm_ds;
335
 		ix86->segs.es = rm_ds;
331
 		ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );
336
 		ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );

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

21
 #include <ipxe/shell.h>
21
 #include <ipxe/shell.h>
22
 #include <ipxe/image.h>
22
 #include <ipxe/image.h>
23
 #include <ipxe/keys.h>
23
 #include <ipxe/keys.h>
24
+#include <ipxe/version.h>
24
 #include <usr/prompt.h>
25
 #include <usr/prompt.h>
25
 #include <usr/autoboot.h>
26
 #include <usr/autoboot.h>
26
 #include <config/general.h>
27
 #include <config/general.h>
82
 	 * do so.
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
 		 NORMAL " -- Open Source Network Boot Firmware -- "
87
 		 NORMAL " -- Open Source Network Boot Firmware -- "
87
 		 CYAN "http://ipxe.org" NORMAL "\n"
88
 		 CYAN "http://ipxe.org" NORMAL "\n"
88
-		 "Features:" );
89
+		 "Features:", product_version );
89
 	for_each_table_entry ( feature, FEATURES )
90
 	for_each_table_entry ( feature, FEATURES )
90
 		printf ( " %s", feature->name );
91
 		printf ( " %s", feature->name );
91
 	printf ( "\n" );
92
 	printf ( "\n" );

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

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

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
 #include <ipxe/nvo.h>
54
 #include <ipxe/nvo.h>
55
 #include <ipxe/device.h>
55
 #include <ipxe/device.h>
56
 #include <ipxe/netdevice.h>
56
 #include <ipxe/netdevice.h>
57
+#include <ipxe/version.h>
57
 #include <ipxe/efi/efi.h>
58
 #include <ipxe/efi/efi.h>
58
 #include <ipxe/efi/efi_hii.h>
59
 #include <ipxe/efi/efi_hii.h>
59
 #include <ipxe/efi/efi_snp.h>
60
 #include <ipxe/efi/efi_snp.h>
196
 	efi_ifr_text_op ( &ifr,
197
 	efi_ifr_text_op ( &ifr,
197
 			  efi_ifr_string ( &ifr, "Version" ),
198
 			  efi_ifr_string ( &ifr, "Version" ),
198
 			  efi_ifr_string ( &ifr, "Firmware version" ),
199
 			  efi_ifr_string ( &ifr, "Firmware version" ),
199
-			  efi_ifr_string ( &ifr, VERSION ) );
200
+			  efi_ifr_string ( &ifr, "%s", product_version ) );
200
 	efi_ifr_text_op ( &ifr,
201
 	efi_ifr_text_op ( &ifr,
201
 			  efi_ifr_string ( &ifr, "Driver" ),
202
 			  efi_ifr_string ( &ifr, "Driver" ),
202
 			  efi_ifr_string ( &ifr, "Firmware driver" ),
203
 			  efi_ifr_string ( &ifr, "Firmware driver" ),

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

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

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

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

Loading…
Cancel
Save