SUMMARY="A port of MelonDS, a Nintendo DS emulator to the libretro API"
DESCRIPTION="MelonDS is a Nintendo DS emulator with emphasis on performance. \
It is attempting to do things 'right and fast' according to its original \
author. This is the libretro core based of MelonDS."
HOMEPAGE="http://melonds.kuribo64.net/"
COPYRIGHT="2016-2020 StapleButter, the libretro team"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="1ad65728476d7b9594c4ff91a1ba60460a0a30e7"
SOURCE_URI="https://github.com/libretro/melonDS/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="485ab6f64d31b800bfb7c2484140bc09e2542ca3048bfaceef5f3c6de977fb51"
SOURCE_FILENAME="melonds-libretro-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="melonDS-$srcGitRev"
ADDITIONAL_FILES="melonds_libretro.info.in"

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

PROVIDES="
	melonds_libretro$secondaryArchSuffix = $portVersion
	addon:melonds_libretro$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	retroarch$secondaryArchSuffix
	"

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

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		${portDir}/additional-files/melonds_libretro.info.in \
		> melonds_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 \
		melonds_libretro.info \
		melonds_libretro.so
}
