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

name                    libgsasl
version                 2.2.4
revision                1

categories              security net
license                 LGPL-2.1+
homepage                https://www.gnu.org/software/gsasl/
maintainers             {sethm.id.au:dev @McDaMastR} \
                        openmaintainer

description             The GNU SASL library
long_description        GNU SASL is an implementation of the Simple \
                        Authentication and Security Layer framework and a few \
                        common SASL mechanisms.  SASL is used by network \
                        servers (e.g., IMAP, SMTP, XMPP) to request \
                        authentication from clients, and in clients to \
                        authenticate against servers.

depends_lib-append      port:gettext \
                        port:libgcrypt \
                        port:libiconv \
                        port:readline

master_sites            gnu:gsasl
distname                gsasl-${version}
dist_subdir             ${name}/${version}_1

checksums               rmd160  cee8e6f904117f44f139b62b18170d57275ceaec \
                        sha256  d32be15efd3a04cb19b232f721bdca02cc6ad7ab415df7d79fb2dd2c0da3e0be \
                        size    3541621

configure.args-append   --disable-gtk-doc \
                        --disable-ntlm \
                        --disable-silent-rules \
                        --disable-valgrind-tests \
                        --without-gnutls \
                        --without-gssapi-impl \
                        --with-libgcrypt \
                        --without-openssl \
                        --without-stringprep \
                        --with-packager=MacPorts

# <https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr>
configure.checks.implicit_function_declaration.whitelist-append \
                        __GNUC_PREREQ \
                        MIN \
                        alignof \
                        strchr \
                        unreachable

test.run                yes
test.target             check

default_variants-append +idn +starttls

# GSS framework was added in macOS 10.7
if {${os.platform} eq "darwin" &&
        ${os.subplatform} eq "macosx" &&
        ${os.major} >= 11} {
    default_variants-append +gssapi_native
} elseif {[variant_isset gssapi_native]} {
    known_fail              yes
} else {
    default_variants-append +gssapi_gss
}

variant doc \
        description {Install HTML documentation} {
    depends_build-append    port:gtk-doc
    configure.args-replace  --disable-gtk-doc --enable-gtk-doc
}

variant gssapi_gss \
        conflicts gssapi_mit gssapi_native \
        description {Use GNU GSSAPI implementation} {
    depends_lib-append      port:gss
    configure.args-replace  --without-gssapi-impl --with-gssapi-impl=gss
}

variant gssapi_mit \
        conflicts gssapi_gss gssapi_native \
        description {Use MIT GSSAPI implementation} {
    configure.args-replace  --without-gssapi-impl --with-gssapi-impl=mit
}

variant gssapi_native \
        conflicts gssapi_gss gssapi_mit \
        description {Use native GSSAPI implementation} {
    configure.args-replace  --without-gssapi-impl --with-gssapi-impl=framework
}

variant idn \
        description {Add non-ASCII support} {
    depends_lib-append      port:libidn
    configure.args-replace  --without-stringprep --with-stringprep
}

variant ntlm \
        description {Add NTLM support} {
    depends_lib-append      port:libntlm
    configure.args-replace  --disable-ntlm --enable-ntlm
}

variant starttls \
        description {Add STARTTLS support} {
    depends_lib-append      port:gnutls
    configure.args-replace  --without-gnutls --with-gnutls
}

livecheck.type          regex
livecheck.url           https://ftp.gnu.org/pub/gnu/gsasl/
livecheck.regex         "gsasl-(\[0-9]+(\\.\[0-9]+)*)\\.tar\\.gz"
