SUMMARY="Free 3D go-kart racing game"
DESCRIPTION="a 3D open-source arcade racer with a variety of customized characters, \
tracks, and various modes to play. Our aim is to create a game that is more fun than \
realistic, and provide an enjoyable experience for all ages.

Discover the mystery of an underwater world, or drive through the jungles of Val Verde \
and visit the famous Cocoa Temple. Race underground or in a spaceship, through a rural \
farmland or a strange alien planet. Or rest under the palm trees on the beach, watching \
the other karts overtake you. But don't eat the bananas! Watch for bowling balls, \
plungers, bubble gum, and cakes thrown by your opponents.

You can do a single race against other karts, compete in one of several Grand Prix, \
or try to beat the high score in time trials on your own. Play battle mode against \
the computer or your friends, and more! For a greater challenge, race online against \
players from all over the world and prove your racing skills!"
HOMEPAGE="https://supertuxkart.net"
COPYRIGHT="2021 SuperTuxKart Development Team"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/supertuxkart/stk-code/releases/download/$portVersion/supertuxkart-$portVersion-src.tar.xz"
CHECKSUM_SHA256="eeabeb0d9801688a218f6f0a76ea3546a46a322ccaca9a258148ecacfe083ffd"
SOURCE_DIR="SuperTuxKart-$portVersion-src"
PATCHES="supertuxkart-$portVersion.patchset"
ADDITIONAL_FILES="supertuxkart.rdef.in"

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

PROVIDES="
	supertuxkart$secondaryArchSuffix = $portVersion
	app:SuperTuxKart$secondaryArchSuffix
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libenet$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libharfbuzz$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libsdl2_2.0$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libsquish$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libenet$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix >= 2.2
	devel:libharfbuzz$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libsdl2$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libsquish$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build

	cmake .. \
		-DCMAKE_BUILD_TYPE=STKRelease \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DSTK_INSTALL_DATA_DIR=$dataDir/SuperTuxKart \
		-DSTK_INSTALL_BINARY_DIR=$appsDir \
		-DBUILD_RECORDER=OFF \
		-DBUILD_SHARED_LIBS=OFF \
		-DUSE_WIIUSE=OFF

	make $jobArgs
}

INSTALL()
{
	cd build
	make install
	rm -rf $prefix/share
	mv $appsDir/supertuxkart $appsDir/SuperTuxKart

	local APP_SIGNATURE="application/x-vnd.supertuxkart"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/supertuxkart.rdef.in > $sourceDir/supertuxkart.rdef

	addResourcesToBinaries $sourceDir/supertuxkart.rdef $appsDir/SuperTuxKart
	addAppDeskbarSymlink $appsDir/SuperTuxKart
}
