SUMMARY="3D Sonic the Hedgehog fangame based on a modified version of Doom Legacy"
DESCRIPTION="Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame\
 built using a modified version of the Doom Legacy port of Doom. SRB2 is \
closely inspired by the original Sonic games from the Sega Genesis, and \
attempts to recreate the design in 3D. It features tons of levels, enemies, \
speed, and quite a lot of the fun that the original Sonic games provided."
HOMEPAGE="https://www.srb2.org/"
COPYRIGHT="1998-2021 Sonic Team Junior"
LICENSE="GNU GPL v2"
REVISION="3"
srcGitRev="60ca690c6d8f6cc670161851e4b2c08983c7d54f"
SOURCE_URI="https://git.do.srb2.org/win8linux/SRB2/-/archive/haiku_release/${srcGitRev}.tar.gz"
CHECKSUM_SHA256="a7512668d90281bdf3d10a55a0b1ff3ade38433bfe292f1c4b83d2f2e6122222"
SOURCE_DIR="SRB2-haiku_release-$srcGitRev"
ADDITIONAL_FILES="srb2.rdef.in"

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

PROVIDES="
	srb2$secondaryArchSuffix = $portVersion
	app:srb2 = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libopenmpt$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	srb2_data
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libexecinfo$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libopenmpt$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_mixer_2.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:git
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd src
	make HAIKU=1 $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir
	cp bin/Release/srb2 $appsDir/srb2

	local APP_SIGNATURE="application/x-vnd.srb2"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/srb2.rdef.in > $sourceDir/srb2.rdef
	addResourcesToBinaries $sourceDir/srb2.rdef $appsDir/srb2
	addAppDeskbarSymlink $appsDir/srb2 "Sonic Robo Blast 2"
}
