Skip to content

Commit 4867085

Browse files
committedNov 2, 2012
[build] Include version number within only a single object file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent 0932bc5 commit 4867085

File tree

11 files changed

+87
-21
lines changed

11 files changed

+87
-21
lines changed
 

‎src/Makefile

-5
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ GITVERSION := $(shell git describe --always --abbrev=1 --match "" 2>/dev/null)
169169
ifneq ($(GITVERSION),)
170170
VERSION += ($(GITVERSION))
171171
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'
177172
version :
178173
@$(ECHO) "$(VERSION)"
179174

‎src/Makefile.housekeeping

+7
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,13 @@ $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
653653

654654
$(BIN)/clientcert.o : override CC := env CCACHE_DISABLE=1 $(CC)
655655

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+
656663
# We automatically generate rules for any file mentioned in AUTO_SRCS
657664
# using the following set of templates. It would be cleaner to use
658665
# $(eval ...), but this function exists only in GNU make >= 3.80.

‎src/arch/i386/image/multiboot.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
3939
#include <ipxe/init.h>
4040
#include <ipxe/features.h>
4141
#include <ipxe/uri.h>
42+
#include <ipxe/version.h>
4243

4344
FEATURE ( FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1 );
4445

@@ -247,7 +248,7 @@ static struct multiboot_info __bss16 ( mbinfo );
247248
#define mbinfo __use_data16 ( mbinfo )
248249

249250
/** The multiboot bootloader name */
250-
static char __data16_array ( mb_bootloader_name, [] ) = "iPXE " VERSION;
251+
static char __bss16_array ( mb_bootloader_name, [32] );
251252
#define mb_bootloader_name __use_data16 ( mb_bootloader_name )
252253

