# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 89976 2012-02-18 06:42:57Z jeremyhu@macports.org $

PortSystem 1.0

name		heimdal
version		1.3.3
revision        1
categories	net security
maintainers	landonf openmaintainer
platforms	darwin
description	Kerberos is a network authentication protocol.

long_description	Kerberos provides a means of verifying the identities \
			of principals, (e.g., a workstation user or a network \
			server) on an open (unprotected) network.  This is \
			accomplished without relying on authentication by the \
			host operating system, without basing trust on host \
			addresses, without requiring physical security of all \
			the hosts on the network, and under the assumption \
			that packets traveling along the network can be read, \
			modified, and inserted at will.

homepage	http://www.h5l.org/
master_sites	${homepage}dist/src/
checksums   md5 963c09f1b14c41660be70b55fae9f163 \
            sha1 a385d959e3edd144aee79e9df585e44347342049 \
            rmd160 ce97ac415e7c27912ba148b81c46e756dc54ba3e

depends_lib port:readline port:gettext

patchfiles  patch-lib-sqlite-sqlite3.c.diff

# Use a separate prefix to avoid conflicts with the port kerberos5
# (and openssl, if that variant is selected)
configure.pre_args --prefix=${prefix}/libexec/heimdal
configure.args                 \
    --sysconfdir=${prefix}/etc \
    --enable-shared            \
    --enable-static            \
    --enable-pthread-support   \
    --with-readline=${prefix}  \
    --with-libintl=${prefix}   \
    --without-x                \
    --without-openldap         \
    --without-openssl          \
    --without-sqlite3

variant x11 description \
    {Enable X11 use in libraries, and build X11-related applications} {
    depends_lib-append     port:xorg-libice \
                           port:xorg-libXau \
                           port:xorg-libXt \
                           port:xorg-libsm \
                           port:xorg-libX11 \
                           port:xorg-libXdmcp
    configure.args-delete  --without-x
    configure.args-append  --with-x=${prefix}
}

variant openldap description \
    {Enable LDAP database support for keeping track \
         of Kerberos information} {
    depends_lib-append     port:openldap
    configure.args-delete  --without-openldap
    configure.args-append  --with-openldap=${prefix}
}

# heimdal fails with openssl-1.0.0a due to removal of md2
#variant openssl description \
#    {Use OpenSSL libraries instead of internal ones for \
#         crypto and ssl related functions} {
#    depends_lib-append     port:openssl
#    configure.args-delete  --without-openssl
#    configure.args-append  --with-openssl=${prefix}
#}

variant sqlite3 description \
    {Enable SQlite3 database support for keeping track \
         of Kerberos information} {
    depends_lib-append      port:sqlite3
    configure.args-delete  --without-sqlite3
    configure.args-append  --with-sqlite3=${prefix}
}

post-patch {
	# Tiger does not have the CommonCrypto support needed for -openssl
	if {${os.platform} == "darwin" && ${os.major} < 9} {
		reinplace "s:def __APPLE__: 0:" ${worksrcpath}/lib/hcrypto/evp-cc.c
	}
}

build.env-append LC_CTYPE=C

test.run	yes
test.target	check

livecheck.type  regex
livecheck.url   ${master_sites}
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
