SUMMARY="A port of Stella, an Atari 2600 VCS emulator to the libretro API"
DESCRIPTION="Stella is a multi-platform Atari 2600 VCS emulator originally \
developed for Linux by Bradford W. Mott, and currently maintained by Stephen \
Anthony. The Atari 2600 Video Computer System (VCS), introduced in 1977, was \
the most popular home video game system of the early 1980's. This is a fork \
of the more recent version of Stella, updated for accuracy."
HOMEPAGE="https://stella-emu.github.io/"
COPYRIGHT="1995-2021 the Stella team, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="f999bd685af24f1ebc705e146d33b46a8fb0beac"
SOURCE_URI="https://github.com/stella-emu/stella/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="bdbc7fe4a906f7712f2fd5bffdca1d29da4660eebc14a35268c1780beb74ccdb"
SOURCE_FILENAME="stella-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="stella-$srcGitRev"
ADDITIONAL_FILES="stella_libretro.info.in"

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

PROVIDES="
	stella_libretro$secondaryArchSuffix = $portVersion
	addon:stella_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/stella_libretro.info.in \
		> stella_libretro.info
	cd src/libretro
	make -f Makefile platform="unix" -j4 CC="gcc" CXX="g++" $jobArgs
}

INSTALL()
{
	install -m 0755 -d "$docDir"
	install -m 0644 -t "$docDir" README.md
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro \
		stella_libretro.info \
		src/libretro/stella_libretro.so
}
