SUMMARY="A standalone port of Mednafen PCE to libretro"
DESCRIPTION="This is a port of Mednafen PCE to libretro, a MEC PC Engine \
and SuperGrafx emulator. This version focuses on accuracy while the  \
PCE Fast version focuses on speed."
HOMEPAGE="https://mednafen.github.io/documentation/pce.html"
COPYRIGHT="2005-2020 Forgotten, the Mednafen team, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="d1fe47b1e8f2a34e890cab0cd76a707e2fb81d6f"
SOURCE_URI="https://github.com/libretro/beetle-pce-libretro/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="0d1482dd3601daf685b6b9c2284fb0206db6dcbc8b60f0ff301a07d14e8abd31"
SOURCE_FILENAME="libretro-mednafen-pce-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="beetle-pce-libretro-$srcGitRev"
ADDITIONAL_FILES="mednafen_pce_libretro.info.in"

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

PROVIDES="
	mednafen_pce_libretro$secondaryArchSuffix = $portVersion
	addon:mednafen_pce_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_pce_libretro.info.in \
		> mednafen_pce_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_pce_libretro.info \
		mednafen_pce_libretro.so
}
