SUMMARY="A cross-platform port of Hexen II game"
DESCRIPTION="Hammer of Thyrion (uHexen2) is a cross-platform port of Raven Software's Hexen II source. \
It is based on an older linux port, Anvil of Thyrion. HoT includes countless bug fixes, improved music, \
sound and video modes, opengl improvements, support for many operating systems and architectures, and \
documentation among many others."
HOMEPAGE="https://sourceforge.net/projects/uhexen2/"
COPYRIGHT="2000 Raven Software"
LICENSE="GNU GPL v2"
REVISION="5"
SOURCE_URI="https://sourceforge.net/projects/uhexen2/files/Hammer%20of%20Thyrion/$portVersion/Source/hexen2source-$portVersion.tgz"
CHECKSUM_SHA256="2aa84c141a820f9087850aacf3684a5f71c434428bc57545899eda1b9a28c3e0"
SOURCE_DIR="hexen2source-$portVersion"
SOURCE_URI_2="https://sourceforge.net/projects/uhexen2/files/Hexen2Demo-Nov.1997/hexen2demo_nov1997-linux-i586.tgz"
CHECKSUM_SHA256_2="2df15cde0128b7a036e71995e068ca853f13be8e2b591caac140025d66643fc0"
SOURCE_DIR_2="hexen2demo_nov1997"
PATCHES="uhexen2-$portVersion.patchset"
ADDITIONAL_FILES="uhexen2.rdef.in"

ARCHITECTURES="all"

PROVIDES="
	uhexen2 = $portVersion
	app:Hexen2
	"
REQUIRES="
	haiku
	lib:libmad
	lib:libogg
	lib:libSDL_1.2
	lib:libvorbis
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libmad
	devel:libogg
	devel:libSDL_1.2
	devel:libvorbis
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:ld
	cmd:make
	cmd:nasm
	cmd:pkg_config
	"

BUILD()
{
	cd engine/hexen2
	make h2 $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/uHexen2
	cp engine/hexen2/hexen2 "$appsDir/uHexen2/Hexen II"
	cp -rf $sourceDir2/data1 \
		$sourceDir2/docs \
		$sourceDir2/DEMO.TXT \
		$sourceDir2/SUBLICENSE.doc \
		$appsDir/uHexen2

	local APP_SIGNATURE="application/x-vnd.uhexen2"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	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/uhexen2.rdef.in > $sourceDir/uhexen2.rdef

	addResourcesToBinaries  $sourceDir/uhexen2.rdef \
		"$appsDir/uHexen2/Hexen II"
	addAppDeskbarSymlink "$appsDir/uHexen2/Hexen II"
}
