VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/Makefile.kmk@ 99396

Last change on this file since 99396 was 98410, checked in by vboxsync, 21 months ago

Devices/*.kmk: Automatic scm cleanups. bugref:10348

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.2 KB
Line 
1# $Id: Makefile.kmk 98410 2023-02-01 16:20:10Z vboxsync $
2## @file
3# Toplevel sub-makefile for the EFI firmwares.
4#
5# Note! kBuild is only used for the build tools, the rest is handled by the
6# very custom EFI build system.
7#
8
9#
10# Copyright (C) 2013-2023 Oracle and/or its affiliates.
11#
12# This file is part of VirtualBox base platform packages, as
13# available from https://www.virtualbox.org.
14#
15# This program is free software; you can redistribute it and/or
16# modify it under the terms of the GNU General Public License
17# as published by the Free Software Foundation, in version 3 of the
18# License.
19#
20# This program is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program; if not, see <https://www.gnu.org/licenses>.
27#
28# The contents of this file may alternatively be used under the terms
29# of the Common Development and Distribution License Version 1.0
30# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31# in the VirtualBox distribution, in which case the provisions of the
32# CDDL are applicable instead of those of the GPL.
33#
34# You may elect to license modified versions of this file under the
35# terms and conditions of either the GPL or the CDDL or both.
36#
37# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38#
39
40SUB_DEPTH = ../../../../..
41include $(KBUILD_PATH)/subheader.kmk
42
43#
44# Make sure our Config.kmk is included.
45#
46ifndef VBOX_EFI_FIRMWARE_CONFIG_KMK_INCLUDED
47 include $(PATH_SUB_CURRENT)/Config.kmk
48endif
49
50
51#
52# Include sub-makefiles.
53#
54VBOX_EFI_BLDPROGS := $(BLDPROGS)
55include $(PATH_SUB_CURRENT)/BaseTools/Makefile.kmk
56VBOX_EFI_BLDPROGS := $(filter-out $(VBOX_EFI_BLDPROGS),$(BLDPROGS)) VBoxEfiBldPythonWrappers
57
58#
59# Binary wrappers for python scripts.
60#
61VBOX_EFI_PYTHON_WRAPPERS = \
62 AmlToC \
63 BPDG \
64 build \
65 Ecc \
66 GenFds \
67 GenPatchPcdTable \
68 PatchPcdValue \
69 Split \
70 Trim \
71 TargetTool \
72 UPT
73
74INSTALLS += VBoxEfiBldPythonWrappers
75VBoxEfiBldPythonWrappers_TEMPLATE = VBoxEfiBldProg
76if1of ($(KBUILD_HOST), win os2)
77 VBoxEfiBldPythonWrappers_EXEC_SOURCES = \
78 $(foreach PyWrap,$(VBOX_EFI_PYTHON_WRAPPERS),$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap).cmd)
79else
80 VBoxEfiBldPythonWrappers_EXEC_SOURCES = \
81 $(addprefix $(VBoxEfiBldPythonWrappers_0_OUTDIR)/,$(VBOX_EFI_PYTHON_WRAPPERS))
82endif
83VBoxEfiBldPythonWrappers_CLEAN = $(VBoxEfiBldPythonWrappers_EXEC_SOURCES)
84
85if1of ($(KBUILD_HOST), win os2)
86 define VBoxEfiBldPythonWrappersRuleTemplate
87 $$$$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap).cmd: | $$$$(dir $$$$@)
88 $$(APPEND) -tn "$$@" \
89 '@SET PYTHONPATH=$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python' \
90 '@"$$(VBOX_BLD_PYTHON_2X)" "$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/$(PyWrap)/$(PyWrap).py" %*'
91 endef
92else
93 define VBoxEfiBldPythonWrappersRuleTemplate
94 $$$$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap): | $$$$(dir $$$$@)
95 $$(APPEND) -tn "$$@" \
96 '#!$(ASH)' \
97 'export PYTHONPATH="$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python"' \
98 'exec "$$(VBOX_BLD_PYTHON_2X)" "$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/$(PyWrap)/$(PyWrap).py" "$$(DOLLAR)@"'
99 $$(CHMOD) a+x "$$@"
100 endef
101endif
102$(foreach PyWrap,$(VBOX_EFI_PYTHON_WRAPPERS),$(eval $(VBoxEfiBldPythonWrappersRuleTemplate)))
103
104#
105# Rules for building and installing the VBox EFI firmware images.
106#
107INSTALLS += VBoxEfiFirmware
108VBoxEfiFirmware_INST = $(INST_BIN)
109VBoxEfiFirmware_MODE = 0644
110VBoxEfiFirmware_SOURCES = \
111 $(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd=>VBoxEFI32.fd \
112 $(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd=>VBoxEFI64.fd
113VBoxEfiFirmware_BLDDIRS = \
114 $(VBoxEfiFirmware_0_OUTDIR)/x86/ \
115 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/ \
116 $(VBoxEfiFirmware_0_OUTDIR)/amd64/ \
117 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/
118VBoxEfiFirmware_CLEAN = \
119 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt \
120 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/build_rule.txt \
121 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \
122 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt \
123 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/build_rule.txt \
124 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt
125
126# Install the debug info.
127INSTALLS += VBoxEfiFirmwareDbg32
128VBoxEfiFirmwareDbg32_INST = $(INST_VBOXDBG_SYMS)x86/
129VBoxEfiFirmwareDbg32_MODE = 0644
130if1of ($(KBUILD_HOST), win)
131 VBoxEfiFirmwareDbg32_SOURCES = \
132 $(foreach mod,$(VBOX_EFI_MODULES),$(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/IA32/$(mod).pdb)
133else
134 VBoxEfiFirmwareDbg32_SOURCES = \
135 $(foreach mod,$(VBOX_EFI_MODULES_FLAT),$(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/IA32/$(mod).debug)
136endif
137
138INSTALLS += VBoxEfiFirmwareDbg64
139VBoxEfiFirmwareDbg64_INST = $(INST_VBOXDBG_SYMS)amd64/
140VBoxEfiFirmwareDbg64_MODE = 0644
141if1of ($(KBUILD_HOST), win)
142 VBoxEfiFirmwareDbg64_SOURCES = \
143 $(foreach mod,$(VBOX_EFI_MODULES),$(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/X64/$(mod).pdb)
144else
145 VBoxEfiFirmwareDbg64_SOURCES = \
146 $(foreach mod,$(VBOX_EFI_MODULES_FLAT),$(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/X64/$(mod).debug)
147endif
148
149
150#
151# Install a custom clean up rule for dealing with the EFI build system output.
152#
153PASS_CLEAN_trgs += VBoxEfiFirmwareCleanup
154VBoxEfiFirmwareCleanup:
155 $(if $(VBoxEfiFirmware_0_OUTDIR),,exit 1)
156 $(RM) -Rf -- "$(VBoxEfiFirmware_0_OUTDIR)/amd64/" "$(VBoxEfiFirmware_0_OUTDIR)/x86/"
157.PHONY: VBoxEfiFirmwareCleanup
158
159
160#
161# The zipfile.
162#
163include $(KBUILD_PATH)/tools/ZIP.kmk
164ifndef TOOL_ZIP_PACK
165 TOOL_ZIP_PACK = zip
166endif
167VBoxEfiFirmware.zip: $(PATH_STAGE)/VBoxEfiFirmware.zip
168$(PATH_STAGE)/VBoxEfiFirmware.zip:
169 $(REDIRECT) -C "$(PATH_STAGE_BIN)" -- $(TOOL_ZIP_PACK) $(TOOL_ZIP_PACKFLAGS) -9X $@ \
170 VBoxEFI32.fd \
171 VBoxEFI64.fd
172 $(REDIRECT) -C "$(PATH_STAGE)/$(INST_VBOXDBG_SYMS)" -- $(TOOL_ZIP_PACK) $(TOOL_ZIP_PACKFLAGS) -9X $@ \
173 $(foreach mod,$(VBOX_EFI_MODULES_FLAT),amd64/$(mod)$(VBOX_EFI_DBG_SUFF)) \
174 $(foreach mod,$(VBOX_EFI_MODULES_FLAT),x86/$(mod)$(VBOX_EFI_DBG_SUFF))
175
176#
177# Include the footer early so that we can use VBoxEfiFirmware_0_OUTDIR below.
178#
179include $(FILE_KBUILD_SUB_FOOTER)
180
181#
182# Incomplete list of dependencies relative.
183#
184VBOX_EFI_DEPENDENCIES = \
185 $(VBOX_PATH_EFI_FIRMWARE)/../DevEFI.h \
186 $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxDebugAgentLib/VBoxDebugAgentLib.c \
187 $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxDebugAgentLib/VBoxDebugAgentLib.inf \
188 $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/VBoxPkg.dec \
189 \
190 $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkg.dec
191
192#
193# The common build.py invocation part.
194# Note! windir isn't set in cygwin on tinderwin2a. SystemRoot is.
195# Note! MAKEFLAGS must be zapped on Windows so nmake don't get confused.
196#
197if1of ($(KBUILD_HOST), win)
198 VBOX_EFI_REDIRECT_E_EQUAL := $(EQUAL)
199 VBOX_EFI_BUILD_CMD = $(REDIRECT) \
200 -E 'PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH);' \
201 -E 'INCLUDE=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_SEP)$(PATH_TOOL_$(VBOX_VCC_TOOL)_INC)$(INCLUDE);' \
202 -E 'COMSPEC=$(firstword $(windir) $(SystemRoot) C:\windows)\system32\cmd.exe' \
203 -E 'MAKEFLAGS='
204else
205 VBOX_EFI_REDIRECT_E_EQUAL :=
206 VBOX_EFI_BUILD_CMD = $(REDIRECT) \
207 -E "PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH)" \
208 -E "C_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)" \
209 -E "CPLUS_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)"
210endif
211VBOX_EFI_BUILD_CMD += \
212 -E 'PYTHONPATH=$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python' \
213 -E 'PYTHONDONTWRITEBYTECODE=1' \
214 -E 'IASL_BIN=$(VBOX_IASLCMD)' \
215 -E 'NASM_BIN=$(VBOX_NASMCMD)' \
216 -E 'CONF_PATH=$(abspath $(@D)/../../Conf)' \
217 -E 'WORKSPACE=$(VBOX_PATH_EFI_FIRMWARE)' \
218 -E 'EDK_TOOLS_PATH=$(VBOX_PATH_EFI_FIRMWARE)/BaseTools' \
219 -E 'EFI_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \
220 -E 'ECP_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \
221 -E 'EDK_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \
222 -E 'X64_PETOOLS_PREFIX$(VBOX_EFI_REDIRECT_E_EQUAL)' \
223 -E 'ARCH$(VBOX_EFI_REDIRECT_E_EQUAL)' \
224 -E 'IPF_PETOOLS_PREFIX=__no_ipf__' \
225 -E $(if-expr "$(KBUILD_VERBOSE)" != "",'EFI_QUIET=','EFI_QUIET=@') \
226 -C '$(VBOX_PATH_EFI_FIRMWARE)' \
227 -- $(VBOX_BLD_PYTHON_2X) "$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/build/build.py" \
228 -D VBOX=1 \
229 -D VBOX_WITH_OVMF=1 \
230 $(if $(VBOX_WITH_EFI_SECURE_BOOT),-D "SECURE_BOOT_ENABLE=1") \
231 $(if $(VBOX_WITH_EFI_TPM),-D "TPM_ENABLE=1") \
232 $(if $(VBOX_WITH_EFI_TPM),-D "TPM_CONFIG_ENABLE=1") \
233 -D BUILD_NEW_SHELL=1 \
234 -D VBOX_REV=$(VBOX_SVN_REV) \
235 -D "VBOX_OUTPUT_BASE_DIR=$(VBoxEfiFirmware_0_OUTDIR)" \
236 -D "VBOX_PATH_ROOT=$(PATH_ROOT)" \
237 -D "FD_SIZE_4MB=1" \
238 $(if $(VBOX_OSE),-D "VBOX_OSE=1") \
239 $(if-expr "$(KBUILD_VERBOSE)" != "",$(if-expr "$(KBUILD_VERBOSE)" >= 3,-v,),--silent --quiet) \
240 --no-cache \
241 --buildtarget $(VBOX_EFI_BUILD_TARGET) \
242 --tagname $(VBOX_EFI_TOOL_CHAIN)
243
244#
245# Derive the number of parallel jobs (on windows) from KMK_OPTS_JOBS.
246#
247VBOX_EFI_MAX_THREADS := 1
248if defined(KMK_OPTS_JOBS) && "$(KBUILD_HOST)" == "win"
249 VBOX_EFI_MAX_THREADS := $(if-expr $(KMK_OPTS_JOBS) > 0,$(expr $(KMK_OPTS_JOBS) / 2),$(NUMBER_OF_PROCESSORS))
250endif
251
252#
253# Tools configurations.
254#
255ifeq ($(KBUILD_HOST),win)
256 ifndef TOOL_$(VBOX_VCC_TOOL_STEM)X86
257 include $(KBUILD_PATH)/tools/$(VBOX_VCC_TOOL_STEM)X86.kmk
258 endif
259 ifndef TOOL_$(VBOX_VCC_TOOL_STEM)AMD64
260 include $(KBUILD_PATH)/tools/$(VBOX_VCC_TOOL_STEM)AMD64.kmk
261 endif
262 ifndef SDK_WINSDK10
263 include $(KBUILD_PATH)/sdk/WINSDK10.kmk
264 endif
265endif
266$(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \
267$(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt: \
268 $(VBOX_PATH_EFI_FIRMWARE)/vbox-tools_def.txt \
269 $(MAKEFILE) | $$(dir $$@)
270 $(RM) -f -- "$@"
271 $(SED) \
272 -e 's,@VBOX_IASLCMD@,$(VBOX_IASLCMD),' \
273 -e 's,@VBOX_YASMCMD@,$(VBOX_YASMCMD),' \
274 -e 's,@VBOX_NASMCMD@,$(VBOX_NASMCMD),' \
275 -e 's,@KMK@,$(MAKE),' \
276 \
277 -e 's,@VBOX_PATH_PREFIX_GCC32@,$(PATH_TOOL_$(VBOX_GCC_TOOL)),' \
278 -e 's,@VBOX_PATH_PREFIX_GCC64@,$(PATH_TOOL_$(VBOX_GCC_TOOL)),' \
279 \
280 -e 's,@PATH_VS2010@,$(PATH_TOOL_$(VBOX_VCC_TOOL)),' \
281 -e 's,@PATH_VS2010_AMD64_BIN@,$(PATH_TOOL_$(VBOX_VCC_TOOL))/bin/$(subst x86,x86_amd64,$(KBUILD_HOST_ARCH)),' \
282 \
283 -e 's,@PATH_VS2017_BIN_HOST@,$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_BIN),' \
284 -e 's,@PATH_VS2017_AMD64_BIN@,$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_BIN),' \
285 -e 's,@PATH_VS2017_X86_BIN@,$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_BIN),' \
286 \
287 -e 's,@PATH_SDK_WINSDK10_BIN@,$(PATH_SDK_WINSDK10_BIN),' \
288 \
289 --output $@ $<
290
291$(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/build_rule.txt \
292$(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/build_rule.txt: \
293 $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Conf/build_rule.template \
294 $(MAKEFILE) | $$(dir $$@)
295 $(RM) -f -- "$@"
296 $(CP) -f -- "$<" "$@"
297
298
299#
300# VBoxEFI32
301#
302$(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt: $(MAKEFILE) | $$(dir $$@) $(VBOX_EFI_BLDPROGS)
303 $(APPEND) -tn "$@" \
304 "# Automatically generated, do not edit" \
305 "" \
306 "# These variables cannot be overriden by the build.py command line." \
307 "TOOL_CHAIN_CONF = $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt" \
308 "BUILD_RULE_CONF = $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Conf/build_rule.template" \
309 "" \
310 "# These variables are overridden and this is just for show." \
311 "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgIa32.dsc" \
312 "TARGET = $(VBOX_EFI_BUILD_TARGET)" \
313 "TARGET_ARCH = IA32" \
314 "TOOL_CHAIN_TAG = $(VBOX_EFI_TOOL_CHAIN)" \
315 "MAX_CONCURRENT_THREAD_NUMBER = $(VBOX_EFI_MAX_THREADS)"
316
317$(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd \
318+ $(VBoxEfiFirmwareDbg32_SOURCES): \
319 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt \
320 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \
321 $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/build_rule.txt \
322 $$(VBoxEfiResetVector-x86_1_TARGET) \
323 $(VBOX_EFI_DEPENDENCIES) \
324 $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgIa32.dsc \
325 $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgIa32.fdf
326 + $(VBOX_EFI_BUILD_CMD) \
327 --arch IA32 \
328 --platform OvmfPkg/OvmfPkgIa32.dsc
329
330#
331# VBoxEFI64
332#
333$(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt: $(MAKEFILE) | $$(dir $$@) $(VBOX_EFI_BLDPROGS)
334 $(APPEND) -tn "$@" \
335 "# Automatically generated, do not edit" \
336 "" \
337 "# These variables cannot be overriden by the build.py command line." \
338 "TOOL_CHAIN_CONF = $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt" \
339 "BUILD_RULE_CONF = $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Conf/build_rule.template" \
340 "" \
341 "# These variables are overridden and this is just for show." \
342 "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc" \
343 "TARGET = $(VBOX_EFI_BUILD_TARGET)" \
344 "TARGET_ARCH = X64" \
345 "TOOL_CHAIN_TAG = $(VBOX_EFI_TOOL_CHAIN)" \
346 "MAX_CONCURRENT_THREAD_NUMBER = $(VBOX_EFI_MAX_THREADS)"
347
348$(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd \
349+ $(VBoxEfiFirmwareDbg64_SOURCES): \
350 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt \
351 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt \
352 $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/build_rule.txt \
353 $$(VBoxEfiResetVector-amd64_1_TARGET) \
354 $(VBOX_EFI_DEPENDENCIES) \
355 $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgX64.dsc \
356 $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgX64.fdf
357 + $(VBOX_EFI_BUILD_CMD) \
358 --arch X64 \
359 --platform OvmfPkg/OvmfPkgX64.dsc
360
361#
362# Some aliases.
363#
364build-efi-x86: $$(filter %VBoxEFI32.fd,$$(VBoxEfiFirmware_2_STAGE_TARGETS))
365build-efi-amd64: $$(filter %VBoxEFI64.fd,$$(VBoxEfiFirmware_2_STAGE_TARGETS))
366
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette