SUMMARY="A tetris clone based on Qt5"
DESCRIPTION="Gottet is a clean, simple falling blocks game. \
Use the arrow keys to rotate and position each piece as it \
falls. Fill a whole row to clear it. Unlimited levels, with \
progressively faster speeds."
HOMEPAGE="https://gottcode.org/gottet/"
COPYRIGHT="2009-2020 Graeme Gott"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://gottcode.org/gottet/gottet-$portVersion-src.tar.bz2"
CHECKSUM_SHA256="6c979caa5b3fa6854ca8367ca0595814fcc101f0bdfad02d64219dd9049abb2b"
SOURCE_DIR="gottet-$portVersion"
ADDITIONAL_FILES="gottet.rdef.in"

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

PROVIDES="
	gottet$secondaryArchSuffix = $portVersion
	app:Gottet$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Gottet/translations
	cp gottet $appsDir/Gottet/Gottet
	cp -Rf translations/*.qm $appsDir/Gottet/translations

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

	addResourcesToBinaries  $sourceDir/gottet.rdef \
		$appsDir/Gottet/Gottet

	mimeset -f $appsDir/Gottet/Gottet

	addAppDeskbarSymlink $appsDir/Gottet/Gottet
}
