1SUMMARY = "Fast open source processor emulator"
2HOMEPAGE = "http://qemu.org"
3LICENSE = "GPLv2 & LGPLv2.1"
4DEPENDS = "glib-2.0 zlib pixman"
5RDEPENDS_${PN}_class-target += "bash"
6
7require qemu-targets.inc
8inherit pkgconfig bluetooth
9BBCLASSEXTEND = "native nativesdk"
10
11# QEMU_TARGETS is overridable variable
12QEMU_TARGETS ?= "arm aarch64 i386 mips mipsel mips64 mips64el ppc riscv32 riscv64 sh4 x86_64"
13
14EXTRA_OECONF = " \
15    --prefix=${prefix} \
16    --bindir=${bindir} \
17    --includedir=${includedir} \
18    --libdir=${libdir} \
19    --mandir=${mandir} \
20    --datadir=${datadir} \
21    --docdir=${docdir}/${BPN} \
22    --sysconfdir=${sysconfdir} \
23    --libexecdir=${libexecdir} \
24    --localstatedir=${localstatedir} \
25    --with-confsuffix=/${BPN} \
26    --disable-strip \
27    --disable-werror \
28    --target-list=${@get_qemu_target_list(d)} \
29    --extra-cflags='${CFLAGS}' \
30    ${PACKAGECONFIG_CONFARGS} \
31    "
32EXTRA_OECONF_append_class-native = " --python=python2.7"
33
34EXTRA_OEMAKE_append_class-native = " LD='${LD}' AR='${AR}' OBJCOPY='${OBJCOPY}' LDFLAGS='${LDFLAGS}'"
35
36LDFLAGS_append_class-native = " -fuse-ld=bfd"
37
38export LIBTOOL="${HOST_SYS}-libtool"
39
40B = "${WORKDIR}/build"
41
42do_configure_prepend_class-native() {
43	# Append build host pkg-config paths for native target since the host may provide sdl
44	BHOST_PKGCONFIG_PATH=$(PATH=/usr/bin:/bin pkg-config --variable pc_path pkg-config || echo "")
45	if [ ! -z "$BHOST_PKGCONFIG_PATH" ]; then
46		export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$BHOST_PKGCONFIG_PATH
47	fi
48}
49
50do_configure() {
51    ${S}/configure ${EXTRA_OECONF}
52}
53
54do_install () {
55	export STRIP=""
56	oe_runmake 'DESTDIR=${D}' install
57}
58
59# The following fragment will create a wrapper for qemu-mips user emulation
60# binary in order to work around a segmentation fault issue. Basically, by
61# default, the reserved virtual address space for 32-on-64 bit is set to 4GB.
62# This will trigger a MMU access fault in the virtual CPU. With this change,
63# the qemu-mips works fine.
64# IMPORTANT: This piece needs to be removed once the root cause is fixed!
65do_install_append() {
66	if [ -e "${D}/${bindir}/qemu-mips" ]; then
67		create_wrapper ${D}/${bindir}/qemu-mips \
68			QEMU_RESERVED_VA=0x0
69	fi
70}
71# END of qemu-mips workaround
72
73PACKAGECONFIG ??= " \
74    fdt sdl kvm \
75    ${@bb.utils.filter('DISTRO_FEATURES', 'alsa xen', d)} \
76"
77PACKAGECONFIG_class-native ??= "fdt alsa kvm"
78PACKAGECONFIG_class-nativesdk ??= "fdt sdl kvm"
79
80# Handle distros such as CentOS 5 32-bit that do not have kvm support
81PACKAGECONFIG_class-native_remove = "${@'kvm' if not os.path.exists('/usr/include/linux/kvm.h') else ''}"
82
83# Disable kvm on targets that do not support it
84PACKAGECONFIG_remove_darwin = "kvm"
85PACKAGECONFIG_remove_mingw32 = "kvm"
86
87PACKAGECONFIG[sdl] = "--enable-sdl --with-sdlabi=2.0,--disable-sdl,libsdl2"
88PACKAGECONFIG[virtfs] = "--enable-virtfs --enable-attr,--disable-virtfs,libcap attr,"
89PACKAGECONFIG[aio] = "--enable-linux-aio,--disable-linux-aio,libaio,"
90PACKAGECONFIG[xfs] = "--enable-xfsctl,--disable-xfsctl,xfsprogs,"
91PACKAGECONFIG[xen] = "--enable-xen,--disable-xen,xen,xen-libxenstore xen-libxenctrl xen-libxenguest"
92PACKAGECONFIG[vnc-sasl] = "--enable-vnc --enable-vnc-sasl,--disable-vnc-sasl,cyrus-sasl,"
93PACKAGECONFIG[vnc-jpeg] = "--enable-vnc --enable-vnc-jpeg,--disable-vnc-jpeg,jpeg,"
94PACKAGECONFIG[vnc-png] = "--enable-vnc --enable-vnc-png,--disable-vnc-png,libpng,"
95PACKAGECONFIG[libcurl] = "--enable-curl,--disable-curl,libcurl,"
96PACKAGECONFIG[nss] = "--enable-smartcard,--disable-smartcard,nss,"
97PACKAGECONFIG[curses] = "--enable-curses,--disable-curses,ncurses,"
98PACKAGECONFIG[gtk+] = "--enable-gtk --with-gtkabi=3.0 --enable-vte,--disable-gtk --disable-vte,gtk+3 vte"
99PACKAGECONFIG[libcap-ng] = "--enable-cap-ng,--disable-cap-ng,libcap-ng,"
100PACKAGECONFIG[ssh2] = "--enable-libssh2,--disable-libssh2,libssh2,"
101PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt,"
102PACKAGECONFIG[nettle] = "--enable-nettle,--disable-nettle,nettle"
103PACKAGECONFIG[libusb] = "--enable-libusb,--disable-libusb,libusb1"
104PACKAGECONFIG[fdt] = "--enable-fdt,--disable-fdt,dtc"
105PACKAGECONFIG[alsa] = "--audio-drv-list='oss alsa',,alsa-lib"
106PACKAGECONFIG[glx] = "--enable-opengl,--disable-opengl,mesa"
107PACKAGECONFIG[lzo] = "--enable-lzo,--disable-lzo,lzo"
108PACKAGECONFIG[numa] = "--enable-numa,--disable-numa,numactl"
109PACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls"
110PACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2"
111PACKAGECONFIG[bluez] = "--enable-bluez,--disable-bluez,${BLUEZ}"
112PACKAGECONFIG[libiscsi] = "--enable-libiscsi,--disable-libiscsi"
113PACKAGECONFIG[kvm] = "--enable-kvm,--disable-kvm"
114PACKAGECONFIG[virglrenderer] = "--enable-virglrenderer,--disable-virglrenderer,virglrenderer"
115# spice will be in meta-networking layer
116PACKAGECONFIG[spice] = "--enable-spice,--disable-spice,spice"
117# usbredir will be in meta-networking layer
118PACKAGECONFIG[usb-redir] = "--enable-usb-redir,--disable-usb-redir,usbredir"
119
120INSANE_SKIP_${PN} = "arch"
121