PortSystem          1.0

name                ejabberd
version             24.02
revision            0
categories          net
license             GPL-2
maintainers         {ciserlohn @ci42}
description         ejabberd is an XMPP application server.
long_description    ${description} ejabberd stands for "Erlang Jabber Daemon"

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

checksums           rmd160  1be237435f77b1403a3b30e8b45cc07a30d09c14 \
                    sha256  b6d48d3bf2bef368e9321e35436381c86d78444b9042649c6c4aab0089395c07 \
                    size    2531049

extract.suffix      .tar.gz

build.env-append    CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CPP=${configure.cpp} \
                    CFLAGS=${configure.cflags} \
                    CXXFLAGS=${configure.cxxflags} \
                    LDFLAGS=${configure.ldflags}

depends_build       port:git \
                    port:autoconf \
                    port:automake

depends_lib         port:erlang \
                    port:expat \
                    port:libyaml \
                    path:lib/libssl.dylib:openssl \
                    port:libiconv \
                    port:zlib

# erlang is not universal
universal_variant   no

configure.cmd       ./autogen.sh && ./configure

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

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

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

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

}

variant odbc description {Enable ODBC support} {
    depends_lib-append      port:unixODBC
    configure.args-append   --enable-odbc
}

notes "
Before running ${name} for the first time, you must copy the sample\
configuration files:

cd ${etc}/
"
foreach file ${conf_files} {
    notes-append "cp ${file}.sample ${file}"
}

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