SUMMARY="A portable Nintendo 64 emulator"
DESCRIPTION="Mupen64 is a portable Nintendo 64 emulator. It emulates most Nintendo \
64 games perfectly enough that they are playable."
HOMEPAGE="http://mupen64.emulation64.com/"
COPYRIGHT="2005 Hacktarux & Azimer"
SOURCE_URI="http://mupen64.emulation64.com/files/0.5/mupen64_src-0.5.tar.bz2"
CHECKSUM_SHA256="1b8e4188ab7a94d8125b77aed8725ee348c24818622b881adfe16be510487dfd"
SOURCE_DIR="mupen64_src-$portVersion"
PATCHES="mupen64-$portVersion.patch"
REVISION="1"
LICENSE="GNU GPL v2"

DISABLE_SOURCE_PACKAGE="YES" # bug in HaikuPorter that makes this fail

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"
else
    ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	mupen64$secondaryArchSuffix = $portVersion
	cmd:mupen64_nogui = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:libgl$secondaryArchSuffix
	lib:libsdl_1.2$secondaryArchSuffix >= 0.11.4
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	devel:libgl$secondaryArchSuffix
	devel:libsdl_1.2$secondaryArchSuffix >= 0.11.4
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:pkg_config$secondaryArchSuffix
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	"

BUILD()
{
	export WITH_HOME="$prefix/"
	make -e $jobArgs \
		mupen64_nogui \
		plugins/mupen64_input.so \
		plugins/mupen64_hle_rsp_azimer.so \
		plugins/dummyaudio.so \
		plugins/jttl_audio.so \
		plugins/mupen64_soft_gfx.so
}

INSTALL()
{
	mkdir -p $prefix $prefix/bin $prefix/data/mupen64
	
	cp mupen64_nogui $prefix/bin
	cp mupen64.ini $prefix/data/mupen64
	cp -rv lang $prefix/data/mupen64
	cp -rv plugins $prefix/data/mupen64
	cp -rv doc $prefix/data/mupen64
}
