SUMMARY="A Nintendo Game Boy Advance emulator using the libretro API"
DESCRIPTION="mGBA is a Nintendo Game Boy Advance emulator with great accuracy. \
It also now emulates classic Game Boy / Game Boy Color systems. This is the \
libretro core version of mGBA, for use with RetroArch."
HOMEPAGE="https://mgba.io/"
COPYRIGHT="2014-2018 Endrift, the libretro team"
LICENSE="MPL v2.0"
REVISION="1"
srcGitRev="c33adfa66b4b3f72c939c27ff0668ebeada75086"
SOURCE_URI="https://github.com/libretro/mgba/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="25b17766b47c6f74b01df5b9cb6b5d70616eae558fe25c1704de436ce87712ad"
SOURCE_FILENAME="libretro-mgba-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="mgba-$srcGitRev"
ADDITIONAL_FILES="mgba_libretro.info.in"

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

PROVIDES="
	mgba_libretro$secondaryArchSuffix = $portVersion
	addon:mgba_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/mgba_libretro.info.in \
		> mgba_libretro.info
	make -f Makefile.libretro $jobArgs
}

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