SUMMARY="A standalone port of Mednafen Saturn to libretro"
DESCRIPTION="This is a standalone port of Mednafen Saturn to libretro, a Sega \
Saturn emulator. It is one of the original emulators included in Mednafen."
HOMEPAGE="https://mednafen.github.io/documentation/ss.html"
COPYRIGHT="2005-2020 Forgotten, the Mednafen team, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="e6ba71f8bcc647b646d94dec812b24d00c41cf3f"
SOURCE_URI="https://github.com/libretro/beetle-saturn-libretro/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="4e47ba49ac1a6609285921831bf8d91c48ece1293f949ac602f9f29e172b06b4"
SOURCE_FILENAME="libretro-mednafen-saturn-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="beetle-saturn-libretro-$srcGitRev"
ADDITIONAL_FILES="mednafen_saturn_libretro.info.in"

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

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

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

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

INSTALL()
{
	install -m 0755 -d "$docDir"
	install -m 0644 -t "$docDir" COPYING README.md
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro \
		mednafen_saturn_libretro.info \
		mednafen_saturn_libretro.so
}
