# $Id: Portfile 67540 2010-05-12 07:55:35Z jmr@macports.org $

PortSystem          1.0
PortGroup           archcheck 1.0

name                dovecot
epoch               20060722
version             1.2.11
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           md5     bdac013fd57aa616ea4bdd9ac34557c6 \
                    sha1    97e63377be3641d4c7aa5a0c6d4e2bd602d45972 \
                    rmd160  cb2090a21e99cfaf98d7cbfdc98adbf42df6e2cc

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

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}-(\\d+\\.\\d+(\\.\\d+)?).tar.gz"
