SUMMARY="An educational real-time strategy video game featuring 3D graphics"
DESCRIPTION="Colobot: Gold Edition is a real-time strategy game, where you can \
program your units (bots) in a language called CBOT, which is similar to C++ and \
Java. Your mission is to find a new planet to live and survive. You can save the \
humanity and get programming skills!"
HOMEPAGE="https://colobot.info/"
COPYRIGHT="Epsitec and TerranovaTeam"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/colobot/colobot/archive/colobot-gold-$portVersion-alpha.tar.gz"
CHECKSUM_SHA256="633ce4ec9b54c657942453e769a2339befb2d0afff8b8b3589a73d005e097ab6"
SOURCE_DIR="colobot-colobot-gold-$portVersion-alpha"
PATCHES="colobot-$portVersion.patchset"
ADDITIONAL_FILES="colobot.rdef.in"

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

PROVIDES="
	colobot$secondaryArchSuffix = $portVersion
	app:Colobot = $portVersion
	"
REQUIRES="
	colobot_data
	haiku$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_regex$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libphysfs$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libsdl2_2.0$secondaryArchSuffix
	lib:libsdl2_image_2.0$secondaryArchSuffix
	lib:libsdl2_ttf_2.0$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_filesystem$secondaryArchSuffix >= 1.69.0
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libboost_regex$secondaryArchSuffix >= 1.69.0
	devel:libgl$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libphysfs$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libsdl2_2.0$secondaryArchSuffix
	devel:libsdl2_image_2.0$secondaryArchSuffix
	devel:libsdl2_ttf_2.0$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libz$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 \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Colobot \
		-DCOLOBOT_INSTALL_BIN_DIR=$appsDir/Colobot \
		-DCOLOBOT_INSTALL_LIB_DIR=$appsDir/Colobot/lib \
		-DCOLOBOT_INSTALL_I18N_DIR=$appsDir/Colobot/lang \
		-DCOLOBOT_INSTALL_DATA_DIR=$dataDir/Colobot \
		-DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir/SDL2 \
		-DOPENAL_SOUND=ON \
		-DPORTABLE=OFF \
		-DDESKTOP=OFF
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Colobot
	cd build
	make install
	mv $appsDir/Colobot/colobot $appsDir/Colobot/Colobot

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

	addResourcesToBinaries $sourceDir/build/colobot.rdef $appsDir/Colobot/Colobot
	addAppDeskbarSymlink $appsDir/Colobot/Colobot
}
