SUMMARY="A cryptography library"
DESCRIPTION="Botan is a cryptography library written in C++. \
Its goal is to offer the tools necessary to implement a range of practical \
systems, such as TLS/DTLS, PKIX certificate handling, PKCS#11 and TPM \
hardware support, password hashing, and post quantum crypto schemes. \
Botan also has a C89 API specifically designed to be easy to call from other \
languages."
HOMEPAGE="https://botan.randombit.net/"
COPYRIGHT="1999-2018 The Botan Authors"
LICENSE="BSD (2-clause)"
REVISION="2"
SOURCE_URI="https://botan.randombit.net/releases/Botan-$portVersion.tgz"
CHECKSUM_SHA256="e7159b127e91e0c158245d61c638c50d443ec7b440b6b0161328c47b3aba3960"
SOURCE_DIR="Botan-$portVersion"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	botan$secondaryArchSuffix = $portVersion
	lib:libbotan_2$secondaryArchSuffix = $libVersionCompat
	cmd:botan$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:liblzma$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	botan${secondaryArchSuffix}_devel = $portVersion
	devel:libbotan_2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	botan$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:liblzma$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	"

BUILD()
{
	runConfigure --omit-buildspec --omit-dirs binDir ./configure.py \
		--prefix=/ --bindir="$commandBinDir" \
		--enable-shared-library \
		--with-bzip2 --with-lzma --with-zlib \
		--with-openssl --with-sqlite3
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLib libbotan-2
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}

TEST()
{
	LIBRARY_PATH="$sourceDir${LIBRARY_PATH:+:$LIBRARY_PATH}" \
	./botan-test
}
