SUMMARY="Port Adamant Armor Affection Adventure 3D stealth-action platform game"
DESCRIPTION="Adamant Armor Affection Adventure by quasist and Don Miguel is a \
3D stealth-action platform game participated in the RIOT Tag-Team Coding \
Competition event in 2011 and took the second place. It was originally released \
on the gaming console GP2X Caanoo and GP2X Wiz, and later ported to Pandora and GCW Zero."
HOMEPAGE="https://github.com/EXL/AdamantArmorAffectionAdventure/"
COPYRIGHT="2016-2018 EXL"
LICENSE="MIT"
REVISION="3"
SOURCE_URI="https://github.com/EXL/AdamantArmorAffectionAdventure/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="a350fcf72827e600adcd7028fc8e453870c8087532b1e663975fa9fddcf3b1bd"
SOURCE_DIR="AdamantArmorAffectionAdventure-$portVersion"
PATCHES="aaaa-$portVersion.patchset"
ADDITIONAL_FILES="aaaa.rdef.in"

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

GLOBAL_WRITABLE_FILES="
	settings/AAAA/donothexedit.me keep-old
	"

PROVIDES="
	aaaa$secondaryArchSuffix = $portVersion
	app:AdamantArmorAffectionAdventure$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0${secondaryArchSuffix}
	lib:libSDL2_mixer_2.0${secondaryArchSuffix}
	"

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

BUILD()
{
	mkdir -p build
	cd build
	cmake -DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir \
		-DSDL2_MIXER_INCLUDE_DIR=/system/$relativeIncludeDir \
		-DCMAKE_BUILD_TYPE=Release \
		-DGLES=off \
		-DANDROID=off \
		-DCMAKE_C_FLAGS="-D__linux__ -DAPPDIR=\"\\\"$appsDir/AAAA\\\"\"" \
		../aaaa/src/main/cpp
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/AAAA $settingsDir/AAAA

	cp build/Release/AAAA-Engine "$appsDir/AAAA/Adamant Armor Affection Adventure"
	cp build/Release/donothexedit.me $settingsDir/AAAA
	cp -rf build/Release/{bgm,maps,sfx,textures.gfx} $appsDir/AAAA/
	ln -s $settingsDir/AAAA/donothexedit.me $appsDir/AAAA/donothexedit.me

	local APP_SIGNATURE="application/x-vnd.adamant-armor-affection-adventure"
	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/aaaa.rdef.in > $sourceDir/aaaa.rdef

	addResourcesToBinaries  $sourceDir/aaaa.rdef \
		"$appsDir/AAAA/Adamant Armor Affection Adventure"
	addAppDeskbarSymlink "$appsDir/AAAA/Adamant Armor Affection Adventure" \
		"Adamant Armor Affection Adventure"
}
