SUMMARY="A standalone port of Mednafen NGP to libretro"
DESCRIPTION="This is a standalone port of Mednafen NGP to libretro, a SNK \
Neo Geo Pocket emulator. It is itself a fork of NeoPop."
HOMEPAGE="https://mednafen.github.io/documentation/ngp.html"
COPYRIGHT="2005-2018 Forgotten, the Mednafen team, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="f7c393184e5228c3d3807ee74c951c4c549107d8"
SOURCE_URI="https://github.com/libretro/beetle-ngp-libretro/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="0b30eefcd62a956534f02a51357e2af073a6d150e0d7ad563ec351d1b2d7465b"
SOURCE_FILENAME="libretro-mednafen-ngp-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="beetle-ngp-libretro-$srcGitRev"
ADDITIONAL_FILES="mednafen_ngp_libretro.info.in"

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

PROVIDES="
	mednafen_ngp_libretro$secondaryArchSuffix = $portVersion
	addon:mednafen_ngp_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_ngp_libretro.info.in \
		> mednafen_ngp_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_ngp_libretro.info \
		mednafen_ngp_libretro.so
}
