SUMMARY="Hardcore 3D space scroll-shooter with spaceship upgrade possibilities"
DESCRIPTION="AstroMenace is an astonishing hardcore scroll-shooter where brave space warriors \
may find a great opportunity to hone their combat skills. Gather money during the battle to \
spend them on turning your spaceship into an ultimate weapon of mass destruction and give hell \
to swarms of adversaries. Enjoy the wonderfully crafted 3d graphics and high-quality special \
effects along with a detailed difficulty adjustment and a handy interface of AstroMenace.

Features:
* 22 playable ships with unique characteristics.
* 19 unique weapons with the easy drag-and-drop weapon mount mode.
* 15 missions with 100+ unique enemies and 40+ space objects.
* Simulative and arcade ship control mode."
HOMEPAGE="https://viewizard.com/"
COPYRIGHT="Mikhail Kurinnoi"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/viewizard/astromenace/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="0aca5211c9f333acf698807f597e5ad8e9d1455ba8ad202940890bff5b6c9507"
SOURCE_DIR="astromenace-$portVersion"
PATCHES="astromenace-$portVersion.patchset"
ADDITIONAL_FILES="astromenace.rdef.in"

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

PROVIDES="
	astromenace$secondaryArchSuffix = $portVersion
	app:AstroMenace
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libalut$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libvorbisfile$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libalut$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_image_2.0$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libvorbisfile$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=Release \
		-DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir/SDL2 \
		-DALUT_INCLUDE_DIR=/system/$relativeIncludeDir

	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/AstroMenace
	cp build/astromenace $appsDir/AstroMenace/AstroMenace
	cp build/gamedata.vfs $appsDir/AstroMenace

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

	addResourcesToBinaries  $sourceDir/build/astromenace.rdef $appsDir/AstroMenace/AstroMenace
	addAppDeskbarSymlink $appsDir/AstroMenace/AstroMenace
}
