SUMMARY="A port of Gearcoleco, a Colecovision emulator to the libretro API"
DESCRIPTION="Gearcoleco is a very accurate cross-platform ColecoVision \
emulator written in C++ that runs on Windows, macOS, Linux, BSD, Raspberry Pi \
and RetroArch."
HOMEPAGE="https://github.com/drhelius/Gearcoleco"
COPYRIGHT="2020-2021 Ignacio Sánchez"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="1046724cb5fe02a588d019a53a2e938e36c620f5"
SOURCE_URI="https://github.com/drhelius/Gearcoleco/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="94d1892aa20d71ba5877b9ff8d09bf426057165b40f3d6a40cd37c1b27dd6374"
SOURCE_FILENAME="Gearcoleco-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="Gearcoleco-$srcGitRev"
ADDITIONAL_FILES="gearcoleco_libretro.info.in"

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

PROVIDES="
	gearcoleco_libretro$secondaryArchSuffix = $portVersion
	addon:gearcoleco_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/gearcoleco_libretro.info.in \
		> gearcoleco_libretro.info

	cd platforms/libretro && make GIT_VERSION=${srcGitRev:0:7} $jobArgs
}

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