SUMMARY="The Cyrus SASL (Simple Authentication and Security Layer)"
DESCRIPTION="The Cyrus SASL library is a generic library for easy \
integration of secure network authentication to any client or server \
application. It supports authentication via standard plaintext methods as \
well as CRAM-MD5 and DIGEST-MD5 shared secret methods and KERBEROS_V4 and \
GSSAPI Kerberos methods. The SASL protocol framework is used by SMTP, \
IMAP, ACAP, LDAP, and other standard protocols."
HOMEPAGE="https://github.com/cyrusimap/cyrus-sasl"
COPYRIGHT="1994-2012 Carnegie Mellon University"
LICENSE="BSD (4-clause)"
REVISION="2"
SOURCE_URI="https://github.com/cyrusimap/cyrus-sasl/archive/cyrus-sasl-${portVersion/\~/-}.tar.gz"
CHECKSUM_SHA256="5a0c5475b35aad933c0f5939a360cfef86d06dbca93309cb7b223a38a133dc68"
SOURCE_DIR="cyrus-sasl-cyrus-sasl-${portVersion/\~/-}"

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

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	cyrus_sasl$secondaryArchSuffix = $portVersion compat >= 2
	cmd:pluginviewer$commandSuffix
	cmd:saslauthd$commandSuffix
	cmd:testsaslauthd$commandSuffix
	lib:libsasl2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

PROVIDES_devel="
	cyrus_sasl${secondaryArchSuffix}_devel = $portVersion compat >= 2
	devel:libsasl2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	cyrus_sasl$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:automake
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:nroff
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage cyrus_sasl$secondaryArchSuffix \
	"$libDir"/libsasl2.so.$libVersion

BUILD()
{
	autoreconf -fi
	LDFLAGS="-lnetwork -lgnu" runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file
	rm -f $libDir/libsasl2.la
	rm -f $libDir/sasl2/*.la

	prepareInstalledDevelLib libsasl2
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
