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

name                mailutils
version             3.17
revision            1

categories          mail
license             GPL-3

maintainers         nomaintainer

description         General-Purpose Mail Packages
long_description    Mailutils is a swiss army knife of electronic mail handling. \
                    It offers a rich set of utilities and daemons for processing e-mail.

homepage            https://mailutils.org/
master_sites        gnu:mailutils
use_xz              yes

checksums           rmd160  47136641b8119c27b98897b995f9b53844022a24 \
                    sha256  fa49bacec37566fe52f88221d3871673a633aeee0cd923cc3a8e65bbef2b84e9 \
                    size    3219484

# https://trac.macports.org/ticket/62993
patchfiles          patch-configure-libtool.diff

configure.args      --disable-silent-rules \
                    --without-readline \
                    --without-ldap \
                    --disable-build-servers \
                    --without-guile \
                    --without-gnutls \
                    --without-fribidi \
                    --without-tcp-wrappers \
                    --enable-cxx \
                    --disable-python \
                    --without-dbm \
                    --without-gdbm \
                    --without-ndbm \
                    --without-berkeley-db \
                    --without-mysql \
                    --without-postgres \
                    --without-odbc \
                    --without-tokyocabinet \
                    --without-kyotocabinet \
                    --without-gsasl \
                    --without-gssapi

variant readline description {Enable readline} {
    configure.args-replace    --without-readline --with-readline
    depends_lib-append        port:readline
}

variant ldap description {Build with ldap support} {
    configure.args-replace    --without-ldap --with-ldap
}

variant server description {Build servers} {
    configure.args-replace    --disable-build-servers --enable-build-servers
}

variant guile description {Enable support for Guile scripting} {
    configure.args-replace    --without-guile --with-guile
    depends_lib-append        port:guile-2.2
    configure.env-append      GUILE_CONFIG=${prefix}/bin/guile-config-2.2
    configure.env-append      GUILE_SNARF=${prefix}/bin/guile-snarf-2.2
    configure.env-append      GUILE_TOOLS=${prefix}/bin/guile-tools-2.2
    configure.env-append      GUILE=${prefix}/bin/guile-2.2

    configure.args-append     --with-guile-site-dir=${prefix}/share/guile/site/2.2

    post-patch {
        reinplace "s/GUILE_BINDIR=`guile-config info bindir`/GUILE_BINDIR=`\$GUILE_CONFIG info bindir`/" ${worksrcpath}/configure
    }
}

variant gnutls description {Build with GNU TLS support} {
    configure.args-replace    --without-gnutls --with-gnutls
    depends_lib-append        path:lib/pkgconfig/gnutls.pc:gnutls
}

variant fribidi description {Build with fribidi support} {
    configure.args-replace    --without-fribidi --with-fribidi
    depends_lib-append        port:fribidi
}

variant tcp_wrappers description {Build with tcp_wrappers support} {
    configure.args-replace    --without-tcp-wrappers --with-tcp-wrappers
    depends_build-append      port:tcp_wrappers
}

variant gdbm description {Build with GNU DBM support} {
    configure.args-replace    --without-gdbm --with-gdbm
    depends_lib-append        port:gdbm
}

variant ndbm description {Build with NDBM support} {
    configure.args-replace    --without-ndbm --with-ndbm
}

variant gssapi description {Enable gssapi} {
    configure.args-replace    --without-gssapi --with-gssapi
    depends_lib-append        port:kerberos5
}

variant unistring description {Enable libunistring} {
    configure.args-replace    --without-unistring --with-unistring
    depends_lib-append        port:libunistring
}

variant gsasl description {Enable GNU SASL} {
    configure.args-replace    --without-gsasl --with-gsasl
    depends_lib-append        port:libgsasl
}

variant python39 description {Enable support for Python 3.9 scripting} {
    set py_ver                3.9
    set py_ver_nodot          [string map {. {}} ${py_ver}]

    configure.ldflags-append  -L${frameworks_dir}/Python.framework/Versions/${py_ver}/lib
    configure.args-append     PYTHON_CONFIG=${prefix}/bin/python${py_ver}-config

    configure.args-replace    --disable-python --enable-python
    configure.python          ${prefix}/bin/python${py_ver}
    depends_lib-append        port:python${py_ver_nodot}
}

default_variants +ldap +tcp_wrappers +unistring
