SUMMARY="Solitaire Mahjong game"
DESCRIPTION="Solitaire Mahjong is a one player version of the classic Eastern tile game, Mahjong. \
It has all the functionality you expect from a solitaire game. In addition it provides tools such \
as a layout editor allowing the player to create custom layouts as well as analysis tools to evaluate them. "
HOMEPAGE="http://star.physics.yale.edu/~ullrich/software/SolitaireMahjong/"
COPYRIGHT="2008-2017 Thomas S. Ullrich"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="http://star.physics.yale.edu/~ullrich/software/SolitaireMahjong/Distributions/$portVersion/SolitaireMahjong-2.24-src.tgz"
CHECKSUM_SHA256="42e2f5201c8562775fd655e296ce23e06a8ca2595ce9f7263b1ccecde52bc4cd"
SOURCE_DIR="SolitaireMahjong"
ADDITIONAL_FILES="solitaire_mahjong.rdef.in"

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

PROVIDES="
	solitaire_mahjong$secondaryArchSuffix = $portVersion
	app:SolitaireMahjong$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:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake SolitaireMahjong.pro
	make $jobArgs
}

INSTALL()
{
	mkdir -p "$appsDir/Solitaire Mahjong"
	cp "smg/Solitaire Mahjong" "$appsDir/Solitaire Mahjong"
	cp "smld/Layout Designer" "$appsDir/Solitaire Mahjong"

	cp -Rf docs layouts tiles "$appsDir/Solitaire Mahjong"

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

	addResourcesToBinaries  $sourceDir/solitaire_mahjong.rdef \
		"$appsDir/Solitaire Mahjong/Solitaire Mahjong"

	local APP_SIGNATURE="application/x-vnd.solitaire-mahjong-layout-designer"
	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/solitaire_mahjong.rdef.in > $sourceDir/layout_dedsigner.rdef

	addResourcesToBinaries  $sourceDir/layout_dedsigner.rdef \
		"$appsDir/Solitaire Mahjong/Layout Designer"

	mimeset -f "$appsDir/Solitaire Mahjong/Solitaire Mahjong"
	mimeset -f "$appsDir/Solitaire Mahjong/Layout Designer"

	addAppDeskbarSymlink "$appsDir/Solitaire Mahjong/Solitaire Mahjong" "Solitaire Mahjong"
}
