SUMMARY="A port of Mesen, a Nintendo Entertainment System emulator to the \
libretro API"
DESCRIPTION="Mesen a relatively new but highly accurate NES emulator. With \
great accuracy comes great resource requirements (relative to other NES \
emulators, at least), so this core is not a great choice for weak mobile \
devices or other low-power/embedded platforms. However, it is the best choice \
for users who seek the most accurate reproduction of the NES hardware. Mesen \
also supports some fun enhancements, such as HD sprite replacement packs."
HOMEPAGE="https://www.mesen.ca/"
COPYRIGHT="2016-2021 Sour, the libretro team"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="094d82bf724448426acbaad45e83bc38994e32f6"
SOURCE_URI="https://github.com/libretro/Mesen/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="206a0fc5dff2fb8795a6281582f7033aefdbef034ccba98f7cc4d0b5e58a7d03"
SOURCE_FILENAME="Mesen-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="Mesen-$srcGitRev"
ADDITIONAL_FILES="mesen_libretro.info.in"

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

PROVIDES="
	mesen_libretro$secondaryArchSuffix = $portVersion
	addon:mesen_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/mesen_libretro.info.in \
		> mesen_libretro.info

	make GIT_VERSION=${srcGitRev:0:7} $jobArgs -C Libretro/
}

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