SUMMARY="An infinite game engine generator"
DESCRIPTION="GemRB (Game Engine Made with preRendered Background) \
is a port (actually a new implementation) of the original Infinity \
Engine (the one of Baldur's Gate, Icewind Dale, Planescape: Torment, ...) \
to Linux/Unix, MacOS X and Windows with some enhancements. Would \
you like to create a game like Baldur's Gate? \
(Originals games' data is not included)"
HOMEPAGE="https://gemrb.org"
COPYRIGHT="2003-2021 The GemRB Team"
LICENSE="MIT"
REVISION="1"
srcGitRev="0f383aad6ef51f2d0695ebadd4b73d5bb19fc706"
SOURCE_URI="https://github.com/gemrb/gemrb/archive/$srcGitRev.zip"
CHECKSUM_SHA256="8bc09de3b2d8301490afba2191f856d5e7947afa43e82eae2039a306e6ed4718"
SOURCE_FILENAME="gemrb-$srcGitRev.zip"
SOURCE_DIR="gemrb-$srcGitRev"

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

GLOBAL_WRITABLE_FILES="
	settings/gemrb/GemRB.cfg.noinstall.sample auto-merge
	settings/gemrb/GemRB.cfg.sample auto-merge
	"

PROVIDES="
	gemrb$secondaryArchSuffix = $portVersion
	cmd:extend2da.py$secondaryArchSuffix = $portVersion
	cmd:gemrb$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2$secondaryArchSuffix
	devel:libSDL2_mixer$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:python
	"

defineDebugInfoPackage gemrb$secondaryArchSuffix \
	"$binDir"/gemrb

BUILD()
{
	mkdir -p build
	cd build

	cmake .. \
		$cmakeDirArgs \
		-Wno-dev \
		-DDATA_DIR=$dataDir/gemrb \
		-DMAN_DIR=$manDir/man6 \
		-DSYSCONF_DIR=$settingsDir/gemrb \
		-DDOC_DIR=$documentationDir/gemrb \
		-DSDL2_INCLUDE_DIR=/boot/system/develop/headers/SDL2/ \
		-DSDL2_MIXER_INCLUDE_DIR=/boot/system/develop/headers/SDL2
	make $jobArgs
}

INSTALL()
{
	cd build
	make install
}

TEST()
{
	cd $settingsDir/gemrb
	cp GemRB.cfg.sample GmRB.cfg.bots
	echo GamePath=$dataDir/gemrb/minimal >> GmRB.cfg.bots
	echo GameType=test >> GmRB.cfg.bots
	echo AudioDriver=none >> GmRB.cfg.bots
	gemrb.exe -c GmRB.cfg.bots
	rm GmRB.cfg.bots
}
