# $Id: Portfile 65388 2010-03-25 22:54:57Z ryandesign@macports.org $

PortSystem          1.0

name                ejabberd
version             2.1.3
categories          net
platforms           darwin
maintainers         nomaintainer
description         ejabberd is an XMPP application server.
long_description    ${description} ejabberd stands for "Erlang Jabber Daemon"

homepage            http://www.process-one.net/en/ejabberd/
master_sites        http://www.process-one.net/downloads/ejabberd/${version}/

checksums           md5     e5c87eda5312a6e8a53df0f9b4844b69 \
                    sha1    77fdf18c0bb3b25cf9045e0c833ba4d82f180469 \
                    rmd160  c57672928e30f71ec66636dd5e76adb802f17b03

worksrcdir          ${worksrcdir}/src

depends_lib         port:erlang \
                    port:expat \
                    port:openssl \
                    port:libiconv \
                    port:zlib

configure.args      --with-expat=${prefix} \
                    --with-zlib=${prefix} \
                    --with-openssl=${prefix}

# All ejabberd configuration files.
set conf_files      {ejabberd.cfg ejabberdctl.cfg inetrc}

destroot.keepdirs   ${destroot}${prefix}/var/log/ejabberd/

post-destroot {
    # Create sample configuration files so they don't get overwritten by an
    # update.
    set etc ${destroot}${prefix}/etc/ejabberd
    foreach file ${conf_files} {
        file rename ${etc}/${file} ${etc}/${file}.sample
    }

    # Install documentation.
    set doc ${destroot}${prefix}/share/doc
    xinstall -d ${doc}
    file copy ${worksrcpath}/../doc ${doc}/${name}-${version}
}

post-install {
    ui_msg "****************************************************************"
    ui_msg "*                                                              *"
    ui_msg "* If you run ejabberd for the first time, then you must rename *"
    ui_msg "* the following configuration files by removing the .sample    *"
    ui_msg "* extension:                                                   *"
    ui_msg "*                                                              *"
    ui_msg "* cd ${prefix}/etc/ejabberd/                                  *"
    foreach file ${conf_files} {
        ui_msg "* mv ${file}.sample ${file}"
    }
    ui_msg "*                                                              *"
    ui_msg "****************************************************************"
}

livecheck.type      regex
livecheck.url       ${homepage}release_notes
livecheck.regex     "${name} (\\d+(?:\\.\\d+)*)"
