SUMMARY="Educational software suite comprising of numerous activities for kids"
DESCRIPTION="GCompris is a high quality educational software suite comprising \
of numerous activities for children aged 2 to 10.
Some of the activities are game orientated, but nonetheless still educational."
HOMEPAGE="https://gcompris.net/index-en.html"
COPYRIGHT="
	2014-2016 Bruno Coudoin
	2014-2016 Johnny Jazeix
	2016 Stefan Toncu
	2014-2015 Stephane Mankowski
	2015 Sagar Chand Agarwal
	2014 Emmanuel Charruau
	2014-2015 Holger Kaelberer
	2014 Pulkit Gupta
	2010-2011 Alessandro Portale
	2014 Aruna Sankaranarayanan
	2015 Siddhesh suthar
	"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="http://gcompris.net/download/qt/src/gcompris-qt-$portVersion.tar.xz"
CHECKSUM_SHA256="8a475ac354dad320dee1c1f6835fb1bb36ef91fe157870bda3562c5e1b8a2707"
SOURCE_DIR="gcompris-qt-$portVersion"
PATCHES="gcompris-$portVersion.patchset"
ADDITIONAL_FILES="gcompris.rdef.in"

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

PROVIDES="
	gcompris$secondaryArchSuffix
	app:GCompris$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Qml$secondaryArchSuffix
	lib:libQt5Quick$secondaryArchSuffix
	lib:libQt5Sensors$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libQt5XmlPatterns$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix # should come with devel:libQt5Gui
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Qml$secondaryArchSuffix
	devel:libQt5Quick$secondaryArchSuffix
	devel:libQt5Sensors$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libQt5XmlPatterns$secondaryArchSuffix
	qt5:QmlBox2d
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:msgattrib
	"

BUILD()
{
	mkdir -p build && cd build
	cmake .. -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DQML_BOX2D_LIBRARY=$dataDir/Qt5/qml/Box2D.2.0
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR=0
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/gcompris.rdef.in > gcompris.rdef

	addResourcesToBinaries gcompris.rdef \
		$binDir/gcompris-qt

	mkdir -p $appsDir
	mv $binDir/gcompris-qt $appsDir/GCompris
	rm -r $binDir
	addAppDeskbarSymlink $appsDir/GCompris
}
