summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/PC/ipxe/Makefile.kmk
blob: 7f5b4c5a2172fd626fa87502b60ef46046430090 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# $Id: Makefile.kmk $
## @file
# Sub-makefile for iPXE.
#

#
# Copyright (C) 2012-2023 Oracle and/or its affiliates.
#
# This file is part of VirtualBox base platform packages, as
# available from https://www.virtualbox.org.
#
# 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, in version 3 of the
# License.
#
# 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, see <https://www.gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-3.0-only
#

SUB_DEPTH = ../../../../..
include $(KBUILD_PATH)/subheader.kmk

#
# Globals.
#
VBOX_PATH_IPXE_SRC := $(PATH_SUB_CURRENT)


#
# iPxeBiosBin - Library containing the iPXE ROM as a data blob.
#               Will be linked into VBoxDD2.
#
LIBRARIES += iPxeBiosBin
iPxeBiosBin_TEMPLATE = VBoxR3Dll
iPxeBiosBin_DEFS     = IN_VBOXDD2
iPxeBiosBin_SOURCES  = $(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c
iPxeBiosBin_CLEAN    = \
	$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c \

if1of ($(KBUILD_TARGET), darwin os2 solaris win)
 $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c: $(PATH_SUB_CURRENT)/iPxeBiosBin.rom $(VBOX_BIN2C) | $$(dir $$@)
	$(call MSG_TOOL,bin2c,iPxeBiosBin,$<,$@)
	$(QUIET)$(VBOX_BIN2C) -min 32 -max 56 -mask 0x1ff -export NetBiosBinary $< $@

else
 iPxeBiosBin_CLEAN    += \
	$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.rom \
	$(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.bin \
	$(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.zinfo

 $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c: $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.rom $(VBOX_BIN2C)
	$(call MSG_TOOL,bin2c,iPxeBiosBin,$<,$@)
	$(QUIET)$(VBOX_BIN2C) -min 32 -max 56 -export NetBiosBinary $< $@


 $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.rom: \
		$$(iPxeBaseBin_1_TARGET) \
		$$(ipxezbin_1_TARGET) \
		$(VBOX_PATH_IPXE_SRC)/src/util/padimg.pl \
		$(VBOX_PATH_IPXE_SRC)/src/util/fixrom.pl \
		| $$(dir $$@)
	$(call MSG_TOOL,zbin,iPxeBiosBin,$<,$@)
	$(TOOL_$(VBOX_GCC32_TOOL)_OBJCOPY) -O binary -R .zinfo $< $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.bin
	$(TOOL_$(VBOX_GCC32_TOOL)_OBJCOPY) -O binary -j .zinfo $< $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.zinfo
	$(ipxezbin_1_TARGET) \
	    $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.bin \
	    $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.zinfo \
	    > $@
	perl $(VBOX_PATH_IPXE_SRC)/src/util/fixrom.pl $@
	$(RM) -- \
	    $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.bin \
	    $(iPxeBiosBin_0_OUTDIR)/iPxeBaseBin.rom.zinfo

 #
 # iPxeLinker - Linker tool used to link the ROM binary.
 #
 TOOL_iPxeLinker = iPXE LD tool.
 TOOL_iPxeLinker_LINK_PROGRAM_OUTPUT =
 TOOL_iPxeLinker_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
 TOOL_iPxeLinker_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
 TOOL_iPxeLinker_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
 TOOL_iPxeLinker_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
	    $(filter %.def, $(othersrc))
 TOOL_iPxeLinker_LINK_PROGRAM_DEPORD =
 define TOOL_iPxeLinker_LINK_PROGRAM_CMDS
	$(QUIET)ld $(flags) -o $(out) $(objs)\
		$(foreach p,$(libpath), -L$(p))\
		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
 endef

 #
 # iPXE - Template used to build the ROM binary.
 #
 TEMPLATE_iPxe         = iPXE code
 TEMPLATE_iPxe_TOOL    = $(VBOX_GCC32_TOOL)
 TEMPLATE_iPxe_LDTOOL  = iPxeLinker
 TEMPLATE_iPxe_LDFLAGS = \
	-N \
	--no-check-sections \
	--gc-sections \
	-T $(VBOX_PATH_IPXE_SRC)/src/arch/x86/scripts/pcbios.lds \
	-u _rom_start  --defsym check__rom_start=_rom_start \
	-u obj_config  --defsym check_obj_config=obj_config \
	-u _build_id   --defsym _build_id=0xaffeaffe \
	--defsym pci_vendor_id=0x8086 \
	--defsym pci_device_id=0x100E \
	-e _rom_start
ifeq ($(KBUILD_TARGET), freebsd)
 TEMPLATE_iPxe_LDFLAGS += -m elf_i386_fbsd
else
 TEMPLATE_iPxe_LDFLAGS += -m elf_i386
endif
 TEMPLATE_iPxe_LNK_DEPS = $(VBOX_PATH_IPXE_SRC)/src/arch/x86/scripts/pcbios.lds
 TEMPLATE_iPxe_CFLAGS  = \
	-fno-pie \
	-fcommon \
	-ffreestanding \
	-ffunction-sections \
	-march=i386 \
	-fomit-frame-pointer \
	-fstrength-reduce \
	-falign-jumps=1 \
	-falign-loops=1 \
	-Os \
	-falign-functions=1 \
	-mpreferred-stack-boundary=2 \
	-mregparm=3 \
	-mrtd \
	-freg-struct-return \
	-fshort-wchar \
	-Ui386 \
	-Ulinux \
	-include compiler.h \
	-Wall \
	-W \
	-Wformat-nonliteral \
	$(VBOX_GCC_fno-stack-protector) \
	$(VBOX_GCC_fno-dwarf2-cfi-asm) \
	$(VBOX_GCC_Wno-address)
 TEMPLATE_iPxe_ASFLAGS = \
	-ffreestanding \
	-ffunction-sections \
	-march=i386 \
	-fomit-frame-pointer \
	-fstrength-reduce \
	-falign-jumps=1 \
	-falign-loops=1 \
	-falign-functions=1 \
	-mpreferred-stack-boundary=2 \
	-mregparm=3 \
	-mrtd \
	-freg-struct-return \
	-fshort-wchar \
	-Ui386 \
	-Ulinux \
	-include compiler.h \
	-Wall \
	-W \
	-Wformat-nonliteral \
	$(VBOX_GCC_fno-stack-protector) \
	$(VBOX_GCC_fno-dwarf2-cfi-asm) \
	$(VBOX_GCC_Wno-address) \
	-DASSEMBLY \
	-DASM_TCHAR=@ \
	-DASM_TCHAR_OPS=@
 TEMPLATE_iPxe_DEFS = \
	ARCH=i386 \
	PLATFORM=pcbios  \
	VERSION_MAJOR=1  \
	VERSION_MINOR=21 \
	VERSION_PATCH=1  \
	ASM_TCHAR=@ \
	ASM_TCHAR_OPS=@
 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
  TEMPLATE_iPxe_DEFS += \
  	VERSION="1.21.1" \
  	BUILD_NAME="VBox"
 else
  TEMPLATE_iPxe_DEFS += \
  	VERSION=\"1.21.1\" \
  	BUILD_NAME=\"VBox\"
 endif

 #
 # iPxeBaseBin - The iPXE ROM base binary.
 #
 PROGRAMS += iPxeBaseBin

 iPxeBaseBin_TEMPLATE = iPxe

 iPxeBaseBin_INCS = \
	vbox \
	src \
	src/include \
	src/arch/x86/include \
	src/arch/i386/include \
	src/arch/i386/include/pcbios

 iPxeBaseBin_SOURCES = \
	src/arch/x86/core/basemem_packet.c \
	src/arch/x86/core/relocate.c \
	src/arch/x86/interface/pcbios/basemem.c \
	src/arch/x86/interface/pcbios/bios_console.c \
	src/arch/x86/interface/pcbios/hidemem.c \
	src/arch/x86/interface/pcbios/memmap.c \
	src/arch/x86/hci/commands/pxe_cmd.c \
	src/arch/x86/image/bootsector.c \
	src/arch/x86/image/pxe_image.c \
	src/arch/x86/interface/pcbios/bios_nap.c \
	src/arch/x86/interface/pcbios/bios_smbios.c \
	src/arch/x86/interface/pcbios/bios_timer.c \
	src/arch/x86/interface/pcbios/biosint.c \
	src/arch/x86/interface/pcbios/int13.c \
	src/arch/x86/interface/pcbios/memtop_umalloc.c \
	src/arch/x86/interface/pcbios/pcibios.c \
	src/arch/x86/interface/pcbios/rtc_time.c \
	src/arch/x86/interface/pxe/pxe_call.c \
	src/arch/x86/interface/pxe/pxe_file.c \
	src/arch/x86/interface/pxe/pxe_loader.c \
	src/arch/x86/interface/pxe/pxe_preboot.c \
	src/arch/x86/interface/pxe/pxe_tftp.c \
	src/arch/x86/interface/pxe/pxe_udp.c \
	src/arch/x86/interface/pxe/pxe_undi.c \
	src/arch/x86/core/pci_autoboot.c \
	src/arch/x86/core/pit8254.c \
	src/arch/x86/core/x86_string.c \
	src/config/config.c \
	src/config/config_ethernet.c \
	src/config/config_http.c \
	src/config/config_romprefix.c \
	src/config/config_route.c \
	src/config/config_timer.c \
	src/core/acpi.c \
	src/core/ansicol.c \
	src/core/ansiesc.c \
	src/core/asprintf.c \
	src/core/base16.c \
	src/core/base64.c \
	src/core/basename.c \
	src/core/bitmap.c \
	src/core/blockdev.c \
	src/core/blocktrans.c \
	src/core/console.c \
	src/core/ctype.c \
	src/core/cwuri.c \
	src/core/device.c \
	src/core/downloader.c \
	src/core/edd.c \
	src/core/exec.c \
	src/core/errno.c \
	src/core/getkey.c \
	src/core/getopt.c \
	src/core/image.c \
	src/core/init.c \
	src/core/interface.c \
	src/core/iobuf.c \
	src/core/job.c \
	src/core/linebuf.c \
	src/core/list.c \
	src/core/main.c \
	src/core/malloc.c \
	src/core/menu.c \
	src/core/monojob.c \
	src/core/nvo.c \
	src/core/null_sanboot.c \
	src/core/open.c \
	src/core/params.c \
	src/core/parseopt.c \
	src/core/pending.c \
	src/core/pool.c \
	src/core/posix_io.c \
	src/core/process.c \
	src/core/quiesce.c \
	src/core/random.c \
	src/core/refcnt.c \
	src/core/resolv.c \
	src/core/sanboot.c \
	src/core/settings.c \
	src/core/string.c \
	src/core/time.c \
	src/core/timer.c \
	src/core/uri.c \
	src/core/uuid.c \
	src/core/version.c \
	src/core/vsprintf.c \
	src/core/xfer.c \
	src/core/xferbuf.c \
	src/crypto/chap.c \
	src/crypto/md5.c \
	src/drivers/bitbash/bitbash.c \
	src/drivers/bitbash/spi_bit.c \
	src/drivers/bus/pci.c \
	src/drivers/bus/pciextra.c \
	src/drivers/bus/pci_settings.c \
	src/drivers/bus/virtio-ring.c \
	src/drivers/bus/virtio-pci.c \
	src/drivers/net/mii.c \
	src/drivers/net/ne.c \
	src/drivers/net/intel.c \
	src/drivers/net/pcnet32.c \
	src/drivers/net/virtio-net.c \
	src/drivers/nvs/nvs.c \
	src/drivers/nvs/spi.c \
	src/drivers/nvs/threewire.c \
	src/hci/commands/autoboot_cmd.c \
	src/hci/commands/config_cmd.c \
	src/hci/commands/ifmgmt_cmd.c \
	src/hci/commands/dhcp_cmd.c \
	src/hci/commands/image_cmd.c \
	src/hci/editstring.c \
	src/hci/keymap/keymap_us.c \
	src/hci/mucurses/ansi_screen.c \
	src/hci/mucurses/clear.c \
	src/hci/mucurses/colour.c \
	src/hci/mucurses/mucurses.c \
	src/hci/mucurses/print.c \
	src/hci/mucurses/widgets/editbox.c \
	src/hci/mucurses/winattrs.c \
	src/hci/mucurses/wininit.c \
	src/hci/readline.c \
	src/hci/jumpscroll.c \
	src/hci/shell.c \
	src/hci/strerror.c \
	src/hci/tui/login_ui.c \
	src/hci/tui/menu_ui.c \
	src/hci/tui/settings_ui.c \
	src/image/segment.c \
	src/interface/smbios/smbios.c \
	src/interface/smbios/smbios_settings.c \
	src/libgcc/implicit.c \
	src/net/arp.c \
	src/net/dhcpopts.c \
	src/net/dhcppkt.c \
	src/net/eth_slow.c \
	src/net/ethernet.c \
	src/net/fakedhcp.c \
	src/net/fragment.c \
	src/net/icmp.c \
	src/net/icmpv4.c \
	src/net/icmpv6.c \
	src/net/iobpad.c \
	src/net/ipv4.c \
	src/net/neighbour.c \
	src/net/netdev_settings.c \
	src/net/netdevice.c \
	src/net/nullnet.c \
	src/net/rarp.c \
	src/net/retry.c \
	src/net/socket.c \
	src/net/tcp.c \
	src/net/tcpip.c \
	src/net/udp.c \
	src/net/udp/dhcp.c \
	src/net/udp/dns.c \
	src/net/udp/tftp.c \
	src/usr/autoboot.c \
	src/usr/dhcpmgmt.c \
	src/usr/ifmgmt.c \
	src/usr/imgmgmt.c \
	src/usr/prompt.c \
	src/usr/pxemenu.c \
	src/usr/route.c \
	src/usr/route_ipv4.c \
	src/arch/x86/core/x86_tcpip.c \
	src/arch/x86/core/patch_cf.S \
	src/arch/i386/core/setjmp.S \
	src/arch/x86/core/stack.S \
	src/arch/x86/core/stack16.S \
	src/arch/x86/interface/pcbios/e820mangler.S \
	src/arch/x86/interface/pxe/pxe_entry.S \
	src/arch/x86/prefix/unlzma16.S \
	src/arch/x86/prefix/romprefix.S \
	src/arch/x86/prefix/undiloader.S \
	src/arch/x86/transitions/liba20.S \
	src/arch/x86/transitions/librm.S \
	src/arch/x86/transitions/librm_mgmt.c \
	src/arch/i386/core/gdbidt.S \
	src/arch/x86/prefix/libprefix.S

 define def_iPxeBaseBinDefs
  $(file)_DEFS += OBJECT=$(subst -,_,$(basename $(notdir $(file))))
 endef

 $(foreach file,$(iPxeBaseBin_SOURCES),$(eval $(call def_iPxeBaseBinDefs)))

 #
 # ipxezbin - Compressor?
 #
 BLDPROGS += ipxezbin
 ipxezbin_TEMPLATE = VBoxBldProg
 ipxezbin_CFLAGS   = -Wno-format -Wno-unused-function -Wno-pointer-arith
 ipxezbin_SOURCES  = src/util/zbin.c
 ifdef VBOX_WITH_LIBLZMA
  ipxezbin_INCS     = $(SDK_VBoxLibLzma_INCS) # Can't use the proper SDK here as link order matters and liblzma depends on our runtime.
  ipxezbin_LIBS    = \
  	$(SDK_VBoxLibLzma_LIBS) \
  	$(PATH_STAGE_LIB)/RuntimeBldProg$(VBOX_HOSTSUFF_LIB)
 else
  ipxezbin_LIBS = lzma # Assume it is installed on the system ready for linking
 endif

endif


include $(FILE_KBUILD_SUB_FOOTER)