# -*- 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               github 1.0
PortGroup               muniversal 1.0
PortGroup               legacysupport 1.1

github.setup            cyrusimap cyrus-sasl 2.1.28 cyrus-sasl-
revision                1

name                    cyrus-sasl2
categories              security net
# license is BSD plus a fourth (almost redundant) acknowledgement clause
license                 Permissive
maintainers             nomaintainer

description             SASL is an authentication library.

long_description        SASL is the Simple Authentication and Security Layer, \
                        a method for adding authentication support to \
                        connection-based protocols. To use SASL, a protocol \
                        includes a command for identifying and authenticating \
                        a user to a server and for optionally negotiating \
                        protection of subsequent protocol interactions. If \
                        its use is negotiated, a security layer is inserted \
                        between the protocol and the connection.

merger_must_run_binaries    yes

homepage                https://www.cyrusimap.org
github.tarball_from     releases

checksums               rmd160 ce07ac81e35ac8cd73c64b863cd7850bbb004d9c \
                        sha256 7ccfc6abd01ed67c1a0924b353e526f1b766b21f42d4562ee635a8ebfc5bb38c \
                        size   4034803

depends_lib             path:lib/libssl.dylib:openssl \
                        port:zlib

default_variants        +kerberos

patchfiles              patch-pwcheck-pwcheck_getpwnam.c.diff \
                        dynamic_lookup-11.patch \
                        887dbc0435056ec58ee48c4d803f110ade1e4c39.patch

configure.env-append    CC_FOR_BUILD=${configure.cc}

configure.args          --mandir=${prefix}/share/man \
                        --with-openssl=${prefix} \
                        --with-dblib=ndbm \
                        --with-dbpath=${prefix}/etc/sasldb2 \
                        --with-plugindir=${prefix}/lib/sasl2 \
                        --with-saslauthd=${prefix}/var/state/saslauthd \
                        --with-pwcheck=${prefix}/var/pwcheck \
                        --disable-obsolete_cram_attr \
                        --disable-obsolete_digest_attr \
                        --enable-static \
                        --disable-gssapi \
                        --disable-macos-framework \
                        --with-sphinx-build=no \
                        --enable-srp \
                        --enable-srp-setpass \
                        --enable-login \
                        --enable-ntlm \
                        --with-rc4=openssl \
                        ac_cv_prog_AWK=/usr/bin/awk

destroot.keepdirs       ${destroot}${prefix}/var/state/saslauthd \
                        ${destroot}${prefix}/var/pwcheck

post-destroot {
    xinstall -d \
        ${destroot}${prefix}/share/doc \
        ${destroot}${prefix}/var/state/saslauthd \
        ${destroot}${prefix}/var/pwcheck

    file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${name}
    delete {*}[glob ${destroot}${prefix}/share/doc/${name}/legacy/*Makefile*]
}

variant kerberos description "Enable Kerberos support" {
    configure.args-append   --enable-keep-db-open

    if {${os.platform} eq "darwin"} {
        depends_lib-append  port:kerberos5
        configure.args-replace  --disable-gssapi --enable-gssapi=${prefix}
        configure.args-append   --with-gss_impl=mit
    }
    if {${os.platform} eq "freebsd"} {
        depends_lib-append  port:heimdal
        configure.args-replace  --disable-gssapi --enable-gssapi=${prefix}
        configure.args-append   --with-gss_impl=heimdal
    }
}

variant sql description "Enable SQL support" {
    depends_lib-append      port:sqlite3
    configure.args-append   --enable-sql \
                            --without-mysql \
                            --without-pgsql \
                            --without-sqlite \
                            --with-sqlite3
}

github.livecheck.regex  {(\d+(?:\.\d+)*)}