SUMMARY="An optimized VisualBoyAdvance-M core for the libretro API"
DESCRIPTION="VBA-Next is a fork of VBA-M, itself a fork of VisualBoyAdvance, \
a popular Nintendo Game Boy Advance emulator. VBA Next was developed by the \
libretro team as an optimized version of VBA-M."
HOMEPAGE="https://github.com/libretro/vba-next"
COPYRIGHT="2001-2018 Forgotten, the VBA-M team , the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="b218f48bb27b5d3885fa4076ff325922b5acd817"
SOURCE_URI="https://github.com/libretro/vba-next/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="9aec4b44da688ab4f13c4c960d936a5ff793b5bb5c58446bf2b1aea128de8619"
SOURCE_FILENAME="libretro-vba-next-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="vba-next-$srcGitRev"
ADDITIONAL_FILES="vba_next_libretro.info.in"

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

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

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