# Template file for 'cyrus-sasl'
pkgname=cyrus-sasl
version=2.1.25
revision=4
short_desc="Cyrus SASL - auth daemon and administration tools"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://cyrusimap.web.cmu.edu/"
license="BSD"
distfiles="ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-$version.tar.gz"
checksum=418c16e6240a4f9b637cbe3d62937b9675627bad27c622191d47de8686fe24fe

hostmakedepends="groff"
makedepends="openssl-devel db-devel>=5.3 libldap-devel mit-krb5-devel pam-devel
 postgresql-libs-devel libmysqlclient-devel>=5.5.27 sqlite-devel"
depends="libsasl>=${version}"
systemd_services="saslauthd.service on"

do_configure() {
	./configure ${configure_args} --disable-static --enable-shared \
		--enable-alwaystrue --enable-checkapop --enable-cram \
		--enable-digest --disable-otp --disable-srp \
		--disable-srp-setpass --disable-krb4 --enable-gssapi \
		--enable-auth-sasldb --enable-plain --enable-anon \
		--enable-login --enable-ntlm --disable-passdss --enable-sql \
		--enable-ldapdb --disable-macos-framework --with-pam \
		--with-saslauthd=/var/run/saslauthd --with-ldap \
		--with-configdir=/etc/sasl2:/etc/sasl:/usr/lib/sasl2 \
		--with-devrandom=/dev/urandom LDFLAGS=-ldb
}

do_build() {
	make ${makejobs}
}

do_install() {
	make DESTDIR=${DESTDIR} install

	# Remove libsasl{,-devel} files.
	rm -rf ${DESTDIR}/usr/include
	rm -f ${DESTDIR}/usr/lib/libsasl*
	rm -rf ${DESTDIR}/usr/share/man/man3

	# systemd
	vinstall ${FILESDIR}/saslauthd.service 644 usr/lib/systemd/system
	vinstall ${FILESDIR}/saslauthd.tmpfiles.d 644 \
		usr/lib/tmpfiles.d saslauthd.conf

	vinstall COPYING 644 usr/share/licenses/${pkgname}
}

cyrus-sasl-modules-ldap_package() {
	depends="cyrus-sasl>=${version}_${revision}"
	short_desc="Cyrus SASL - pluggable authentication modules (LDAP)"
	pkg_install() {
		vmove "usr/lib/sasl2/libldapdb.*"
	}
}

cyrus-sasl-modules-sql_package() {
	depends="cyrus-sasl>=${version}_${revision}"
	short_desc="Cyrus SASL - pluggable authentication modules (SQL)"
	pkg_install() {
		vmove "usr/lib/sasl2/libsql.*"
	}
}

cyrus-sasl-modules-gssapi_package() {
	depends="cyrus-sasl>=${version}_${revision}"
	short_desc="Cyrus SASL - pluggable authentication modules (GSSAPI)"
	pkg_install() {
		vmove "usr/lib/sasl2/libgssapi*"
	}
}

cyrus-sasl-modules_package() {
	depends="cyrus-sasl>=${version}_${revision}"
	short_desc="Cyrus SASL - pluggable authentication modules"
	pkg_install() {
		vmove usr/lib/sasl2
	}
}
