SUMMARY="Port of Mupen64plus Next, a Nintendo 64 emulator to the libretro API"
DESCRIPTION="Mupen64Plus Next is a cross-platform plugin-based N64 emulator \
which is capable of accurately playing many games. This is the libretro core."
HOMEPAGE="https://mupen64plus.org/"
COPYRIGHT="2001-2020 Hacktarux, richard42g, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="b4024d75597da162bbc7cb693b8cef0d6da75105"
SOURCE_URI="https://github.com/libretro/mupen64plus-libretro-nx/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="44855e051ed94a8a13d08acc527583a114a0fdd345c248be771fe6d69da4ad89"
SOURCE_FILENAME="mupen64plus-libretro-nx-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="mupen64plus-libretro-nx-$srcGitRev"
ADDITIONAL_FILES="mupen64plus_next_libretro.info.in"

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

PROVIDES="
	mupen64plus_next_libretro$secondaryArchSuffix = $portVersion
	addon:mupen64plus_next_libretro$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	retroarch$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:nasm
	"

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		$portDir/additional-files/mupen64plus_next_libretro.info.in \
		> mupen64plus_next_libretro.info
	make $jobArgs
}

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