SUMMARY="High-precision scientific calculator"
DESCRIPTION="SpeedCrunch features a syntax-highlighted scrollable display and \
is designed to be fully used via keyboard.
Some distinctive features are auto-completion of functions and variables, a \
formula book, and quick insertion of constants from various fields of knowledge.
It is available for Windows, OS X, Linux and Haiku in a number of languages."
HOMEPAGE="https://www.speedcrunch.org/"
COPYRIGHT="2014-2016 Helder Correia"
LICENSE="GNU GPL v2"
REVISION="6"
srcGitRev="7a18d76caad9"
SOURCE_URI="https://bitbucket.org/heldercorreia/speedcrunch/get/$srcGitRev.zip"
CHECKSUM_SHA256="23e8a7964186b6f1ca4026ba9a72e7e6f9ccc6f25995056297a271919f9c4688"
SOURCE_FILENAME="speedcrunch-$portVersion-$srcGitRev.tar.zip"
SOURCE_DIR="heldercorreia-speedcrunch-$srcGitRev"
PATCHES="speedcrunch-$portVersion.patchset"
ADDITIONAL_FILES="speedcrunch.rdef.in"

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

PROVIDES="
	speedcrunch$secondaryArchSuffix = $portVersion
	app:SpeedCrunch = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Help$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Help$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:qcollectiongenerator$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build && cd build
	cmake -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix	../src
	make $jobArgs OBJ_DIR=objects
}

INSTALL()
{
	cd build
	make install

	local APP_SIGNATURE="application/x-vnd.qt5-speedcrunch"
	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/speedcrunch.rdef.in > speedcrunch.rdef

	addResourcesToBinaries speedcrunch.rdef $appsDir/SpeedCrunch
	addAppDeskbarSymlink $appsDir/SpeedCrunch
}

TEST()
{
	cd build
	make test
}
