# -*- 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

PortSystem                  1.0
PortGroup                   compiler_blacklist_versions 1.0

name                        kerberos5
version                     1.21.3
revision                    0
checksums                   rmd160  51727964dcfc3d1f83f8df342b23cd2aad48f526 \
                            sha256  b7a4cd5ead67fb08b980b21abd150ff7217e85ea320c9ed0c6dadd304840ad35 \
                            size    9136145

set branch                  [join [lrange [split ${version} .] 0 1] .]
conflicts                   fbopenssl
categories                  net security
maintainers                 {ryandesign @ryandesign} openmaintainer
license                     MIT BSD ISC OpenLDAP-2.8+

description                 Kerberos is a network authentication protocol.

long_description            Kerberos is a network authentication protocol. \
                            It is designed to provide strong authentication \
                            for client/server applications by using secret-key \
                            cryptography. A free implementation of this protocol \
                            is  available from the Massachusetts Institute of \
                            Technology. Kerberos is available in many commercial \
                            products as well.

homepage                    http://web.mit.edu/kerberos/
master_sites                ${homepage}dist/krb5/${branch}/
distname                    krb5-${version}

depends_build               port:gettext \
                            path:bin/pkg-config:pkgconfig

depends_lib                 port:gettext-runtime \
                            port:libcomerr \
                            port:libedit \
                            port:lmdb \
                            port:ncurses \
                            path:lib/libssl.dylib:openssl

worksrcdir                  ${worksrcdir}/src

patchfiles                  patch-util__verto__Makefile.in-use-nonzero-compat-version.diff \
                            patch-config__shlib.conf-do-not-pass-dylib-file-ldflags.diff \
                            patch-lib_rpc_Makefile.in-explicitly-link-krb5support.diff \
                            no-Werror.patch

use_autoreconf              yes
configure.checks.implicit_function_declaration.whitelist-append strchr

# kerberos5 fails to build in its own presence, see #23769, #37944
# remove ${prefix}/lib from configure.ldflags to allow linking against its own libs first
# adding ${worksrcpath}/lib is not necessary and pollutes krb5-config --libs and pkg-config files
configure.ldflags-delete    -L${prefix}/lib
configure.python            false
configure.args              --with-system-et \
                            --without-system-db \
                            --without-hesiod \
                            --without-ldap \
                            --with-crypto-impl=openssl \
                            --with-libedit \
                            --without-readline \
                            --without-system-verto \
                            --without-system-ss \
                            ac_cv_prog_AWK=/usr/bin/awk

# Needs LIBRARY_PATH support
compiler.blacklist-append   {clang <= 318.0.61}

# i386 linking fails on Snow Leopard with gcc-4.2 from Xcode 3.2.6
if {[string match *gcc-4.2 ${configure.compiler}] &&
    ($build_arch eq "i386" || ([variant_isset universal] && "i386" in $universal_archs))} {
    configure.optflags -O2
}

post-configure {
    reinplace -E {s|-arch [^ ]+||g} \
        ${worksrcpath}/build-tools/krb5-config
}

livecheck.type              regex
livecheck.url               ${homepage}
livecheck.regex             {Current\s+release:\s+<.*>krb5-([0-9.]+)<}
