SUMMARY="A port of SameBoy, a Game Boy / GB Color emulator to the libretro API"
DESCRIPTION="A port of the highly accurate Game Boy emulator, SameBoy, to \
libretro. This core has the highest accuracy of any Game Boy emulator and \
also supports a variety of fun features and improvements. While its \
requirements are higher than most other Game Boy cores, it is a good first \
choice for devices strong enough to run it full speed."
HOMEPAGE="https://sameboy.github.io/downloads/"
COPYRIGHT="2016-2021 LIJI32, the libretro team"
LICENSE="MIT"
REVISION="1"
srcGitRev="685c6c8b497260f53a984d5c4398ef2b25253104"
SOURCE_URI="https://github.com/libretro/SameBoy/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="4cdfa28a9b73949fa94b6692e792a1d61c6bf915929f2f790d7f0799deb85876"
SOURCE_FILENAME="SameBoy-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="SameBoy-$srcGitRev"
ADDITIONAL_FILES="sameboy_libretro.info.in"

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

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

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

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

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