SUMMARY="A port of bsnes to the libretro architecture"
DESCRIPTION="bsnes is an accurate SNES emulator, but can also emulate the NES, \
Game Boy (DMG), Game Boy Color, and Game Boy Advance. This is a libretro \
core based off the latest version of bsnes, following its complete rewrite \
by its original author Near."
HOMEPAGE="https://bsnes.dev/"
COPYRIGHT="2014-2021 Near, the libretro team"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="6fc6bf14a39d32dab69c4f9687a81df26d412758"
SOURCE_URI="https://github.com/bsnes-emu/bsnes/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="ce1eaf0625ffd73d146aa164baade8fd4fb6e03c742ac0d6f3b2d1e4288646eb"
SOURCE_FILENAME="bsnes-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="bsnes-$srcGitRev"
ADDITIONAL_FILES="bsnes_libretro.info.in"

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

PROVIDES="
	bsnes_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/bsnes_libretro.info.in > bsnes_libretro.info
	cd bsnes
	make $jobArgs target=libretro
}

INSTALL()
{
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro bsnes/out/bsnes_libretro.so bsnes_libretro.info
}
