SUMMARY="Optimized/rewritten Nintendo 64 emulator for Libretro, based on Mupen64 Plus"
DESCRIPTION="ParaLLEl is a Nintendo 64 emulator using Low Level Emulation. \
This offers much better accuracy than any HLE implementation."
HOMEPAGE="https://github.com/libretro/parallel-n64"
COPYRIGHT="2019-2020 the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="0a67445ce63513584d92e5c57ea87efe0da9b3bd"
SOURCE_URI="https://github.com/libretro/parallel-n64/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="141205571de2a5c0646ee4d33d32e71d86c8f4a75e43aba73c103c62cc15affd"
SOURCE_FILENAME="parallel-n64-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="parallel-n64-$srcGitRev"
ADDITIONAL_FILES="parallel_n64_libretro.info.in"

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

PROVIDES="
	parallel_n64_libretro$secondaryArchSuffix = $portVersion
	addon:parallel_n64_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:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		$portDir/additional-files/parallel_n64_libretro.info.in \
		> parallel_n64_libretro.info
	if [ "$targetArchitecture" = x86_gcc2 ]; then
		ARCH=x86
	elif [ "$targetArchitecture" = x86_64 ]; then
		ARCH=x86_64
	fi
	make WITH_DYNAREC=$ARCH $jobArgs
}

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 \
		parallel_n64_libretro.info \
		parallel_n64_libretro.so
}
