# $Id: Portfile 78711 2011-05-18 21:17:48Z pixilla@macports.org $

PortSystem          1.0
PortGroup           archcheck 1.0

name                dovecot
conflicts           dovecot2
epoch               20060722
version             1.2.17
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          mail
maintainers         jberry openmaintainer
platforms           darwin

description         Secure, fast imap and pop3 server
long_description    Dovecot is an IMAP and POP3 server for Linux/UNIX-like \
                    systems, written with security primarily in mind. Although \
                    it's written in C, it uses several coding techniques to \
                    avoid most of the common pitfalls.

homepage            http://dovecot.org/
master_sites        ${homepage}releases/${branch}

checksums           sha1    457b16791a15e739c6bc8b02bc9c78f9ad794e39 \
                    rmd160  59f619dba2aadef3cccd6ceb045a2e75a11700a2

depends_build       port:pkgconfig
depends_lib         port:libiconv \
                    port:zlib \
                    port:openssl
archcheck.files     lib/libiconv.dylib \
                    lib/libz.dylib \
                    lib/libssl.dylib

configure.args      --sysconfdir=${prefix}/etc/dovecot \
                    --localstatedir=${prefix}/var \
                    --with-ioloop=kqueue \
                    --with-ssl=openssl \
                    --with-ssldir=${prefix}/etc/ssl \
                    --enable-header-install

configure.cppflags  -I${prefix}/include/openssl

post-destroot {
    # Create the dovecot user and group
    addgroup dovecot
    set gid [existsgroup dovecot]
    adduser dovecot gid=${gid} realname=Dovecot
}

variant postgres requires postgresql80 description {Obsolete synonym for postgresql80 variant} {}

variant postgresql80 conflicts postgresql81 postgresql82 postgresql83 postgresql84 description {Enable PostgreSQL 8.0 support} {
    depends_lib-append          port:postgresql80
    archcheck.files-append      lib/postgresql80/libpq.dylib
    configure.args-append       --with-pgsql
    configure.ldflags-append    -L${prefix}/lib/postgresql80
    configure.cppflags-append   -I${prefix}/include/postgresql80
}

variant postgresql81 conflicts postgresql80 postgresql82 postgresql83 postgresql84 description {Enable PostgreSQL 8.1 support} {
    depends_lib-append          port:postgresql81
    archcheck.files-append      lib/postgresql81/libpq.dylib
    configure.args-append       --with-pgsql
    configure.ldflags-append    -L${prefix}/lib/postgresql81
    configure.cppflags-append   -I${prefix}/include/postgresql81
}

variant postgresql82 conflicts postgresql80 postgresql81 postgresql83 postgresql84 description {Enable PostgreSQL 8.2 support} {
    depends_lib-append          port:postgresql82
    archcheck.files-append      lib/postgresql82/libpq.dylib
    configure.args-append       --with-pgsql
    configure.ldflags-append    -L${prefix}/lib/postgresql82
    configure.cppflags-append   -I${prefix}/include/postgresql82
}

variant postgresql83 conflicts postgresql80 postgresql81 postgresql82 postgresql84 description {Enable PostgreSQL 8.3 support} {
    depends_lib-append          port:postgresql83
    archcheck.files-append      lib/postgresql83/libpq.dylib
    configure.args-append       --with-pgsql
    configure.ldflags-append    -L${prefix}/lib/postgresql83
    configure.cppflags-append   -I${prefix}/include/postgresql83
}

variant postgresql84 conflicts postgresql80 postgresql81 postgresql82 postgresql83 description {Enable PostgreSQL 8.4 support} {
    depends_lib-append          port:postgresql84
    archcheck.files-append      lib/postgresql84/libpq.dylib
    configure.args-append       --with-pgsql
    configure.ldflags-append    -L${prefix}/lib/postgresql84
    configure.cppflags-append   -I${prefix}/include/postgresql84
}

variant mysql5 description {Enable MySQL support} {
    depends_lib-append          path:bin/mysql_config5:mysql5
    archcheck.files-append      lib/mysql5/mysql/libmysqlclient.dylib
    configure.args-append       --with-mysql
    configure.ldflags-append    -L${prefix}/lib/mysql5/mysql
    configure.cppflags-append   -I${prefix}/include/mysql5/mysql
}

variant ldap description {Enable LDAP support} {
    configure.args-append       --with-ldap
    archcheck.files-append      lib/libldap.dylib
    depends_lib-append          port:openldap
}

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/dovecot
startupitem.pidfile     auto ${prefix}/var/run/dovecot/master.pid

livecheck.type  regex
livecheck.url   ${homepage}download.html
livecheck.regex "${name}-(${branch}\\.\\d+(\\.\\d+)?)${extract.suffix}"
