# $Id: Makefile.kmk 58460 2015-10-28 20:34:41Z vboxsync $ ## @file # Toplevel sub-makefile for the EFI firmwares. # # Note! kBuild is only used for the build tools, the rest is handled by the # very custom EFI build system. # # # Copyright (C) 2013-2015 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # The contents of this file may alternatively be used under the terms # of the Common Development and Distribution License Version 1.0 # (CDDL) only, as it comes in the "COPYING.CDDL" file of the # VirtualBox OSE distribution, in which case the provisions of the # CDDL are applicable instead of those of the GPL. # # You may elect to license modified versions of this file under the # terms and conditions of either the GPL or the CDDL or both. # SUB_DEPTH = ../../../../.. include $(KBUILD_PATH)/subheader.kmk # # Make sure our Config.kmk is included. # ifndef VBOX_EFI_FIRMWARE_CONFIG_KMK_INCLUDED include $(PATH_SUB_CURRENT)/Config.kmk endif # # Include sub-makefiles. # VBOX_EFI_BLDPROGS := $(BLDPROGS) include $(PATH_SUB_CURRENT)/BaseTools/Makefile.kmk VBOX_EFI_BLDPROGS := $(filter-out $(VBOX_EFI_BLDPROGS),$(BLDPROGS)) VBoxEfiBldPythonWrappers # # Binary wrappers for python scripts. # VBOX_EFI_PYTHON_WRAPPERS = \ BPDG \ build \ Ecc \ GenFds \ GenPatchPcdTable \ PatchPcdValue \ Trim \ TargetTool \ UPT INSTALLS += VBoxEfiBldPythonWrappers VBoxEfiBldPythonWrappers_TEMPLATE = VBoxEfiBldProg if1of ($(KBUILD_HOST), win os2) VBoxEfiBldPythonWrappers_EXEC_SOURCES = \ $(foreach PyWrap,$(VBOX_EFI_PYTHON_WRAPPERS),$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap).cmd) else VBoxEfiBldPythonWrappers_EXEC_SOURCES = \ $(addprefix $(VBoxEfiBldPythonWrappers_0_OUTDIR)/,$(VBOX_EFI_PYTHON_WRAPPERS)) endif VBoxEfiBldPythonWrappers_CLEAN = $(VBoxEfiBldPythonWrappers_SOURCES) if1of ($(KBUILD_HOST), win os2) define VBoxEfiBldPythonWrappersRuleTemplate $$$$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap).cmd: | $$$$(dir $$$$@) $$(APPEND) -tn "$$@" \ '@SET PYTHONPATH=$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python' \ '@"$$(VBOX_BLD_PYTHON)" "$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/$(PyWrap)/$(PyWrap).py" %*' endef else define VBoxEfiBldPythonWrappersRuleTemplate $$$$(VBoxEfiBldPythonWrappers_0_OUTDIR)/$(PyWrap): | $$$$(dir $$$$@) $$(APPEND) -tn "$$@" \ '#!$(ASH)' \ 'export PYTHONPATH="$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python"' \ 'exec "$$(VBOX_BLD_PYTHON)" "$$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/$(PyWrap)/$(PyWrap).py" "$$(DOLLAR)@"' $$(CHMOD) a+x "$$@" endef endif $(foreach PyWrap,$(VBOX_EFI_PYTHON_WRAPPERS),$(eval $(VBoxEfiBldPythonWrappersRuleTemplate))) # # Rules for building and installing the VBox EFI firmware images. # INSTALLS += VBoxEfiFirmware VBoxEfiFirmware_INST = $(INST_BIN) VBoxEfiFirmware_MODE = 0644 VBoxEfiFirmware_SOURCES = \ $(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd=>VBoxEFI32.fd \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd=>VBoxEFI64.fd VBoxEfiFirmware_BLDDIRS = \ $(VBoxEfiFirmware_0_OUTDIR)/x86/ \ $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/ \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/ \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/ VBoxEfiFirmware_CLEAN = \ $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt \ $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt # Install the debug info. INSTALLS += VBoxEfiFirmwareDbg32 VBoxEfiFirmwareDbg32_INST = $(INST_VBOXDBG_SYMS)x86/ VBoxEfiFirmwareDbg32_MODE = 0644 if1of ($(KBUILD_HOST), win) VBoxEfiFirmwareDbg32_SOURCES = \ $(foreach mod,$(VBOX_EFI_MODULES),$(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/IA32/$(mod).pdb) else VBoxEfiFirmwareDbg32_SOURCES = \ $(foreach mod,$(VBOX_EFI_MODULES_FLAT),$(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/IA32/$(mod).debug) endif INSTALLS += VBoxEfiFirmwareDbg64 VBoxEfiFirmwareDbg64_INST = $(INST_VBOXDBG_SYMS)amd64/ VBoxEfiFirmwareDbg64_MODE = 0644 if1of ($(KBUILD_HOST), win) VBoxEfiFirmwareDbg64_SOURCES = \ $(foreach mod,$(VBOX_EFI_MODULES),$(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/X64/$(mod).pdb) else VBoxEfiFirmwareDbg64_SOURCES = \ $(foreach mod,$(VBOX_EFI_MODULES_FLAT),$(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/X64/$(mod).debug) endif # # Install a custom clean up rule for dealing with the EFI build system output. # PASS_CLEAN_trgs += VBoxEfiFirmwareCleanup VBoxEfiFirmwareCleanup: $(if $(VBoxEfiFirmware_0_OUTDIR),,exit 1) $(RM) -Rf -- "$(VBoxEfiFirmware_0_OUTDIR)/amd64/" "$(VBoxEfiFirmware_0_OUTDIR)/x86/" .PHONY: VBoxEfiFirmwareCleanup # # The reset vector code. # # Dummy Linker. TOOL_VBoxEfiResetVectorLd = Dummy linker for the EFI reset vectors. TOOL_VBoxEfiResetVectorLd_LINK_MISCBIN_OUTPUT = TOOL_VBoxEfiResetVectorLd_LINK_MISCBIN_DEPEND = TOOL_VBoxEfiResetVectorLd_LINK_MISCBIN_DEPORD = define TOOL_VBoxEfiResetVectorLd_LINK_MISCBIN_CMDS $(VBOX_BLD_PYTHON) $(VBOX_PATH_EFI_FIRMWARE)/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py \ "$(objs)" \ "$(out)" endef # Makes a boot sector test image. TEMPLATE_VBoxEfiResetVectorRaw = kBuild tool config for building the EFI reset vectors. TEMPLATE_VBoxEfiResetVectorRaw_INSTTYPE = none TEMPLATE_VBoxEfiResetVectorRaw_BINSUFF = .raw TEMPLATE_VBoxEfiResetVectorRaw_MODE = 0644 TEMPLATE_VBoxEfiResetVectorRaw_ASTOOL = YASM TEMPLATE_VBoxEfiResetVectorRaw_ASFLAGS:= -f bin $(VBOX_YASM_Wno-segreg-in-64bit) --mapfile TEMPLATE_VBoxEfiResetVectorRaw_ASDEFS = ASM_FORMAT_BIN __YASM__ TEMPLATE_VBoxEfiResetVectorRaw_INCS = UefiCpuPkg/ResetVector/Vtf0 TEMPLATE_VBoxEfiResetVectorRaw_LDTOOL = VBoxEfiResetVectorLd MISCBINS += VBoxEfiResetVector-x86 VBoxEfiResetVector-x86_TEMPLATE = VBoxEfiResetVectorRaw VBoxEfiResetVector-x86_DEFS = ARCH_IA32 RT_ARCH_X86 DEBUG_NONE VBoxEfiResetVector-x86_SOURCES = OvmfPkg/ResetVector/ResetVectorCode.asm MISCBINS += VBoxEfiResetVector-amd64 VBoxEfiResetVector-amd64_TEMPLATE = VBoxEfiResetVectorRaw VBoxEfiResetVector-amd64_DEFS = ARCH_X64 RT_ARCH_AMD64 DEBUG_NONE VBoxEfiResetVector-amd64_SOURCES = OvmfPkg/ResetVector/ResetVectorCode.asm # # Include the footer early so that we can use VBoxEfiFirmware_0_OUTDIR below. # include $(FILE_KBUILD_SUB_FOOTER) # # Incomplete list of dependencies relative. # VBOX_EFI_DEPENDENCIES = \ $(VBOX_PATH_EFI_FIRMWARE)/../DevEFI.h \ $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxDebugAgentLib/VBoxDebugAgentLib.c \ $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxDebugAgentLib/VBoxDebugAgentLib.inf \ $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxPeCoffExtraActionLib/VBoxPeCoffExtraActionLib.c \ $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/Library/VBoxPeCoffExtraActionLib/VBoxPeCoffExtraActionLib.inf \ $(VBOX_PATH_EFI_FIRMWARE)/VBoxPkg/VBoxPkg.dec \ \ $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkg.dec \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsStrings.uni \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/String.c \ $(VBOX_PATH_EFI_FIRMWARE)/IntelFrameworkModulePkg/Library/GenericBdsLib/String.h \ # # The common build.py invocation part. # if1of ($(KBUILD_HOST), win) VBOX_EFI_REDIRECT_E_EQUAL:=$(EQUAL) VBOX_EFI_BUILD_CMD = $(REDIRECT) \ -E 'PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH)' \ -E 'INCLUDE=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_SEP)$(PATH_TOOL_$(VBOX_VCC_TOOL)_INC)$(INCLUDE)' \ -E 'COMSPEC=$(windir)\system32\cmd.exe' else VBOX_EFI_REDIRECT_E_EQUAL:= VBOX_EFI_BUILD_CMD = $(REDIRECT) \ -E "PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH)" \ -E "C_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)" \ -E "CPLUS_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)" endif VBOX_EFI_BUILD_CMD += \ -E 'PYTHONPATH=$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python' \ -E 'PYTHONDONTWRITEBYTECODE=1' \ -E 'IASL_BIN=$(VBOX_IASLCMD)' \ -E 'NASM_BIN=$(VBOX_YASMCMD)' \ -E 'WORKSPACE=$(VBOX_PATH_EFI_FIRMWARE)' \ -E 'EDK_TOOLS_PATH=$(VBOX_PATH_EFI_FIRMWARE)/BaseTools' \ -E 'EFI_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \ -E 'ECP_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \ -E 'EDK_SOURCE$(VBOX_EFI_REDIRECT_E_EQUAL)' \ -E 'X64_PETOOLS_PREFIX$(VBOX_EFI_REDIRECT_E_EQUAL)' \ -E 'ARCH$(VBOX_EFI_REDIRECT_E_EQUAL)' \ -E 'IPF_PETOOLS_PREFIX=__no_ipf__' \ -E $(if-expr "$(EFI_QUIET)" != "" || "$(KBUILD_VERBOSE)" != "",'EFI_QUIET=','EFI_QUIET=@') \ -C '$(VBOX_PATH_EFI_FIRMWARE)' \ -- $(VBOX_BLD_PYTHON) "$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python/build/build.py" \ -D VBOX_WITH_EDK2_REV=13361 \ -D VBOX=1 \ -D VBOX_WITH_OVMF=1 \ -D BUILD_NEW_SHELL=1 \ -D VBOX_REV=$(VBOX_SVN_REV) \ -D "VBOX_OUTPUT_BASE_DIR=$(VBoxEfiFirmware_0_OUTDIR)" \ -D "VBOX_PATH_ROOT=$(PATH_ROOT)" \ -D "VBOX_RESET_VECTOR_X86=$(VBoxEfiResetVector-x86_1_TARGET)" \ -D "VBOX_RESET_VECTOR_AMD64=$(VBoxEfiResetVector-amd64_1_TARGET)" \ $(if $(VBOX_OSE),-D "VBOX_OSE=1") \ --silent \ $(if $(KBUILD_VERBOSE),,--quiet) \ --no-cache \ --buildtarget $(VBOX_EFI_BUILD_TARGET) \ --tagname $(VBOX_EFI_TOOL_CHAIN) # # Tools configurations. # $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt: \ $(VBOX_PATH_EFI_FIRMWARE)/vbox-tools_def.txt \ $(MAKEFILE) | $$(dir $$@) $(RM) -f -- "$@" $(SED) \ -e 's,@VBOX_IASLCMD@,$(VBOX_IASLCMD),' \ -e 's,@VBOX_YASMCMD@,$(VBOX_YASMCMD),' \ -e 's,@KMK@,$(MAKE),' \ \ -e 's,@VBOX_PATH_PREFIX_MINGW32@,$(VBOX_PATH_PREFIX_MINGW32),' \ -e 's,@VBOX_PATH_PREFIX_MINGW64@,$(VBOX_PATH_PREFIX_MINGW64),' \ -e 's,@VBOX_MINGW32_Wno@,-Wno-address $(VBOX_MINGW32_Wno-unused-but-set-variable) $(VBOX_MINGW32_Wno-maybe-uninitialized) $(VBOX_MINGW32_Wno-array-bounds),' \ -e 's,@VBOX_MINGW64_Wno@,-Wno-address $(VBOX_MINGW64_Wno-unused-but-set-variable) $(VBOX_MINGW64_Wno-maybe-uninitialized) $(VBOX_MINGW64_Wno-array-bounds),' \ -e 's,@VBOX_MINGW64_USER_LABEL_PREFIX@,$(VBOX_MINGW64_USER_LABEL_PREFIX),' \ \ -e 's,@PATH_VS2010@,$(PATH_TOOL_$(VBOX_VCC_TOOL)),' \ -e 's,@PATH_VS2010_AMD64_BIN@,$(PATH_TOOL_$(VBOX_VCC_TOOL))/bin/$(subst x86,x86_amd64,$(KBUILD_HOST_ARCH)),' \ \ --output $@ $< # # VBoxEFI32 # $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt: $(MAKEFILE) | $$(dir $$@) $(VBOX_EFI_BLDPROGS) $(APPEND) -tn "$@" \ "# Automatically generated, do not edit" \ "" \ "# These variables cannot be overriden by the build.py command line." \ "TOOL_CHAIN_CONF = $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt" \ "BUILD_RULE_CONF = $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Conf/build_rule.template" \ "" \ "# These variables are overridden and this is just for show." \ "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgIa32.dsc" \ "TARGET = $(VBOX_EFI_BUILD_TARGET)" \ "TARGET_ARCH = IA32" \ "TOOL_CHAIN_TAG = $(VBOX_EFI_TOOL_CHAIN)" \ "MAX_CONCURRENT_THREAD_NUMBER = 1" $(VBoxEfiFirmware_0_OUTDIR)/x86/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd \ + $(VBoxEfiFirmwareDbg32_SOURCES): \ $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt \ $(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/tools_def.txt \ $$(VBoxEfiResetVector-x86_1_TARGET) \ $(VBOX_EFI_DEPENDENCIES) \ $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgIa32.dsc \ $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgIa32.fdf + $(VBOX_EFI_BUILD_CMD) \ --vbox-target-conf "$(VBoxEfiFirmware_0_OUTDIR)/x86/Conf/target.txt" \ --arch IA32 \ --platform OvmfPkg/OvmfPkgIa32.dsc \ -n 1 # -v # # VBoxEFI64 # $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt: $(MAKEFILE) | $$(dir $$@) $(VBOX_EFI_BLDPROGS) $(APPEND) -tn "$@" \ "# Automatically generated, do not edit" \ "" \ "# These variables cannot be overriden by the build.py command line." \ "TOOL_CHAIN_CONF = $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt" \ "BUILD_RULE_CONF = $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Conf/build_rule.template" \ "" \ "# These variables are overridden and this is just for show." \ "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc" \ "TARGET = $(VBOX_EFI_BUILD_TARGET)" \ "TARGET_ARCH = X64" \ "TOOL_CHAIN_TAG = $(VBOX_EFI_TOOL_CHAIN)" \ "MAX_CONCURRENT_THREAD_NUMBER = 1" $(VBoxEfiFirmware_0_OUTDIR)/amd64/$(VBOX_EFI_OUTPUT_SUBDIR)/FV/OVMF.fd \ + $(VBoxEfiFirmwareDbg64_SOURCES): \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt \ $(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/tools_def.txt \ $$(VBoxEfiResetVector-amd64_1_TARGET) \ $(VBOX_EFI_DEPENDENCIES) \ $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgX64.dsc \ $(VBOX_PATH_EFI_FIRMWARE)/OvmfPkg/OvmfPkgX64.fdf + $(VBOX_EFI_BUILD_CMD) \ --vbox-target-conf "$(VBoxEfiFirmware_0_OUTDIR)/amd64/Conf/target.txt" \ --arch X64 \ --platform OvmfPkg/OvmfPkgX64.dsc \ -n 1 # -v # # Some aliases. # build-efi-x86: $$(filter %VBoxEFI32.fd,$$(VBoxEfiFirmware_2_STAGE_TARGETS)) build-efi-amd64: $$(filter %VBoxEFI64.fd,$$(VBoxEfiFirmware_2_STAGE_TARGETS))