SUMMARY="A generic and open source machine emulator and virtualizer"
DESCRIPTION="QEMU is a generic and open source machine emulator and virtualizer.

QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a \
different machine (e.g. your own PC). By using dynamic translation, it \
achieves very good performance."
HOMEPAGE="http://wiki.qemu.org/"
COPYRIGHT="2003-2014 Fabrice Bellard"
LICENSE="GNU GPL v2"
REVISION="3"
srcGitRev="d1b55862305d1eac5c7ca7cc56ec379bbc452d74"
SOURCE_URI="https://github.com/mmlr/qemu-haiku/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="014175cedf18d09f9b004672394f2c1ac760eb086fbfde83485c4493d7024c89"
SOURCE_DIR="qemu-haiku-$srcGitRev"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	qemu$secondaryArchSuffix = $portVersion
	cmd:qemu$secondaryArchSuffix = $portVersion
	cmd:qemu_img$secondaryArchSuffix = $portVersion
	cmd:qemu_io$secondaryArchSuffix = $portVersion
	cmd:qemu_system_aarch64$secondaryArchSuffix = $portVersion
	cmd:qemu_system_alpha$secondaryArchSuffix = $portVersion
	cmd:qemu_system_arm$secondaryArchSuffix = $portVersion
	cmd:qemu_system_cris$secondaryArchSuffix = $portVersion
	cmd:qemu_system_i386$secondaryArchSuffix = $portVersion
	cmd:qemu_system_lm32$secondaryArchSuffix = $portVersion
	cmd:qemu_system_m68k$secondaryArchSuffix = $portVersion
	cmd:qemu_system_microblaze$secondaryArchSuffix = $portVersion
	cmd:qemu_system_microblazeel$secondaryArchSuffix = $portVersion
	cmd:qemu_system_mips$secondaryArchSuffix = $portVersion
	cmd:qemu_system_mips64$secondaryArchSuffix = $portVersion
	cmd:qemu_system_mips64el$secondaryArchSuffix = $portVersion
	cmd:qemu_system_mipsel$secondaryArchSuffix = $portVersion
	cmd:qemu_system_moxie$secondaryArchSuffix = $portVersion
	cmd:qemu_system_or32$secondaryArchSuffix = $portVersion
	cmd:qemu_system_ppc$secondaryArchSuffix = $portVersion
	cmd:qemu_system_ppc64$secondaryArchSuffix = $portVersion
	cmd:qemu_system_ppcemb$secondaryArchSuffix = $portVersion
	cmd:qemu_system_s390x$secondaryArchSuffix = $portVersion
	cmd:qemu_system_sh4$secondaryArchSuffix = $portVersion
	cmd:qemu_system_sh4eb$secondaryArchSuffix = $portVersion
	cmd:qemu_system_sparc$secondaryArchSuffix = $portVersion
	cmd:qemu_system_sparc64$secondaryArchSuffix = $portVersion
	cmd:qemu_system_unicore32$secondaryArchSuffix = $portVersion
	cmd:qemu_system_x86_64$secondaryArchSuffix = $portVersion
	cmd:qemu_system_xtensa$secondaryArchSuffix = $portVersion
	cmd:qemu_system_xtensaeb$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix >= 0.38
	lib:libintl$secondaryArchSuffix
	lib:libpixman_1$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libfdt$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix >= 0.38
	devel:libpixman_1${secondaryArchSuffix}
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:pod2man
	cmd:python
	"

BUILD()
{
	runConfigure --omit-buildspec ./configure --disable-stack-protector
	make $jobArgs
}

INSTALL()
{
	make install

	# provide convenience symlink to just "qemu"
	if [ $effectiveTargetArchitecture == x86_64 ]; then
		ln -s qemu-system-x86_64 $binDir/qemu
	else
		ln -s qemu-system-i386 $binDir/qemu
	fi

	# Remove empty config file.
	rm $settingsDir/target-x86_64.conf
}
