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

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

name                msmtp
version             1.8.34
revision            0
categories          mail
maintainers         {ra1nb0w @ra1nb0w} openmaintainer
license             GPL-3+
description         SMTP client that can be used as an SMTP plugin for Mutt
long_description    msmtp is an SMTP client that can be used as an SMTP \
                    plugin for Mutt and probably other MUAs (mail user \
                    agents). It forwards mails to an SMTP server which \
                    does the delivery. To use this program, create a \
                    configuration file with your mail account(s) and tell \
                    your MUA to call msmtp instead of /usr/sbin/sendmail.

homepage            https://marlam.de/msmtp/
master_sites        ${homepage}releases/
use_xz              yes

checksums           rmd160  d9955f50173953251a04fb3f862d4f034927b0fa \
                    sha256  84e8fe2a5a80a1ee7802013b3fbdb846a3f27a4163cf37a1c6d7c7f888873ead \
                    size    463940

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

configure.args      --disable-gai-idn \
                    --disable-silent-rules \
                    --without-libgsasl \
                    --without-libidn \
                    --without-libsecret \
                    --without-macosx-keyring \
                    --without-msmtpd \
                    --without-tls

startupitem.name    msmtpd

platform macosx {
    configure.args-replace  --without-macosx-keyring --with-macosx-keyring
}

livecheck.url       ${homepage}download/

default_variants    +idn \
                    +sasl \
                    +tls_gnu

variant idn description {Support internationalized domain names} {
    depends_lib-append      port:libidn2
    configure.args-replace  --without-libidn --with-libidn
}

variant mta description {Use msmtp as the system MTA} {
    conflicts               postfix opensmtpd

    configure.args-replace  --without-msmtpd --with-msmtpd

    startupitem.create      yes
    startupitem.executable  ${prefix}/bin/msmtpd
}

variant sasl description {Support extra SASL mechanisms} {
    depends_lib-append      port:libgsasl
    configure.args-replace  --without-libgsasl --with-libgsasl
}

variant tls_gnu description {Support TLS via GnuTLS} conflicts tls_libre {
    depends_lib-append      path:lib/pkgconfig/gnutls.pc:gnutls
    configure.args-replace  --without-tls --with-tls=gnutls
}

variant tls_libre description {Support TLS via LibreSSL} conflicts tls_gnu {
    depends_lib-append      port:libressl
    configure.args-replace  --without-tls --with-tls=libtls
}

post-destroot {
    if {[variant_isset mta]} {
        ln -s ${prefix}/bin/msmtp ${destroot}${prefix}/sbin/sendmail
    }
}
