SUMMARY="A basic sudoku game"
DESCRIPTION="You can switch between filling in notes (pencil mode), or filling in \
answers (pen mode). To make it easier to see where to place numbers, you can highlight \
all instances of a number. You can also check your answers for correctness while playing. \
The game stores your current notes and answers, so that you can pick up where you left \
off the next time you play."
HOMEPAGE="https://gottcode.org/simsu/"
COPYRIGHT="2009-2021 Graeme Gott"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://gottcode.org/simsu/simsu-$portVersion-src.tar.bz2"
CHECKSUM_SHA256="6db0c004de67c122ac67f34cc6c1a68cd78be02034eceeab922848f87cb85e87"
SOURCE_DIR="simsu-$portVersion"
ADDITIONAL_FILES="
	simsu.rdef.in
	icons.zip
	"

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

PROVIDES="
	simsu$secondaryArchSuffix = $portVersion
	app:Simsu = $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
	cmd:unzip
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/icons.zip -d $sourceDir/icons
}

BUILD()
{
	qmake
	make $jobArgs
}

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

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

	addResourcesToBinaries  $sourceDir/simsu.rdef \
		$appsDir/Simsu/Simsu

	mimeset -f $appsDir/Simsu/Simsu

	addAppDeskbarSymlink $appsDir/Simsu/Simsu Simsu
}
