SUMMARY="An amorphous ball of tar that rolls and squishies around"
DESCRIPTION="Gish is a side-scrolling platformer video game with some physics puzzle elements \
developed by Cryptic Sea (pseudonym of Alex Austin), Edmund McMillen, Josiah Pisciotta and \
published by Chronic Logic in 2004. Cryptic Sea pledged Gish to go open source under the \
 GPLv2 on May 29, 2010."
HOMEPAGE="https://exlmoto.ru/gish-droid/"
COPYRIGHT="2004-2017 Cryptic Sea, 2017-2018 EXL"
LICENSE="GNU GPL v2"
REVISION="3"
srcGitRev="174dfc86886cf99a60bca33b7cad131f2de1a45f"
SOURCE_URI="https://github.com/EXL/Gish/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="b7c7238aa0bf3b848334b884f0b5d4847f89fb21e2be27a1204e033f374cce7c"
SOURCE_DIR="Gish-$srcGitRev"
srcGitRev2="65546dd190d6168c0c06580c7e8cb7e7b4b198e7"
SOURCE_URI_2="https://github.com/EXL/BeGameLauncher/archive/$srcGitRev2.tar.gz"
CHECKSUM_SHA256_2="7c9dc3f1331a89ad92c5a233e9a2f7cb559979d18d0b90519d592336f6dc06b7"
SOURCE_DIR_2="BeGameLauncher-$srcGitRev2"
ADDITIONAL_FILES="gish.rdef"

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

PROVIDES="
	gish$secondaryArchSuffix = $portVersion
	app:Gish$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

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

	cd $sourceDir2
	mkdir -p build
	cd build
	cmake .. -DCMAKE_BUILD_TYPE=Release \
		-DLAUNCHER=gish
	make $jobArgs
}

INSTALL()
{
	cd build
	mkdir -p $appsDir/Gish/engine

	cp Release/Gish $appsDir/Gish/engine/
	cp $sourceDir2/build/GishLauncher $appsDir/Gish/Gish

	settype -t application/x-vnd.Be-elfexecutable $appsDir/Gish/engine/Gish
	rc $portDir/additional-files/gish.rdef -o gish.rsrc
	resattr -o $appsDir/Gish/engine/Gish gish.rsrc

	addAppDeskbarSymlink $appsDir/Gish/Gish
}
