SUMMARY="High speed arctic racing game based on Tux Racer"
DESCRIPTION="Extreme Tux Racer is a racing game in which the player must control Tux across a \
mountainside. Tux can turn left, right, brake, jump, and paddle, and flap his wings. If the \
player presses the brakes and turn buttons, Tux will perform a tight turn. Pressing the paddling \
buttons on the ground gives Tux some additional speed. The paddling stops giving speed and in turn \
slows Tux down when the speedometer turns yellow. Tux can slide off slopes or charge his jumps to \
temporarily launch into midair, during which he can flap his flippers to fly farther and adjust \
his direction left or right. The player can also reset the penguin should he be stuck in any \
part of the course.

This is fork of extremetuxracer, focussing on cross-platform, performance & OpenGL-ES support"
HOMEPAGE="https://github.com/RKSimon/extremetuxracer"
COPYRIGHT="2000-2014 Sunspire Studios"
LICENSE="GNU GPL v2"
REVISION="1"
gitRevision="ff576bc46ea92093b35d708ad657aa994a6789d2"
SOURCE_URI="https://github.com/RKSimon/extremetuxracer/archive/$gitRevision.tar.gz"
CHECKSUM_SHA256="33e2d218800f3e70ecd76cbf975f84f131139ce86851691667a723dfb9a4f6c7"
SOURCE_DIR="extremetuxracer-$gitRevision"
PATCHES="extreme_tuxracer-$portVersion.patchset"
ADDITIONAL_FILES="extreme-tuxracer.rdef.in"

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

PROVIDES="
	extreme_tuxracer$secondaryArchSuffix = $portVersion
	app:ETR$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libSDL2$secondaryArchSuffix
	devel:libSDL2_image$secondaryArchSuffix
	devel:libSDL2_mixer$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	make $jobArgs
}

PATCH()
{
	sed -i "s|/usr/include/freetype2|/system/$relativeIncludeDir -I/system/$relativeIncludeDir/freetype2|" \
		$sourceDir/Makefile
	sed -i "s|/usr/lib|/system/$relativeDevelopLibDir|" \
		$sourceDir/Makefile
	sed -i "s|BIN = etr|BIN = ExtremeTuxRacer|" \
		$sourceDir/Makefile
	sed -i "s|-lSDL2|-lSDL2 -lbe|" \
		$sourceDir/Makefile
}

INSTALL()
{
	mkdir -p $appsDir/ExtremeTuxRacer

	cp -rf {ExtremeTuxRacer,data} $appsDir/ExtremeTuxRacer

	local APP_SIGNATURE="application/x-vnd.extreme-tuxracer"
	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/extreme-tuxracer.rdef.in > $sourceDir/extreme-tuxracer.rdef

	addResourcesToBinaries  $sourceDir/extreme-tuxracer.rdef $appsDir/ExtremeTuxRacer/ExtremeTuxRacer

	addAppDeskbarSymlink $appsDir/ExtremeTuxRacer/ExtremeTuxRacer "Extreme Tux Racer"
}
