SUMMARY="QEMU is a generic and open source machine emulator and virtualizer."
DESCRIPTION="
QEMU is a generic and open source machine emulator and virtualizer.
"
HOMEPAGE="http://wiki.qemu.org/"
SRC_URI="git+https://github.com/mmlr/qemu-haiku.git#e57972be33c91222a580d47c68b135aa8fa7b4c3"
COPYRIGHT="2003-2008 Fabrice Bellard"
LICENSE="GNU GPL v2"
REVISION="1"
ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PATCHES="qemu-1.7.0.patchset"

PROVIDES="
	qemu$secondaryArchSuffix = $portVersion
	cmd:qemu$secondaryArchSuffix = $portVersion
	cmd:qemu_img$secondaryArchSuffix = $portVersion
	cmd:qemu_io$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 >= $haikuVersion
	lib:libz$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	glib2$secondaryArchSuffix >= 2.12
	pixman$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libz$secondaryArchSuffix
	devel:libfdt$secondaryArchSuffix
	glib2${secondaryArchSuffix}_devel >= 2.12
	pixman${secondaryArchSuffix}_devel
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:pod2man
	cmd:python
	"

BUILD()
{
	chmod +x configure
	./configure --prefix=$prefix --mandir=$manDir --datadir=$dataDir/qemu \
		--docdir=$docDir --bindir=$binDir --libdir=$libDir \
		--sysconfdir=$settingsDir/qemu
	make $jobArgs
}

INSTALL()
{
	make install

	# provide convenience symlink to just "qemu"
	ln -s qemu-system-i386 $binDir/qemu

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