1eb8dc403SDave CobbleySUMMARY = "Fast open source processor emulator"
2eb8dc403SDave CobbleyHOMEPAGE = "http://qemu.org"
3eb8dc403SDave CobbleyLICENSE = "GPLv2 & LGPLv2.1"
419323693SBrad Bishop
519323693SBrad BishopRDEPENDS_${PN}-ptest = "bash make"
619323693SBrad Bishop
715ae2509SBrad Bishoprequire qemu-targets.inc
896ff1984SBrad Bishopinherit pkgconfig ptest
915ae2509SBrad Bishop
1019323693SBrad BishopLIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
11c342db35SBrad Bishop                    file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f"
1219323693SBrad Bishop
1319323693SBrad BishopSRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
1419323693SBrad Bishop           file://powerpc_rom.bin \
1519323693SBrad Bishop           file://run-ptest \
16c342db35SBrad Bishop           file://0001-qemu-Add-missing-wacom-HID-descriptor.patch \
17c342db35SBrad Bishop           file://0002-Add-subpackage-ptest-which-runs-all-unit-test-cases-.patch \
18c342db35SBrad Bishop           file://0003-qemu-Add-addition-environment-space-to-boot-loader-q.patch \
19c342db35SBrad Bishop           file://0004-qemu-disable-Valgrind.patch \
20c68388fcSBrad Bishop           file://0005-qemu-native-set-ld.bfd-fix-cflags-and-set-some-envir.patch \
21c68388fcSBrad Bishop           file://0006-chardev-connect-socket-to-a-spawned-command.patch \
22c68388fcSBrad Bishop           file://0007-apic-fixup-fallthrough-to-PIC.patch \
23c68388fcSBrad Bishop           file://0008-linux-user-Fix-webkitgtk-hangs-on-32-bit-x86-target.patch \
24c68388fcSBrad Bishop           file://0009-Fix-webkitgtk-builds.patch \
25*79641f25SBrad Bishop           file://0010-configure-Add-pkg-config-handling-for-libgcrypt.patch \
2619323693SBrad Bishop           "
2719323693SBrad BishopUPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
2819323693SBrad Bishop
29c68388fcSBrad BishopSRC_URI[md5sum] = "cdf2b5ca52b9abac9bacb5842fa420f8"
30c68388fcSBrad BishopSRC_URI[sha256sum] = "656e60218689bdeec69903087fd7582d5d3e72238d02f4481d8dc6d79fd909c6"
3119323693SBrad Bishop
3219323693SBrad BishopCOMPATIBLE_HOST_mipsarchn32 = "null"
3319323693SBrad BishopCOMPATIBLE_HOST_mipsarchn64 = "null"
3419323693SBrad Bishop
3519323693SBrad Bishopdo_install_append() {
3619323693SBrad Bishop    # Prevent QA warnings about installed ${localstatedir}/run
3719323693SBrad Bishop    if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
3819323693SBrad Bishop}
3919323693SBrad Bishop
4019323693SBrad Bishopdo_compile_ptest() {
4119323693SBrad Bishop	make buildtest-TESTS
4219323693SBrad Bishop}
4319323693SBrad Bishop
4419323693SBrad Bishopdo_install_ptest() {
4519323693SBrad Bishop	cp -rL ${B}/tests ${D}${PTEST_PATH}
4619323693SBrad Bishop	find ${D}${PTEST_PATH}/tests -type f -name "*.[Sshcod]" | xargs -i rm -rf {}
4719323693SBrad Bishop
4819323693SBrad Bishop	cp ${S}/tests/Makefile.include ${D}${PTEST_PATH}/tests
4919323693SBrad Bishop	# Don't check the file genreated by configure
5019323693SBrad Bishop	sed -i -e '/wildcard config-host.mak/d' \
5119323693SBrad Bishop	       -e '$ {/endif/d}' ${D}${PTEST_PATH}/tests/Makefile.include
5219323693SBrad Bishop}
5319323693SBrad Bishop
54eb8dc403SDave Cobbley# QEMU_TARGETS is overridable variable
551a4b7ee2SBrad BishopQEMU_TARGETS ?= "arm aarch64 i386 mips mipsel mips64 mips64el ppc riscv32 riscv64 sh4 x86_64"
56eb8dc403SDave Cobbley
57eb8dc403SDave CobbleyEXTRA_OECONF = " \
58eb8dc403SDave Cobbley    --prefix=${prefix} \
59eb8dc403SDave Cobbley    --bindir=${bindir} \
60eb8dc403SDave Cobbley    --includedir=${includedir} \
61eb8dc403SDave Cobbley    --libdir=${libdir} \
62eb8dc403SDave Cobbley    --mandir=${mandir} \
63eb8dc403SDave Cobbley    --datadir=${datadir} \
64eb8dc403SDave Cobbley    --docdir=${docdir}/${BPN} \
65eb8dc403SDave Cobbley    --sysconfdir=${sysconfdir} \
66eb8dc403SDave Cobbley    --libexecdir=${libexecdir} \
67eb8dc403SDave Cobbley    --localstatedir=${localstatedir} \
68eb8dc403SDave Cobbley    --with-confsuffix=/${BPN} \
69eb8dc403SDave Cobbley    --disable-strip \
70eb8dc403SDave Cobbley    --disable-werror \
71eb8dc403SDave Cobbley    --extra-cflags='${CFLAGS}' \
721a4b7ee2SBrad Bishop    ${PACKAGECONFIG_CONFARGS} \
73eb8dc403SDave Cobbley    "
74eb8dc403SDave Cobbley
75eb8dc403SDave Cobbleyexport LIBTOOL="${HOST_SYS}-libtool"
76eb8dc403SDave Cobbley
771a4b7ee2SBrad BishopB = "${WORKDIR}/build"
781a4b7ee2SBrad Bishop
7996ff1984SBrad BishopEXTRA_OECONF_append = " --python=${HOSTTOOLS_DIR}/python3"
8096ff1984SBrad Bishop
81eb8dc403SDave Cobbleydo_configure_prepend_class-native() {
82eb8dc403SDave Cobbley	# Append build host pkg-config paths for native target since the host may provide sdl
83eb8dc403SDave Cobbley	BHOST_PKGCONFIG_PATH=$(PATH=/usr/bin:/bin pkg-config --variable pc_path pkg-config || echo "")
84eb8dc403SDave Cobbley	if [ ! -z "$BHOST_PKGCONFIG_PATH" ]; then
85eb8dc403SDave Cobbley		export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$BHOST_PKGCONFIG_PATH
86eb8dc403SDave Cobbley	fi
87eb8dc403SDave Cobbley}
88eb8dc403SDave Cobbley
89eb8dc403SDave Cobbleydo_configure() {
90eb8dc403SDave Cobbley    ${S}/configure ${EXTRA_OECONF}
91eb8dc403SDave Cobbley}
92eb8dc403SDave Cobbley
93eb8dc403SDave Cobbleydo_install () {
941a4b7ee2SBrad Bishop	export STRIP=""
951a4b7ee2SBrad Bishop	oe_runmake 'DESTDIR=${D}' install
96eb8dc403SDave Cobbley}
97eb8dc403SDave Cobbley
98eb8dc403SDave Cobbley# The following fragment will create a wrapper for qemu-mips user emulation
99eb8dc403SDave Cobbley# binary in order to work around a segmentation fault issue. Basically, by
100eb8dc403SDave Cobbley# default, the reserved virtual address space for 32-on-64 bit is set to 4GB.
101eb8dc403SDave Cobbley# This will trigger a MMU access fault in the virtual CPU. With this change,
102eb8dc403SDave Cobbley# the qemu-mips works fine.
103eb8dc403SDave Cobbley# IMPORTANT: This piece needs to be removed once the root cause is fixed!
104eb8dc403SDave Cobbleydo_install_append() {
105eb8dc403SDave Cobbley	if [ -e "${D}/${bindir}/qemu-mips" ]; then
106eb8dc403SDave Cobbley		create_wrapper ${D}/${bindir}/qemu-mips \
107eb8dc403SDave Cobbley			QEMU_RESERVED_VA=0x0
108eb8dc403SDave Cobbley	fi
109eb8dc403SDave Cobbley}
110eb8dc403SDave Cobbley# END of qemu-mips workaround
111eb8dc403SDave Cobbley
11219323693SBrad Bishopmake_qemu_wrapper() {
11319323693SBrad Bishop        gdk_pixbuf_module_file=`pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0`
114eb8dc403SDave Cobbley
11519323693SBrad Bishop        for tool in `ls ${D}${bindir}/qemu-system-*`; do
11619323693SBrad Bishop                create_wrapper $tool \
11719323693SBrad Bishop                        GDK_PIXBUF_MODULE_FILE=$gdk_pixbuf_module_file \
11819323693SBrad Bishop                        FONTCONFIG_PATH=/etc/fonts \
11919323693SBrad Bishop                        GTK_THEME=Adwaita
12019323693SBrad Bishop        done
12119323693SBrad Bishop}
122eb8dc403SDave Cobbley
12319323693SBrad Bishop# Disable kvm/virgl/mesa on targets that do not support it
12419323693SBrad BishopPACKAGECONFIG_remove_darwin = "kvm virglrenderer glx gtk+"
12519323693SBrad BishopPACKAGECONFIG_remove_mingw32 = "kvm virglrenderer glx gtk+"
126eb8dc403SDave Cobbley
127c342db35SBrad BishopPACKAGECONFIG[sdl] = "--enable-sdl,--disable-sdl,libsdl2"
128eb8dc403SDave CobbleyPACKAGECONFIG[virtfs] = "--enable-virtfs --enable-attr,--disable-virtfs,libcap attr,"
129eb8dc403SDave CobbleyPACKAGECONFIG[aio] = "--enable-linux-aio,--disable-linux-aio,libaio,"
130eb8dc403SDave CobbleyPACKAGECONFIG[xfs] = "--enable-xfsctl,--disable-xfsctl,xfsprogs,"
131eb8dc403SDave CobbleyPACKAGECONFIG[xen] = "--enable-xen,--disable-xen,xen,xen-libxenstore xen-libxenctrl xen-libxenguest"
132eb8dc403SDave CobbleyPACKAGECONFIG[vnc-sasl] = "--enable-vnc --enable-vnc-sasl,--disable-vnc-sasl,cyrus-sasl,"
133eb8dc403SDave CobbleyPACKAGECONFIG[vnc-jpeg] = "--enable-vnc --enable-vnc-jpeg,--disable-vnc-jpeg,jpeg,"
134eb8dc403SDave CobbleyPACKAGECONFIG[vnc-png] = "--enable-vnc --enable-vnc-png,--disable-vnc-png,libpng,"
135*79641f25SBrad BishopPACKAGECONFIG[libcurl] = "--enable-curl,--disable-curl,curl,"
136eb8dc403SDave CobbleyPACKAGECONFIG[nss] = "--enable-smartcard,--disable-smartcard,nss,"
137eb8dc403SDave CobbleyPACKAGECONFIG[curses] = "--enable-curses,--disable-curses,ncurses,"
138c342db35SBrad BishopPACKAGECONFIG[gtk+] = "--enable-gtk,--disable-gtk,gtk+3 gettext-native"
139c342db35SBrad BishopPACKAGECONFIG[vte] = "--enable-vte,--disable-vte,vte gettext-native"
140eb8dc403SDave CobbleyPACKAGECONFIG[libcap-ng] = "--enable-cap-ng,--disable-cap-ng,libcap-ng,"
141c68388fcSBrad BishopPACKAGECONFIG[ssh] = "--enable-libssh,--disable-libssh,libssh,"
142eb8dc403SDave CobbleyPACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt,"
143eb8dc403SDave CobbleyPACKAGECONFIG[nettle] = "--enable-nettle,--disable-nettle,nettle"
144eb8dc403SDave CobbleyPACKAGECONFIG[libusb] = "--enable-libusb,--disable-libusb,libusb1"
145eb8dc403SDave CobbleyPACKAGECONFIG[fdt] = "--enable-fdt,--disable-fdt,dtc"
146eb8dc403SDave CobbleyPACKAGECONFIG[alsa] = "--audio-drv-list='oss alsa',,alsa-lib"
147eb8dc403SDave CobbleyPACKAGECONFIG[glx] = "--enable-opengl,--disable-opengl,mesa"
148eb8dc403SDave CobbleyPACKAGECONFIG[lzo] = "--enable-lzo,--disable-lzo,lzo"
149eb8dc403SDave CobbleyPACKAGECONFIG[numa] = "--enable-numa,--disable-numa,numactl"
150eb8dc403SDave CobbleyPACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls"
151eb8dc403SDave CobbleyPACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2"
15296ff1984SBrad BishopPACKAGECONFIG[bluez] = "--enable-bluez,--disable-bluez,bluez5"
153eb8dc403SDave CobbleyPACKAGECONFIG[libiscsi] = "--enable-libiscsi,--disable-libiscsi"
154eb8dc403SDave CobbleyPACKAGECONFIG[kvm] = "--enable-kvm,--disable-kvm"
1551a4b7ee2SBrad BishopPACKAGECONFIG[virglrenderer] = "--enable-virglrenderer,--disable-virglrenderer,virglrenderer"
1561a4b7ee2SBrad Bishop# spice will be in meta-networking layer
1571a4b7ee2SBrad BishopPACKAGECONFIG[spice] = "--enable-spice,--disable-spice,spice"
1581a4b7ee2SBrad Bishop# usbredir will be in meta-networking layer
1591a4b7ee2SBrad BishopPACKAGECONFIG[usb-redir] = "--enable-usb-redir,--disable-usb-redir,usbredir"
160c342db35SBrad BishopPACKAGECONFIG[snappy] = "--enable-snappy,--disable-snappy,snappy"
161eb8dc403SDave Cobbley
162eb8dc403SDave CobbleyINSANE_SKIP_${PN} = "arch"
163c342db35SBrad Bishop
164c342db35SBrad BishopFILES_${PN} += "${datadir}/icons"
165