SUMMARY="The ultimate desktop calculator"
DESCRIPTION="Qalculate! is a multi-purpose cross-platform desktop calculator. \
It is simple to use but provides power and versatility normally reserved for \
complicated math packages, as well as useful tools for everyday needs (such \
as currency conversion and percent calculation). Features include a large \
library of customizable functions, unit calculations and conversion, symbolic \
calculations (including integrals and equations), arbitrary precision, \
uncertainty propagation, interval arithmetic, plotting, and a user-friendly \
interface (Qt, and CLI)."
HOMEPAGE="https://qalculate.github.io/"
COPYRIGHT="2003-2006, 2021 Hanna Knutsson"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/Qalculate/qalculate-qt/releases/download/v$portVersion/qalculate-qt-$portVersion.tar.gz"
CHECKSUM_SHA256="f14c2d8677b650fd03d8b96d82bcedbae406015f2f871222f94b827c5a0aeef6"
SOURCE_DIR="qalculate-qt-$portVersion"
ADDITIONAL_FILES="qalculate_qt.rdef.in"

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

PROVIDES="
	qalculate_qt$secondaryArchSuffix = $portVersion
	app:qalculate_qt = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libqalculate$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libqalculate$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

defineDebugInfoPackage qalculate_qt$secondaryArchSuffix \
	$appsDir/Qalculate

BUILD()
{
	qmake .
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir
	cp qalculate-qt $appsDir/Qalculate

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

	addResourcesToBinaries qalculate_qt.rdef $appsDir/Qalculate
	addAppDeskbarSymlink $appsDir/Qalculate
}

TEST()
{
	cd build
	make test
}
