SUMMARY="A port of Nestopia, a Nintendo Entertainment System emulator to the \
libretro API"
DESCRIPTION="Nestopia is one of the most accurate NES emulators available \
and is able to run 99% of commercial games close to perfection. This is the \
libretro port of the emulator."
HOMEPAGE="http://nestopia.sourceforge.net/"
COPYRIGHT="2012-2020 Martin Freij, 0ldSk00l, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="21e2cec7a13f0a09f493637de289e59386e2fd36"
SOURCE_URI="https://github.com/libretro/nestopia/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="f35bcb703229a96068bb159fd79fa7ff8f5052d43908a47a208315bb4253e822"
SOURCE_FILENAME="nestopia-libretro-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="nestopia-$srcGitRev"
ADDITIONAL_FILES="nestopia_libretro.info.in"

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

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

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

INSTALL()
{
	install -m 0755 -d "$docDir"
	install -m 0644 -t "$docDir" COPYING NstDatabase.xml
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro \
		nestopia_libretro.info \
		libretro/nestopia_libretro.so
}
