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