SUMMARY="Qt Cryptographic Architecture"
DESCRIPTION="QCA aims to provide a straightforward and cross-platform \
crypto API, using Qt datatypes and conventions. QCA separates the API from \
the implementation, using plugins known as Providers. The advantage of this \
model is to allow applications to avoid linking to or explicitly depending \
on any particular cryptographic library. This allows one to easily change or \
upgrade crypto implementations without even needing to recompile the \
application!"
HOMEPAGE="http://delta.affinix.com/qca/"
COPYRIGHT="2003-2015 Justin Karneges"
LICENSE="GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="http://download.kde.org/stable/qca/$portVersion/qca-$portVersion.tar.xz"
CHECKSUM_SHA256="d716d2d8e3ed8d95bbdb061f03081d7d032206f746a30a4d29d72196f50e7b02"
SOURCE_DIR="qca-$portVersion"
PATCHES="qca-$portVersion.patchset"

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

PROVIDES="
	qca$secondaryArchSuffix = $portVersion
	cmd:mozcerts_qt5$secondaryArchSuffix = $portVersion
	cmd:qcatool2$secondaryArchSuffix = $portVersion
	cmd:qcatool_qt5$secondaryArchSuffix = $portVersion
	lib:libqca$secondaryArchSuffix = $portVersion
	lib:libqca_qt5$secondaryArchSuffix = $portVersion compat >= 2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	ca_root_certificates
	lib:libcrypto$secondaryArchSuffix
	lib:libnspr4$secondaryArchSuffix
	lib:libnss3$secondaryArchSuffix
	lib:libnssutil3$secondaryArchSuffix
	lib:libplc4$secondaryArchSuffix
	lib:libplds4$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libsmime3$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libssl3$secondaryArchSuffix
	"

PROVIDES_devel="
	qca${secondaryArchSuffix}_devel = $portVersion
	devel:libqca$secondaryArchSuffix = $portVersion compat >= 2
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	qca$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libgsasl$secondaryArchSuffix
	devel:libnss3$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

BUILD()
{
	export QC_CERTSTORE_PATH=/system/data/ssl/CARootCertificates.pem

	cmake . -DCMAKE_INSTALL_PREFIX=$prefix \
		-DQCA_PLUGINS_INSTALL_DIR=$libDir \
		-DQCA_BINARY_INSTALL_DIR=$binDir \
		-DQCA_LIBRARY_INSTALL_DIR=$libDir \
		-DQCA_FEATURE_INSTALL_DIR=$dataDir/Qt/mkspecs/features \
		-DQCA_INCLUDE_INSTALL_DIR=$includeDir \
		-DQCA_PRIVATE_INCLUDE_INSTALL_DIR=$includeDir \
		-DQCA_DOC_INSTALL_DIR=$docDir \
		-DQCA_MAN_INSTALL_DIR=$manDir \
		-DBUILD_TESTS=1 \
		-DPKGCONFIG_INSTALL_PREFIX=$developLibDir/pkgconfig

	make $jobArgs
}

INSTALL()
{
	rm -f bin/qcatool2.debug
	rm -f lib/libqca.so.2.0.3.debug

	make install
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$dataDir/Qt/mkspecs \
		$libDir/cmake
}

TEST()
{
	QCA_PLUGIN_PATH="$sourceDir/lib/qca" make test
}
