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

github.setup        BuGlessRB procmail 3.24 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          mail
license             {Artistic-1 GPL-2+}
maintainers         nomaintainer

description         A local mail delivery agent

long_description    The procmail mail processing program can be used \
                    to create mail-servers, mailing lists, sort your \
                    incoming mail into separate folders/files (real \
                    convenient when subscribing to one or more \
                    mailing lists or for prioritising your mail), \
                    preprocess your mail, start any programs upon \
                    mail arrival (e.g. to generate different chimes \
                    on your workstation for different types of mail) \
                    or selectively forward certain incoming mail \
                    automatically to someone. \
                    Procmail can be used: \
                    - and installed by an unprivileged user (for \
                      himself only). \
                    - as a drop in replacement for the local \
                      delivery agent /bin/mail (with biff/comsat \
                      support). \
                    - as a general mailfilter for whole groups of \
                      messages (e.g. when called from within \
                      sendmail.cf rules). \
                    The accompanying formail program enables you to \
                    generate autoreplies, split up digests/mailboxes \
                    into the original messages, do some very simple \
                    header-munging/extraction, or force mail into \
                    mail-format (with leading From line).

checksums           rmd160  c688a01fc1cecb61becec6b5471deac8caf8aac4 \
                    sha256  0804c719b5fc491aeec86f16646cb8588afa4adbc3cdf15e7cceb679dc76e596 \
                    size    299851

post-extract {
    move ${worksrcpath}/INSTALL ${worksrcpath}/INSTALL.README
}

patchfiles          patch-src-Makefile.0.diff \
                    patch-avoid-strlcat-strlcpy.diff \
                    procmail-3.24-modern-c.diff

post-patch {
    reinplace "s%^/\\*\\(#define\[ \t\]*DEF\[S\]*PATH\[ \t\]*\".*\\)\".*$%\\1:${prefix}/bin\"%" ${worksrcpath}/config.h
    reinplace "s%/etc/procmailrc%${prefix}/etc/procmailrc%" ${worksrcpath}/config.h
    reinplace "s%/usr/local%${prefix}%g" ${worksrcpath}/Makefile
    reinplace "s%(BASENAME)/man%(BASENAME)/share/man%" ${worksrcpath}/Makefile
}

use_configure       no

variant universal {}

build.env           "CC=${configure.cc} [get_canonical_archflags cc]"

build.args          BASENAME=${prefix} LOCKINGTEST=/tmp
destroot.args       BASENAME=${destroot}${prefix} LOCKINGTEST=/tmp install-suid