SUMMARY="A port of Gearsystem, a Sega 8bit emulator to the libretro API"
DESCRIPTION="Gearsystem is a Sega Master System / Game Gear / SG-1000 emulator \
written in C++. It features highly accurate CPU emulation, accurate \
instruction and memory timing."
HOMEPAGE="http://www.ignaciosanchez.me/projects/gearsystem/"
COPYRIGHT="2012-2021 Ignacio Sánchez, the libretro team"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="a5fba108cce0abac4bcb431b9da628cea5e61411"
SOURCE_URI="https://github.com/drhelius/Gearsystem/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="6261006ecd2a7ac128cd348428825935e0e23342bf8a4a1db15e207272512e8d"
SOURCE_FILENAME="gearsystem-libretro-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="Gearsystem-$srcGitRev"
ADDITIONAL_FILES="gearsystem_libretro.info.in"

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

PROVIDES="
	gearsystem_libretro$secondaryArchSuffix = $portVersion
	addon:gearsystem_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/gearsystem_libretro.info.in \
		> gearsystem_libretro.info
	cd platforms/libretro
	make $jobArgs
}

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