SUMMARY="A standalone port of Mednafen PC-FX to libretro"
DESCRIPTION="This is a standalone port of Mednafen PC-FX to libretro, an NEC \
PC-FX emulator. It is one of the original emulators included in Mednafen."
HOMEPAGE="https://mednafen.github.io/documentation/pcfx.html"
COPYRIGHT="2005-2018 Forgotten, the Mednafen team, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="6d2b11e17ad5a95907c983e7c8a70e75508c2d41"
SOURCE_URI="https://github.com/libretro/beetle-pcfx-libretro/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="b5a0d170aa1944aa47726e42c230550294d44ecd5565d460bc943a68dc781b5a"
SOURCE_FILENAME="libretro-mednafen-pcfx-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="beetle-pcfx-libretro-$srcGitRev"
ADDITIONAL_FILES="mednafen_pcfx_libretro.info.in"

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

PROVIDES="
	mednafen_pcfx_libretro$secondaryArchSuffix = $portVersion
	addon:mednafen_pcfx_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_pcfx_libretro.info.in \
		> mednafen_pcfx_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_pcfx_libretro.info \
		mednafen_pcfx_libretro.so
}