253254
/** The multiboot memory map */
@@ -420,6 +421,8 @@ static int multiboot_exec ( struct image *image ) {
420421
mbinfo.cmdline = multiboot_add_cmdline ( image );
421422
mbinfo.mods_addr = virt_to_phys ( mbmodules );
422423
mbinfo.mmap_addr = virt_to_phys ( mbmemmap );
424+
snprintf ( mb_bootloader_name, sizeof ( mb_bootloader_name ),
425+
"iPXE %s", product_version );
423426
mbinfo.boot_loader_name = virt_to_phys ( mb_bootloader_name );
424427
if ( ( rc = multiboot_add_modules ( image, max, &mbinfo, mbmodules,
425428
( sizeof ( mbmodules ) /

‎src/arch/i386/image/nbi.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ipxe/fakedhcp.h>
1111
#include <ipxe/image.h>
1212
#include <ipxe/features.h>
13+
#include <ipxe/version.h>
1314

1415
/** @file
1516
*
@@ -94,12 +95,6 @@ struct ebinfo {
9495
uint16_t flags; /* Bit flags */
9596
};
9697

97-
/** Info passed to NBI image */
98-
static struct ebinfo loaderinfo = {
99-
VERSION_MAJOR, VERSION_MINOR,
100-
0
101-
};
102-
10398
/**
10499
* Prepare a segment for an NBI image
105100
*
@@ -281,6 +276,10 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
281276
* @ret rc Return status code, if image returns
282277
*/
283278
static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
279+
struct ebinfo loaderinfo = {
280+
product_major_version, product_minor_version,
281+
0
282+
};
284283
int discard_D, discard_S, discard_b;
285284
int rc;
286285

‎src/arch/i386/interface/syslinux/comboot_call.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
3939
#include <ipxe/serial.h>
4040
#include <ipxe/init.h>
4141
#include <ipxe/image.h>
42+
#include <ipxe/version.h>
4243
#include <usr/imgmgmt.h>
4344
#include "config/console.h"
4445
#include "config/serial.h"
4546

4647
/** The "SYSLINUX" version string */
47-
static char __data16_array ( syslinux_version, [] ) = "\r\niPXE " VERSION;
48+
static char __bss16_array ( syslinux_version, [32] );
4849
#define syslinux_version __use_data16 ( syslinux_version )
4950

5051
/** The "SYSLINUX" copyright string */
@@ -326,6 +327,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
326327
/* SYSLINUX derivative ID */
327328
ix86->regs.dl = BZI_LOADER_TYPE_IPXE;
328329

330+
/* SYSLINUX version */
331+
snprintf ( syslinux_version, sizeof ( syslinux_version ),
332+
"\r\niPXE %s", product_version );
333+
329334
/* SYSLINUX version and copyright strings */
330335
ix86->segs.es = rm_ds;
331336
ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );

‎src/core/main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
2121
#include <ipxe/shell.h>
2222
#include <ipxe/image.h>
2323
#include <ipxe/keys.h>
24+
#include <ipxe/version.h>
2425
#include <usr/prompt.h>
2526
#include <usr/autoboot.h>
2627
#include <config/general.h>
@@ -82,10 +83,10 @@ __asmcall int main ( void ) {
8283
* do so.
8384
*
8485
*/
85-
printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE " VERSION
86+
printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "iPXE %s"
8687
NORMAL " -- Open Source Network Boot Firmware -- "
8788
CYAN "http://ipxe.org" NORMAL "\n"
88-
"Features:" );
89+
"Features:", product_version );
8990
for_each_table_entry ( feature, FEATURES )
9091
printf ( " %s", feature->name );
9192
printf ( "\n" );

‎src/core/version.c

+41
Original file line numberDiff line numberDiff line change
@@ -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;

‎src/include/ipxe/version.h

+16
Original file line numberDiff line numberDiff line change
@@ -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 */

‎src/interface/efi/efi_snp_hii.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
5454
#include <ipxe/nvo.h>
5555
#include <ipxe/device.h>
5656
#include <ipxe/netdevice.h>
57+
#include <ipxe/version.h>
5758
#include <ipxe/efi/efi.h>
5859
#include <ipxe/efi/efi_hii.h>
5960
#include <ipxe/efi/efi_snp.h>
@@ -196,7 +197,7 @@ efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
196197
efi_ifr_text_op ( &ifr,
197198
efi_ifr_string ( &ifr, "Version" ),
198199
efi_ifr_string ( &ifr, "Firmware version" ),
199-
efi_ifr_string ( &ifr, VERSION ) );
200+
efi_ifr_string ( &ifr, "%s", product_version ) );
200201
efi_ifr_text_op ( &ifr,
201202
efi_ifr_string ( &ifr, "Driver" ),
202203
efi_ifr_string ( &ifr, "Firmware driver" ),

‎src/net/tcp/httpcore.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
4848
#include <ipxe/md5.h>
4949
#include <ipxe/blockdev.h>
5050
#include <ipxe/acpi.h>
51+
#include <ipxe/version.h>
5152
#include <ipxe/http.h>
5253

5354
/* Disambiguate the various error causes */
@@ -1141,11 +1142,11 @@ static void http_step ( struct http_request *http ) {
11411142
/* Send request */
11421143
if ( ( rc = xfer_printf ( &http->socket,
11431144
"%s %s HTTP/1.1\r\n"
1144-
"User-Agent: iPXE/" VERSION "\r\n"
1145+
"User-Agent: iPXE/%s\r\n"
11451146
"Host: %s%s%s\r\n"
11461147
"%s%s%s"
11471148
"\r\n",
1148-
method, uri, http->uri->host,
1149+
method, uri, product_version, http->uri->host,
11491150
( http->uri->port ?
11501151
":" : "" ),
11511152
( http->uri->port ?

‎src/net/udp/dhcp.c

-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ static uint8_t dhcp_request_options_data[] = {
9191
DHCP_END
9292
};
9393

94-
/** Version number feature */
95-
FEATURE_VERSION ( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
96-
9794
/** DHCP server address setting */
9895
struct setting dhcp_server_setting __setting ( SETTING_MISC ) = {
9996
.name = "dhcp-server",

0 commit comments

Comments
 (0)