blob: e57fa0972743631b56a4a6e4bc4b19d3e7204fef [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001SUMMARY = "OVMF - UEFI firmware for Qemu and KVM"
2DESCRIPTION = "OVMF is an EDK II based project to enable UEFI support for \
3Virtual Machines. OVMF contains sample UEFI firmware for QEMU and KVM"
4HOMEPAGE = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005LICENSE = "BSD"
6LICENSE_class-target = "${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'BSD & OpenSSL', 'BSD', d)}"
7LIC_FILES_CHKSUM = "file://OvmfPkg/License.txt;md5=343dc88e82ff33d042074f62050c3496"
8
9# Enabling Secure Boot adds a dependency on OpenSSL and implies
10# compiling OVMF twice, so it is disabled by default. Distros
11# may change that default.
12PACKAGECONFIG ??= ""
13PACKAGECONFIG[secureboot] = ",,,"
14
15SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016 file://0001-ia32-Dont-use-pie.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017 file://0002-ovmf-update-path-to-native-BaseTools.patch \
18 file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 file://0004-ovmf-enable-long-path-file.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020 file://VfrCompile-increase-path-length-limit.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021 file://no-stack-protector-all-archs.patch \
Brad Bishopd5ae7d92018-06-14 09:52:03 -070022 file://0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch \
23 file://0002-BaseTools-header.makefile-add-Wno-restrict.patch \
24 file://0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch \
25 file://0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 "
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027UPSTREAM_VERSION_UNKNOWN = "1"
28
29OPENSSL_RELEASE = "openssl-1.1.0e"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030
31SRC_URI_append_class-target = " \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032 ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'http://www.openssl.org/source/${OPENSSL_RELEASE}.tar.gz;name=openssl;subdir=${S}/CryptoPkg/Library/OpensslLib', '', d)} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 file://0007-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch \
34"
35
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036SRCREV="ec4910cd3336565fdb61dafdd9ec4ae7a6160ba3"
37SRC_URI[openssl.md5sum] = "51c42d152122e474754aea96f66928c6"
38SRC_URI[openssl.sha256sum] = "57be8618979d80c910728cfc99369bf97b2a1abd8f366ab6ebdee8975ad3874c"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039
40inherit deploy
41
Brad Bishopd5ae7d92018-06-14 09:52:03 -070042PARALLEL_MAKE = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043
44S = "${WORKDIR}/git"
45
46DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native qemu-native"
47
48DEPENDS_class-target="ovmf-native"
49
50DEPENDS_append = " nasm-native"
51
52EDK_TOOLS_DIR="edk2_basetools"
53
54# OVMF has trouble building with the default optimization of -O2.
55BUILD_OPTIMIZATION="-pipe"
56
57# OVMF supports IA only, although it could conceivably support ARM someday.
58COMPATIBLE_HOST='(i.86|x86_64).*'
59
60# Additional build flags for OVMF with Secure Boot.
61# Fedora also uses "-D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD".
62OVMF_SECURE_BOOT_EXTRA_FLAGS ??= ""
63OVMF_SECURE_BOOT_FLAGS = "-DSECURE_BOOT_ENABLE=TRUE ${OVMF_SECURE_BOOT_EXTRA_FLAGS}"
64
65do_patch[postfuncs] += "fix_basetools_location"
66fix_basetools_location () {
67}
68fix_basetools_location_class-target() {
69 # Replaces the fake path inserted by 0002-ovmf-update-path-to-native-BaseTools.patch.
70 # Necessary for finding the actual BaseTools from ovmf-native.
71 sed -i -e 's#BBAKE_EDK_TOOLS_PATH#${STAGING_BINDIR_NATIVE}/${EDK_TOOLS_DIR}#' ${S}/OvmfPkg/build.sh
72}
73
74do_patch[postfuncs] += "fix_iasl"
75fix_iasl() {
76}
77fix_iasl_class-native() {
78 # iasl is not installed under /usr/bin when building with OE.
79 sed -i -e 's#/usr/bin/iasl#${STAGING_BINDIR_NATIVE}/iasl#' ${S}/BaseTools/Conf/tools_def.template
80}
81
82# Inject CC and friends into the build. LINKER already is in GNUmakefile.
83# Must be idempotent and thus remove old assignments that were inserted
84# earlier.
85do_patch[postfuncs] += "fix_toolchain"
86fix_toolchain() {
87 sed -i \
88 -e '/^\(CC\|CXX\|AS\|AR\|LD\|LINKER\) =/d' \
89 -e '/^APPLICATION/a CC = ${CC}\nCXX = ${CXX}\nAS = ${AS}\nAR = ${AR}\nLD = ${LD}\nLINKER = $(CC)' \
90 ${S}/BaseTools/Source/C/Makefiles/app.makefile
91 sed -i \
92 -e '/^\(CC\|CXX\|AS\|AR\|LD\)/d' \
93 -e '/^VFR_CPPFLAGS/a CC = ${CC}\nCXX = ${CXX}\nAS = ${AS}\nAR = ${AR}\nLD = ${LD}' \
94 ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile
95}
96fix_toolchain_append_class-native() {
97 # This tools_def.template is going to be used by the target ovmf and
98 # defines which compilers to use. For the GCC toolchain definitions,
99 # that will be ${HOST_PREFIX}gcc. However, "make" doesn't need that
100 # prefix.
101 #
102 # Injecting ENV(HOST_PREFIX) matches exporting that value as env
103 # variable in do_compile_class-target.
104 sed -i \
105 -e 's#\(ENV\|DEF\)(GCC.*_PREFIX)#ENV(HOST_PREFIX)#' \
106 -e 's#ENV(HOST_PREFIX)make#make#' \
107 ${S}/BaseTools/Conf/tools_def.template
108 sed -i \
109 -e '/^\(LFLAGS\|CFLAGS\) +=/d' \
110 -e '/^LINKER/a LFLAGS += ${BUILD_LDFLAGS}\nCFLAGS += ${BUILD_CFLAGS}' \
111 ${S}/BaseTools/Source/C/Makefiles/app.makefile \
112 ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile
113 # Linking with gold fails:
114 # internal error in do_layout, at ../../gold/object.cc:1821
115 # make: *** [.../OUTPUT/Facs.acpi] Error 1
116 # We intentionally hard-code the use of ld.bfd regardless of DISTRO_FEATURES
117 # to make ovmf-native reusable across distros.
118 sed -i \
119 -e 's#^\(DEFINE GCC.*DLINK.*FLAGS *=\)#\1 -fuse-ld=bfd#' \
120 ${S}/BaseTools/Conf/tools_def.template
121}
122
123GCC_VER="$(${CC} -v 2>&1 | tail -n1 | awk '{print $3}')"
124
125fixup_target_tools() {
126 case ${1} in
127 4.4.*)
128 FIXED_GCCVER=GCC44
129 ;;
130 4.5.*)
131 FIXED_GCCVER=GCC45
132 ;;
133 4.6.*)
134 FIXED_GCCVER=GCC46
135 ;;
136 4.7.*)
137 FIXED_GCCVER=GCC47
138 ;;
139 4.8.*)
140 FIXED_GCCVER=GCC48
141 ;;
142 4.9.*)
143 FIXED_GCCVER=GCC49
144 ;;
145 *)
146 FIXED_GCCVER=GCC5
147 ;;
148 esac
149 echo ${FIXED_GCCVER}
150}
151
152do_compile_class-native() {
153 oe_runmake -C ${S}/BaseTools
154}
155
156do_compile_class-target() {
157 export LFLAGS="${LDFLAGS}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400158 PARALLEL_JOBS="${@oe.utils.parallel_make_argument(d, '-n %d')}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500159 OVMF_ARCH="X64"
160 if [ "${TARGET_ARCH}" != "x86_64" ] ; then
161 OVMF_ARCH="IA32"
162 fi
163
164 # The build for the target uses BaseTools/Conf/tools_def.template
165 # from ovmf-native to find the compiler, which depends on
166 # exporting HOST_PREFIX.
167 export HOST_PREFIX="${HOST_PREFIX}"
168
169 # BaseTools/Conf gets copied to Conf, but only if that does not
170 # exist yet. To ensure that an updated template gets used during
171 # incremental builds, we need to remove the copy before we start.
172 rm -f `ls ${S}/Conf/*.txt | grep -v ReadMe.txt`
173
174 # ${WORKDIR}/ovmf is a well-known location where do_install and
175 # do_deploy will be able to find the files.
176 rm -rf ${WORKDIR}/ovmf
177 mkdir ${WORKDIR}/ovmf
178 OVMF_DIR_SUFFIX="X64"
179 if [ "${TARGET_ARCH}" != "x86_64" ] ; then
180 OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
181 fi
182 FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
183 bbnote FIXED_GCCVER is ${FIXED_GCCVER}
184 build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
185
186 bbnote "Building without Secure Boot."
187 rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX
188 ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER}
189 ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd
190 ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd
191 ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd
192 ln ${build_dir}/${OVMF_ARCH}/Shell.efi ${WORKDIR}/ovmf/
193
194 if ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'true', 'false', d)}; then
195 # See CryptoPkg/Library/OpensslLib/Patch-HOWTO.txt and
196 # https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/ for
197 # building with Secure Boot enabled.
198 bbnote "Building with Secure Boot."
199 rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500200 ln -sf ${OPENSSL_RELEASE} ${S}/CryptoPkg/Library/OpensslLib/openssl
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500201 ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER} ${OVMF_SECURE_BOOT_FLAGS}
202 ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.secboot.fd
203 ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.secboot.code.fd
204 ln ${build_dir}/${OVMF_ARCH}/EnrollDefaultKeys.efi ${WORKDIR}/ovmf/
205 fi
206}
207
208do_install_class-native() {
209 install -d ${D}/${bindir}/edk2_basetools
210 cp -r ${S}/BaseTools ${D}/${bindir}/${EDK_TOOLS_DIR}
211}
212
213do_install_class-target() {
214 # Content for UEFI shell iso. We install the EFI shell as
215 # bootx64/ia32.efi because then it can be started even when the
216 # firmware itself does not contain it.
217 install -d ${D}/efi/boot
218 install ${WORKDIR}/ovmf/Shell.efi ${D}/efi/boot/boot${@ "ia32" if "${TARGET_ARCH}" != "x86_64" else "x64"}.efi
219 if ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'true', 'false', d)}; then
220 install ${WORKDIR}/ovmf/EnrollDefaultKeys.efi ${D}
221 fi
222}
223
224# This always gets packaged because ovmf-shell-image depends on it.
225# This allows testing that recipe in all configurations because it
226# can always be part of a world build.
227#
228# However, EnrollDefaultKeys.efi is only included when Secure Boot is enabled.
229PACKAGES =+ "ovmf-shell-efi"
230FILES_ovmf-shell-efi = " \
231 EnrollDefaultKeys.efi \
232 efi/ \
233"
234
235do_deploy() {
236}
237do_deploy[cleandirs] = "${DEPLOYDIR}"
238do_deploy_class-target() {
239 # For use with "runqemu ovmf".
240 for i in \
241 ovmf \
242 ovmf.code \
243 ovmf.vars \
244 ${@bb.utils.contains('PACKAGECONFIG', 'secureboot', 'ovmf.secboot ovmf.secboot.code', '', d)} \
245 ; do
246 qemu-img convert -f raw -O qcow2 ${WORKDIR}/ovmf/$i.fd ${DEPLOYDIR}/$i.qcow2
247 done
248}
249addtask do_deploy after do_compile before do_build
250
251BBCLASSEXTEND = "native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500252TOOLCHAIN = "gcc"