# Template file for 'mit-krb5'
pkgname=mit-krb5
version=1.11.3
revision=1
short_desc="MIT Kerberos 5 implementation"
maintainer="Juan RP <xtraeme@gmail.com>"
license="MIT"
homepage="http://web.mit.edu/Kerberos"
distfiles="$homepage/dist/krb5/1.11/krb5-$version-signed.tar"
checksum=9abd94bb94a70996da0f8d90408957154bb543271b097e86c63eb33e5f5751b5

noextract=yes
wrksrc="krb5-${version}"

build_style=gnu-configure
configure_script="./src/configure"
configure_args="--disable-rpath --with-system-et --without-system-verto
 --with-system-ss --with-system-db --enable-shared --without-tcl"

hostmakedepends="perl flex"
makedepends="db-devel>=5.3 e2fsprogs-devel openssl-devel"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" e2fsprogs-devel"
	makedepends+=" libfl-devel"
	configure_args+=" ac_cv_func_pthread_once=yes
			ac_cv_func_pthread_rwlock_init=yes
			acx_pthread_ok=yes
			ac_cv_func_regcomp=yes
			ac_cv_printf_positional=yes
			krb5_cv_attr_constructor_destructor=yes,yes"
fi

do_extract() {
	# We have to do this dance because the real distfile is
	# included in the .tar archive.
	tar xf $XBPS_SRCDISTDIR/$(basename $distfiles) -C $wrksrc
	tar xfz $wrksrc/krb5-$version.tar.gz -C $XBPS_BUILDDIR
	# Fix db plugin.
	sed -i -e "s|<db.h>|<db_185.h>|" $wrksrc/src/plugins/kdb/db2/*.[ch]
}

mit-krb5-client_package() {
	short_desc="MIT Kerberos 5 implementation - client programs"
	pkg_install() {
		for f in uuclient ktutil kswitch gss-client kvno kinit kpasswd \
			kdestroy sclient kadmin k5srvutil sim_client klist ksu; do
			vmove usr/bin/${f}
			if [ -f ${DESTDIR}/usr/share/man/man1/${f}.1 ]; then
				vmove usr/share/man/man1/${f}.1
			fi
		done
	}
}

mit-krb5-devel_package() {
	depends="db-devel>=5.3 openssl-devel e2fsprogs-devel>=1.4.10_1
		mit-krb5-libs>=${version}"
	short_desc="MIT Kerberos 5 implementation - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/bin/krb5-config
	}
}

mit-krb5-libs_package() {
	conflicts="heimdal-libs>=0"
	short_desc="MIT Kerberos 5 implementation - shared libraries"
	pkg_install() {
		vmove "usr/lib/*.so*"
	}
}

mit-krb5_package() {
	depends="mit-krb5-client-${version}_${revision}"
	conflicts="heimdal>=0"
	pkg_install() {
		vmove all
	}
}
