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