VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/Makefile.kmk@ 94264

Last change on this file since 94264 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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