# -*- 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                courier-imap
version             5.2.6
revision            0
checksums           rmd160  caf93c9b9c3347a6097405843935449553b8c6b9 \
                    sha256  ac89cbd8e84bfb9e0e7bc9130304b0202a9d3192823d13956c88023f91661581 \
                    size    3411210

categories          mail
license             {GPL-3 OpenSSLException}
maintainers         nomaintainer
description         IMAP server
long_description    This package contains the standalone Courier IMAP server, \
                    which is used to provide IMAP access to local mailboxes. \
                    Courier-IMAP is provided here as a separate package that \
                    can be used with other mail servers as well.

homepage            https://www.courier-mta.org/imap/
master_sites        sourceforge:project/courier/imap/${version} freebsd
use_bzip2           yes

patchfiles-append   patch-makefile.diff

depends_build-append \
                    port:pkgconfig \
                    path:libexec/coreutils/libstdbuf.so:coreutils

depends_lib-append  path:lib/libssl.dylib:openssl \
                    port:courier-authlib \
                    port:db48 \
                    port:libidn2

set authdaemondir   ${prefix}/var/run/authdaemon.courier-imap

configure.args      --bindir=${prefix}/bin \
                    --mandir=${prefix}/share/man \
                    --sysconfdir=${prefix}/etc/${name} \
                    --datadir=${prefix}/share/${name} \
                    --localstatedir=${prefix}/var/run \
                    --with-piddir=${prefix}/var/run \
                    --with-authdaemonvar=${authdaemondir} \
                    --with-db=db \
                    --enable-unicode \
                    --disable-root-check \
                    --with-notice=unicode

configure.cflags    "-I${prefix}/include/db48 -I${prefix}/include"
configure.cppflags  "-I${prefix}/include/db48 -I${prefix}/include"
configure.ldflags   "-L${prefix}/lib/db48 -L${prefix}/lib"

destroot.target     install install-configure

post-destroot {
    xinstall -m 0755 -d ${destroot}${authdaemondir}
    destroot.keepdirs ${destroot}${authdaemondir}
}

startupitem.create  yes
startupitem.init    \
". ${prefix}/etc/courier-imap/imapd\n. ${prefix}/etc/courier-imap/imapd-ssl\n"
startupitem.start   "${prefix}/libexec/imapd-ssl.rc start"
startupitem.stop    "${prefix}/libexec/imapd-ssl.rc stop"

test.run            no
test.ignore_archs   yes

# Limit the length of the minor and patch version components to avoid picking
# up development versions (that contain a YYYYMMDD timestamp).
livecheck.regex     "[quotemeta ${name}]-(\\d+(\\.\\d{1,7})*)[quotemeta ${extract.suffix}]"