SUMMARY="Flycast is a multiplatform Sega Dreamcast emulator"
DESCRIPTION="Flycast is a cross-platform SEGA Dreamcast, Naomi and AtomisWave \
emulator based off NullDC. It can accurately play several games and is in \
active development."
HOMEPAGE="https://github.com/libretro/flycast"
COPYRIGHT="2013-2021, drk||Raziel, PsyMan, gb_away, the libretro team"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="041297cc6c266b1185a4414271a10732c946239c"
SOURCE_URI="https://github.com/libretro/flycast/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="ca8b8335f4d10bcfa4b65e5415240aec32194dd2ccc1e21e315a05a27aaca686"
SOURCE_FILENAME="flycast-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="flycast-$srcGitRev"
ADDITIONAL_FILES="flycast_libretro.info.in"

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

PROVIDES="
	flycast_libretro$secondaryArchSuffix = $portVersion
	addon:flycast_libretro$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	retroarch$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		$portDir/additional-files/flycast_libretro.info.in \
		> flycast_libretro.info
	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 \
		flycast_libretro.info \
		flycast_libretro.so
}
