1eb8dc403SDave CobbleySUMMARY = "Fast open source processor emulator"
2eb8dc403SDave CobbleyHOMEPAGE = "http://qemu.org"
3eb8dc403SDave CobbleyLICENSE = "GPLv2 & LGPLv2.1"
4*19323693SBrad Bishop
5*19323693SBrad BishopRDEPENDS_${PN}-ptest = "bash make"
6*19323693SBrad Bishop
7*19323693SBrad BishopLIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
8*19323693SBrad Bishop                    file://COPYING.LIB;endline=24;md5=c04def7ae38850e7d3ef548588159913"
9*19323693SBrad Bishop
10*19323693SBrad BishopSRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
11*19323693SBrad Bishop           file://powerpc_rom.bin \
12*19323693SBrad Bishop           file://0001-sdl.c-allow-user-to-disable-pointer-grabs.patch \
13*19323693SBrad Bishop           file://0002-qemu-Add-missing-wacom-HID-descriptor.patch \
14*19323693SBrad Bishop           file://0003-Add-subpackage-ptest-which-runs-all-unit-test-cases-.patch \
15*19323693SBrad Bishop           file://run-ptest \
16*19323693SBrad Bishop           file://0004-qemu-Add-addition-environment-space-to-boot-loader-q.patch \
17*19323693SBrad Bishop           file://0005-qemu-disable-Valgrind.patch \
18*19323693SBrad Bishop           file://0006-qemu-Limit-paths-searched-during-user-mode-emulation.patch \
19*19323693SBrad Bishop           file://0007-qemu-native-set-ld.bfd-fix-cflags-and-set-some-envir.patch \
20*19323693SBrad Bishop           file://0008-chardev-connect-socket-to-a-spawned-command.patch \
21*19323693SBrad Bishop           file://0009-apic-fixup-fallthrough-to-PIC.patch \
22*19323693SBrad Bishop           file://0010-linux-user-Fix-webkitgtk-hangs-on-32-bit-x86-target.patch \
23*19323693SBrad Bishop           file://0011-Revert-linux-user-fix-mmap-munmap-mprotect-mremap-sh.patch \
24*19323693SBrad Bishop           file://0001-Add-a-missing-X11-include.patch \
25*19323693SBrad Bishop           file://0001-egl-headless-add-egl_create_context.patch \
26*19323693SBrad Bishop           file://0014-fix-CVE-2018-16872.patch \
27*19323693SBrad Bishop           file://0015-fix-CVE-2018-20124.patch \
28*19323693SBrad Bishop           file://0016-fix-CVE-2018-20125.patch \
29*19323693SBrad Bishop           file://0017-fix-CVE-2018-20126.patch \
30*19323693SBrad Bishop           file://0018-fix-CVE-2018-20191.patch \
31*19323693SBrad Bishop           file://0019-fix-CVE-2018-20216.patch \
32*19323693SBrad Bishop           file://CVE-2019-3812.patch \
33*19323693SBrad Bishop           "
34*19323693SBrad BishopUPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
35*19323693SBrad Bishop
36*19323693SBrad BishopSRC_URI[md5sum] = "fb687ce0b02d3bf4327e36d3b99427a8"
37*19323693SBrad BishopSRC_URI[sha256sum] = "6a0508df079a0a33c2487ca936a56c12122f105b8a96a44374704bef6c69abfc"
38*19323693SBrad Bishop
39*19323693SBrad BishopCOMPATIBLE_HOST_mipsarchn32 = "null"
40*19323693SBrad BishopCOMPATIBLE_HOST_mipsarchn64 = "null"
41*19323693SBrad Bishop
42*19323693SBrad Bishopdo_install_append() {
43*19323693SBrad Bishop    # Prevent QA warnings about installed ${localstatedir}/run
44*19323693SBrad Bishop    if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
45*19323693SBrad Bishop}
46*19323693SBrad Bishop
47*19323693SBrad Bishopdo_compile_ptest() {
48*19323693SBrad Bishop	make buildtest-TESTS
49*19323693SBrad Bishop}
50*19323693SBrad Bishop
51*19323693SBrad Bishopdo_install_ptest() {
52*19323693SBrad Bishop	cp -rL ${B}/tests ${D}${PTEST_PATH}
53*19323693SBrad Bishop	find ${D}${PTEST_PATH}/tests -type f -name "*.[Sshcod]" | xargs -i rm -rf {}
54*19323693SBrad Bishop
55*19323693SBrad Bishop	cp ${S}/tests/Makefile.include ${D}${PTEST_PATH}/tests
56*19323693SBrad Bishop	# Don't check the file genreated by configure
57*19323693SBrad Bishop	sed -i -e '/wildcard config-host.mak/d' \
58*19323693SBrad Bishop	       -e '$ {/endif/d}' ${D}${PTEST_PATH}/tests/Makefile.include
59*19323693SBrad Bishop}
60*19323693SBrad Bishop
61eb8dc403SDave Cobbley
62eb8dc403SDave Cobbleyrequire qemu-targets.inc
63*19323693SBrad Bishopinherit pkgconfig bluetooth ptest
64eb8dc403SDave Cobbley
65eb8dc403SDave Cobbley# QEMU_TARGETS is overridable variable
661a4b7ee2SBrad BishopQEMU_TARGETS ?= "arm aarch64 i386 mips mipsel mips64 mips64el ppc riscv32 riscv64 sh4 x86_64"
67eb8dc403SDave Cobbley
68eb8dc403SDave CobbleyEXTRA_OECONF = " \
69eb8dc403SDave Cobbley    --prefix=${prefix} \
70eb8dc403SDave Cobbley    --bindir=${bindir} \
71eb8dc403SDave Cobbley    --includedir=${includedir} \
72eb8dc403SDave Cobbley    --libdir=${libdir} \
73eb8dc403SDave Cobbley    --mandir=${mandir} \
74eb8dc403SDave Cobbley    --datadir=${datadir} \
75eb8dc403SDave Cobbley    --docdir=${docdir}/${BPN} \
76eb8dc403SDave Cobbley    --sysconfdir=${sysconfdir} \
77eb8dc403SDave Cobbley    --libexecdir=${libexecdir} \
78eb8dc403SDave Cobbley    --localstatedir=${localstatedir} \
79eb8dc403SDave Cobbley    --with-confsuffix=/${BPN} \
80eb8dc403SDave Cobbley    --disable-strip \
81eb8dc403SDave Cobbley    --disable-werror \
82eb8dc403SDave Cobbley    --extra-cflags='${CFLAGS}' \
831a4b7ee2SBrad Bishop    ${PACKAGECONFIG_CONFARGS} \
84eb8dc403SDave Cobbley    "
85eb8dc403SDave Cobbley
86eb8dc403SDave Cobbleyexport LIBTOOL="${HOST_SYS}-libtool"
87eb8dc403SDave Cobbley
881a4b7ee2SBrad BishopB = "${WORKDIR}/build"
891a4b7ee2SBrad Bishop
90eb8dc403SDave Cobbleydo_configure_prepend_class-native() {
91eb8dc403SDave Cobbley	# Append build host pkg-config paths for native target since the host may provide sdl
92eb8dc403SDave Cobbley	BHOST_PKGCONFIG_PATH=$(PATH=/usr/bin:/bin pkg-config --variable pc_path pkg-config || echo "")
93eb8dc403SDave Cobbley	if [ ! -z "$BHOST_PKGCONFIG_PATH" ]; then
94eb8dc403SDave Cobbley		export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$BHOST_PKGCONFIG_PATH
95eb8dc403SDave Cobbley	fi
96eb8dc403SDave Cobbley}
97eb8dc403SDave Cobbley
98eb8dc403SDave Cobbleydo_configure() {
99eb8dc403SDave Cobbley    ${S}/configure ${EXTRA_OECONF}
100eb8dc403SDave Cobbley}
101eb8dc403SDave Cobbley
102eb8dc403SDave Cobbleydo_install () {
1031a4b7ee2SBrad Bishop	export STRIP=""
1041a4b7ee2SBrad Bishop	oe_runmake 'DESTDIR=${D}' install
105eb8dc403SDave Cobbley}
106eb8dc403SDave Cobbley
107eb8dc403SDave Cobbley# The following fragment will create a wrapper for qemu-mips user emulation
108eb8dc403SDave Cobbley# binary in order to work around a segmentation fault issue. Basically, by
109eb8dc403SDave Cobbley# default, the reserved virtual address space for 32-on-64 bit is set to 4GB.
110eb8dc403SDave Cobbley# This will trigger a MMU access fault in the virtual CPU. With this change,
111eb8dc403SDave Cobbley# the qemu-mips works fine.
112eb8dc403SDave Cobbley# IMPORTANT: This piece needs to be removed once the root cause is fixed!
113eb8dc403SDave Cobbleydo_install_append() {
114eb8dc403SDave Cobbley	if [ -e "${D}/${bindir}/qemu-mips" ]; then
115eb8dc403SDave Cobbley		create_wrapper ${D}/${bindir}/qemu-mips \
116eb8dc403SDave Cobbley			QEMU_RESERVED_VA=0x0
117eb8dc403SDave Cobbley	fi
118eb8dc403SDave Cobbley}
119eb8dc403SDave Cobbley# END of qemu-mips workaround
120eb8dc403SDave Cobbley
121*19323693SBrad Bishopmake_qemu_wrapper() {
122*19323693SBrad Bishop        gdk_pixbuf_module_file=`pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0`
123eb8dc403SDave Cobbley
124*19323693SBrad Bishop        for tool in `ls ${D}${bindir}/qemu-system-*`; do
125*19323693SBrad Bishop                create_wrapper $tool \
126*19323693SBrad Bishop                        GDK_PIXBUF_MODULE_FILE=$gdk_pixbuf_module_file \
127*19323693SBrad Bishop                        FONTCONFIG_PATH=/etc/fonts \
128*19323693SBrad Bishop                        GTK_THEME=Adwaita
129*19323693SBrad Bishop        done
130*19323693SBrad Bishop}
131eb8dc403SDave Cobbley
132*19323693SBrad Bishop# Disable kvm/virgl/mesa on targets that do not support it
133*19323693SBrad BishopPACKAGECONFIG_remove_darwin = "kvm virglrenderer glx gtk+"
134*19323693SBrad BishopPACKAGECONFIG_remove_mingw32 = "kvm virglrenderer glx gtk+"
135eb8dc403SDave Cobbley
1361a4b7ee2SBrad BishopPACKAGECONFIG[sdl] = "--enable-sdl --with-sdlabi=2.0,--disable-sdl,libsdl2"
137eb8dc403SDave CobbleyPACKAGECONFIG[virtfs] = "--enable-virtfs --enable-attr,--disable-virtfs,libcap attr,"
138eb8dc403SDave CobbleyPACKAGECONFIG[aio] = "--enable-linux-aio,--disable-linux-aio,libaio,"
139eb8dc403SDave CobbleyPACKAGECONFIG[xfs] = "--enable-xfsctl,--disable-xfsctl,xfsprogs,"
140eb8dc403SDave CobbleyPACKAGECONFIG[xen] = "--enable-xen,--disable-xen,xen,xen-libxenstore xen-libxenctrl xen-libxenguest"
141eb8dc403SDave CobbleyPACKAGECONFIG[vnc-sasl] = "--enable-vnc --enable-vnc-sasl,--disable-vnc-sasl,cyrus-sasl,"
142eb8dc403SDave CobbleyPACKAGECONFIG[vnc-jpeg] = "--enable-vnc --enable-vnc-jpeg,--disable-vnc-jpeg,jpeg,"
143eb8dc403SDave CobbleyPACKAGECONFIG[vnc-png] = "--enable-vnc --enable-vnc-png,--disable-vnc-png,libpng,"
144eb8dc403SDave CobbleyPACKAGECONFIG[libcurl] = "--enable-curl,--disable-curl,libcurl,"
145eb8dc403SDave CobbleyPACKAGECONFIG[nss] = "--enable-smartcard,--disable-smartcard,nss,"
146eb8dc403SDave CobbleyPACKAGECONFIG[curses] = "--enable-curses,--disable-curses,ncurses,"
147*19323693SBrad BishopPACKAGECONFIG[gtk+] = "--enable-gtk --enable-vte,--disable-gtk --disable-vte,gtk+3 vte gettext-native"
148eb8dc403SDave CobbleyPACKAGECONFIG[libcap-ng] = "--enable-cap-ng,--disable-cap-ng,libcap-ng,"
149eb8dc403SDave CobbleyPACKAGECONFIG[ssh2] = "--enable-libssh2,--disable-libssh2,libssh2,"
150eb8dc403SDave CobbleyPACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt,"
151eb8dc403SDave CobbleyPACKAGECONFIG[nettle] = "--enable-nettle,--disable-nettle,nettle"
152eb8dc403SDave CobbleyPACKAGECONFIG[libusb] = "--enable-libusb,--disable-libusb,libusb1"
153eb8dc403SDave CobbleyPACKAGECONFIG[fdt] = "--enable-fdt,--disable-fdt,dtc"
154eb8dc403SDave CobbleyPACKAGECONFIG[alsa] = "--audio-drv-list='oss alsa',,alsa-lib"
155eb8dc403SDave CobbleyPACKAGECONFIG[glx] = "--enable-opengl,--disable-opengl,mesa"
156eb8dc403SDave CobbleyPACKAGECONFIG[lzo] = "--enable-lzo,--disable-lzo,lzo"
157eb8dc403SDave CobbleyPACKAGECONFIG[numa] = "--enable-numa,--disable-numa,numactl"
158eb8dc403SDave CobbleyPACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls"
159eb8dc403SDave CobbleyPACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2"
160eb8dc403SDave CobbleyPACKAGECONFIG[bluez] = "--enable-bluez,--disable-bluez,${BLUEZ}"
161eb8dc403SDave CobbleyPACKAGECONFIG[libiscsi] = "--enable-libiscsi,--disable-libiscsi"
162eb8dc403SDave CobbleyPACKAGECONFIG[kvm] = "--enable-kvm,--disable-kvm"
1631a4b7ee2SBrad BishopPACKAGECONFIG[virglrenderer] = "--enable-virglrenderer,--disable-virglrenderer,virglrenderer"
1641a4b7ee2SBrad Bishop# spice will be in meta-networking layer
1651a4b7ee2SBrad BishopPACKAGECONFIG[spice] = "--enable-spice,--disable-spice,spice"
1661a4b7ee2SBrad Bishop# usbredir will be in meta-networking layer
1671a4b7ee2SBrad BishopPACKAGECONFIG[usb-redir] = "--enable-usb-redir,--disable-usb-redir,usbredir"
168eb8dc403SDave Cobbley
169eb8dc403SDave CobbleyINSANE_SKIP_${PN} = "arch"
170