SUMMARY="A peg solitaire game"
DESCRIPTION="Peg-E is a peg solitaire game in which you jump over pieces in order \
to remove them from the board, ultimately trying to eliminate all but one. The \
boards are randomly generated, with 100 levels of difficulty. The game auto-saves, \
and has undo-redo capability. Pieces can move horizontally, vertically, and diagonally."
HOMEPAGE="https://gottcode.org/peg-e/"
COPYRIGHT="2009-2020 Graeme Gott"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://gottcode.org/peg-e/peg-e-$portVersion-src.tar.bz2"
CHECKSUM_SHA256="06d6a07c056b82372cdd6ac258dbfedab397ad4f13b70117f548b8218201ff17"
SOURCE_DIR="peg-e-$portVersion"
ADDITIONAL_FILES="peg_e.rdef.in"

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

PROVIDES="
	peg_e$secondaryArchSuffix = $portVersion
	app:PegE$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/Peg-E/translations
	cp peg-e $appsDir/Peg-E/Peg-E
	cp -Rf translations/*.qm $appsDir/Peg-E/translations

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

	addResourcesToBinaries  $sourceDir/peg_e.rdef \
		$appsDir/Peg-E/Peg-E

	mimeset -f $appsDir/Peg-E/Peg-E

	addAppDeskbarSymlink $appsDir/Peg-E/Peg-E Peg-E
}
