SUMMARY="An alternative client for id Softwares Quake II"
DESCRIPTION="Yamagi Quake II is an alternative client for id Softwares Quake \
II. Our goal is to provide the best Quake II experience possible, we strive \
to preserve the gameplay as it was back in 1997. Thus we aim mostly for bug \
fixes, stability and gentle enhancements were appropriate.

Features
Yamagi Quake II has a lot of unique features. The most notables ones are:

* A modern OpenGL 3.2 renderer, providing a greatly enhanced look and feel. \
The original OpenGL 1.4 and even the Software renderers are still supported. \
Both 3D accelerated renderers support anisotropic filtering and multisampling \
anti aliasing.
* Full support for widescreen displays and arbitrary resolutions. \
The HUD can be scaled to be readable on high resolutions.
* Support for surround sound, from stereo up to 7.1 channels and even HRTF. \
The background music can be played from OGG/Vorbis files, a CD drive is no \
longer necessary.
* A rewritten savegame system. Yamagi Quake II savegames are completely \
reliable and backward compatible between releases.
* Highly precise timings. For example, on a flat panel display with a 59.95 \
hertz refresh rate and vertical synchronisation (VSync) enabled Yamagi Quake \
II is running at exactly 59.95 frames per second.
* In comparison with the original client over 1.500 bugs were fixed. The \
Yamagi Quake II client is very well tested and stable. The dedicated server \
is able to run for weeks without a single restart. Last but not least the \
code is fully 64 bit clean and highly portable."
HOMEPAGE="https://www.yamagi.org/quake2/"
COPYRIGHT="OpenArena Team"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://deponie.yamagi.org/quake2/quake2-$portVersion.tar.xz"
CHECKSUM_SHA256="c7524567bf1aa6045f25619bea6e4fd9066284b3fb81863b581fb44f4f47ff65"
SOURCE_DIR="quake2-$portVersion"
PATCHES="yamagi_quake2-$portVersion.patchset"
ADDITIONAL_FILES="yamagi_quake2.rdef.in"

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

PROVIDES="
	yamagi_quake2$secondaryArchSuffix = $portVersion
	app:Quake2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake -DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir ..
	make $jobArgs
}

INSTALL()
{
	cd build/release
	mkdir -p $appsDir/Quake2/baseq2
	cp quake2 $appsDir/Quake2/Quake2
	cp q2ded $appsDir/Quake2/Quake2_dedicated
	cp  *.so $appsDir/Quake2/
	cp baseq2/game.so $appsDir/Quake2/baseq2/

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

	addResourcesToBinaries yamagi_quake2.rdef $appsDir/Quake2/Quake2
	addAppDeskbarSymlink $appsDir/Quake2/Quake2
}
