SUMMARY="A free and open source chess database application"
DESCRIPTION="With ChessX you can operate your collection of chess games \
in many ways: browse, edit, add, organize, analyze, etc."
HOMEPAGE="https://sourceforge.net/projects/chessx/"
COPYRIGHT="2005-2019 ChessX developers
	1990-2000 Info-ZIP
	1998-2005 Gilles Vollant
	1999-2004 Shane Hudson
	2003 Sune Fischer
	2005 Kamil Przybyla
	2005-2006 Ejner Borgbjerg
	2005-2006 William Hoggarth
	2005-2007 Marius Roets
	2005-2010 Michal Rudolf
	2005-2011 Sergey A. Tachenov
	2006 Tobias Koenig
	2006-2007 Pascal Georges
	2006-2007 Sean Estabrooks
	2007 Heinz R. Hopfgartner
	2007 Rico Zenklusen
	2010 P. Sereno
	2011 Nokia Corporation and/or its subsidiary(-ies).
	2012-2016 Jens Nissen
	2014 Digia Plc and/or its subsidiary(-ies).
	2014 Markus Kolb"
LICENSE="GNU GPL v2
	BSD (3-clause)
	GNU LGPL v2
	GNU LGPL v2.1
	Digia Qt LGPL Exception v1.1"
REVISION="1"
SOURCE_URI="https://downloads.sourceforge.net/chessx/chessx-$portVersion.tgz"
CHECKSUM_SHA256="d130ad3220821da9ea19e7228222a5528fabca3ca06bc41b4d7f702454f63827"
PATCHES="chessx-$portVersion.patchset"
ADDITIONAL_FILES="chessx.rdef.in"

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

PROVIDES="
	chessx$secondaryArchSuffix = $portVersion
	app:chessx = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:linguist$secondaryArchSuffix >= 5
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

defineDebugInfoPackage chessx$secondaryArchSuffix \
	$appsDir/ChessX

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	install -d $appsDir $docDir
	install -t $appsDir -m755 release/chessx
	install -t $docDir -m644 ChangeLog TODO

	mv $appsDir/chessx $appsDir/ChessX

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

	addResourcesToBinaries  $sourceDir/chessx.rdef $appsDir/ChessX
	addAppDeskbarSymlink $appsDir/ChessX
}
