SUMMARY="Implementation of the olm and megolm cryptographic ratchets"
DESCRIPTION="An implementation of the Double Ratchet cryptographic ratchet, \
written in C and C++11 and exposed as a C API.
This library also includes an implementation of the Megolm cryptographic
ratchet."
HOMEPAGE="https://gitlab.matrix.org/matrix-org/olm"
COPYRIGHT="2015-2016 OpenMarket Ltd.
	2018-2019 New Vector Ltd."
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://gitlab.matrix.org/matrix-org/olm/-/archive/$portVersion/olm-$portVersion.tar.bz2"
CHECKSUM_SHA256="eff513cff8e5c7af657e800a2c2dbbdee5be19ee9ce24c5498a2528c4b5f1dc3"

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

libVersion="3.1.4"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	olm$secondaryArchSuffix = $portVersion
	lib:libolm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	olm${secondaryArchSuffix}_devel = $portVersion
	devel:libolm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	olm$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage olm$secondaryArchSuffix \
	"$libDir"/libolm.so.$libVersion

BUILD()
{
	mkdir -p haiku_build && cd "$_"

	# Test fals to build, complains about fPIC
	cmake .. \
		-DOLM_TESTS=OFF \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	make install

	rm -f "$libDir"/libolm.la

	prepareInstalledDevelLib libolm

	packageEntries devel \
		"$developDir" \
		"$libDir"/cmake
}

TEST()
{
	make test
}
