SUMMARY="A Qt IMAP e-mail client"
DESCRIPTION="Trojitá enables you to access your mail anytime, anywhere.
Does not slow you down. If we can improve the productivity of an e-mail user, \
we better do.
Respects open standards and facilitate modern technologies. We value the \
vendor-neutrality that IMAP provides and are committed to be as \
interoperable as possible.
Is efficient -- be it at conserving the network bandwidth, keeping memory \
use at a reasonable level or not hogging the system's CPU.
Can be used on many platforms. One UI is not enough for everyone, but our \
IMAP core works fine on anything from desktop computers to cell phones and \
big ERP systems.
Plays well with the rest of the ecosystem. We don't like reinventing \
wheels, but when the existing wheels quite don't fit the tracks, we're \
not afraid of making them work."
HOMEPAGE="http://trojita.flaska.net/"
COPYRIGHT="2006-2020 Trojitá developers"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="b4f24d73b68d69ae4b643d3279a9e90d991d06cc"
SOURCE_URI="https://github.com/KDE/trojita/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="061189f877ee15b25ce0136c9a4b450cb5788a1a62875a849c4ab5030b12ec33"
SOURCE_FILENAME="trojita-$portVersion-$srcGitRev.tar.gz"
SOURCE_DIR="trojita-$srcGitRev"
PATCHES="trojita-$portVersion.patchset"
ADDITIONAL_FILES="trojita.rdef.in"

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

PROVIDES="
	trojita$secondaryArchSuffix = $portVersion
	app:Trojita$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku${secondaryArchSuffix}
#	cmd:gpgconf$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
#	lib:libgpg_error$secondaryArchSuffix
#	lib:libgpgmepp$secondaryArchSuffix
	lib:libmimetic$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Test$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libKF5SonnetCore$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
#	devel:libgpg_error$secondaryArchSuffix
#	devel:libgpgmepp$secondaryArchSuffix
	devel:libmimetic$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Test$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libKF5SonnetCore$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
#	cmd:gpgconf$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
#	cmd:ragel
	cmd:strip
	cmd:xargs
	"

defineDebugInfoPackage trojita$secondaryArchSuffix \
	"$appsDir"/Trojita/Trojita

BUILD()
{
	#Creating Build dir
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX:PATH=$appsDir/Trojita \
		-DCMAKE_INSTALL_LIBDIR:PATH=$appsDir/Trojita/lib \
		-DCMAKE_INSTALL_DATAROOTDIR:PATH=$dataDir/Trojita \
		-DWITH_DBUS:BOOL=OFF \
		-DWITH_KF5_GPGMEPP=OFF \
		-Wno-dev

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	#Moving things around
	BINDIR="$appsDir/Trojita"
	mv "$BINDIR/bin/be.contacts" "$BINDIR/be.contacts"
	mv "$BINDIR/bin/trojita" "$BINDIR/Trojita"
	strip "$BINDIR/be.contacts"
	strip "$BINDIR/Trojita"
	rm -rf "$BINDIR/bin"
	rm -rf $dataDir/Trojita/{appdata,applications,icons}

	# Add Haiku resources
	local APP_SIGNATURE="application/x-vnd.trojita"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	# For release
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	# For git version
	#local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/trojita.rdef.in > trojita.rdef

	addResourcesToBinaries trojita.rdef $appsDir/Trojita/Trojita

	addAppDeskbarSymlink $appsDir/Trojita/Trojita Trojita
}

TEST()
{
	cd build
	ctest $jobArgs
}
