PortSystem 1.0
name            mailx
version         12.4
revision        5
categories      mail
license         {BSD-old BSD}
maintainers     toby
description     Heirloom mailx
long_description \
    Mailx is derived from Berkeley Mail and is intended provide the \
    functionality of the POSIX mailx command with additional support for MIME, \
    IMAP, POP3, SMTP, and S/MIME. It provides enhanced features for \
    interactive use, such as caching and disconnected operation for IMAP, \
    message threading, scoring, and filtering. It is also usable as a mail \
    batch language, both for sending and receiving mail.
homepage        http://heirloom.sourceforge.net/mailx.html
platforms       darwin

master_sites    sourceforge:project/heirloom/heirloom-mailx/${version}
use_bzip2       yes
checksums       md5 0c93759e34200eb56a0e7c464680a54a \
                sha1 b1e105adf9d36269daf317dedf68b6e4cca404a7 \
                rmd160 8244d04d0a0058fdbe9867ca503c7cda8d580154

depends_lib     port:kerberos5 \
                port:libiconv \
                path:lib/libssl.dylib:openssl

patchfiles      patch-Makefile \
                patch-junk.c \
                patch-maildir.c \
                patch-makeconfig \
                patch-openssl.c

# CVE-2004-2771, CVE-2014-7844
# http://seclists.org/oss-sec/2014/q4/1066
patchfiles-append \
                patch-0001-outof-Introduce-expandaddr-flag.diff \
                patch-0002-unpack-Disable-option-processing-for-email-addresses.diff \
                patch-0003-fio_c-Unconditionally-require-wordexp-support.diff \
                patch-0004-globname-Invoke-wordexp-with-WRDE_NOCMD-CVE-2004-277.diff

post-patch {
    reinplace "s|__PREFIX__|${prefix}|" "${worksrcpath}/Makefile"
    reinplace "s|__DESTROOT__|${destroot}|" "${worksrcpath}/Makefile"
    reinplace "s|__CC__|${configure.cc}|" "${worksrcpath}/Makefile"
    reinplace "s|__CFLAGS__|${configure.cflags} [get_canonical_archflags cc]|" "${worksrcpath}/Makefile"
    reinplace "s|__LDFLAGS__|${configure.ldflags} [get_canonical_archflags ld]|" "${worksrcpath}/Makefile"
}

configure.cmd   /bin/sh
configure.args  makeconfig
configure.pre_args
configure.universal_args

livecheck.regex /${name}-(\[0-9.\]+)${extract.suffix}