VirtualBox

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

Last change on this file since 87064 was 85790, checked in by vboxsync, 4 years ago

Devices/EFI/Firmware/Makefile.kmk: TPM2_ENABLE -> TPM_ENABLE and TPM2_CONFIG_ENABLE -> TPM_CONFIG_ENABLE, bugref:4643

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