SUMMARY="A port of Snes9x, a Nintendo Super NES emulator to the libretro API"
DESCRIPTION="Snes9x is one of the very first and most well-known Super NES \
emulators. It has been around since 1996, has always managed to remain as \
portable as can be, and while not the most accurate Super NES emulator on the \
market, found a great balance between performance and accuracy. This is the \
libretro port of the development version of Snes9x."
HOMEPAGE="https://www.snes9x.com/"
COPYRIGHT="2007-2020 the Snes9x team, the libretro team"
LICENSE="Snes9x
	GNU GPL v2
	GNU LGPL v2.1"
REVISION="1"
srcGitRev="fb93aedd612537e233c6872a5d7ebe65e8169ade"
SOURCE_URI="https://github.com/libretro/snes9x/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="a9d1d690850375e2720597daa763d0e6644c4d20cc2eee0d0d4ec07d3497bdcd"
SOURCE_FILENAME="snes9x-libretro-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="snes9x-$srcGitRev"
ADDITIONAL_FILES="snes9x_libretro.info.in"

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

PROVIDES="
	snes9x_libretro$secondaryArchSuffix = $portVersion
	addon:snes9x_libretro$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	retroarch$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libz${secondaryArchSuffix}
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		$portDir/additional-files/snes9x_libretro.info.in \
		> snes9x_libretro.info
	cd libretro
	make $jobArgs
}

INSTALL()
{
	install -m 0755 -d "$docDir"
	install -m 0644 -t "$docDir" README.md \
		docs/changes.txt docs/control-inputs.txt docs/controls.txt \
		docs/porting.html docs/snapshots.txt docs/portsofsnes9x.txt
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro \
		snes9x_libretro.info \
		libretro/snes9x_libretro.so
}
