# -*- 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
# $Id: Portfile 92309 2012-04-24 22:42:05Z pixilla@macports.org $

PortSystem          1.0
name                mod_security2
set name_package    modsecurity-apache
version             2.6.5
categories          www security
platforms           darwin
maintainers         pixilla openmaintainer
description         Apache 2 intrusion detection and prevention engine for web applications
long_description    ModSecurity is an open source intrusion detection and \
                    prevention engine for web applications. It operates \
                    embedded into the web server, acting as a powerful \
                    umbrella - shielding applications from attacks.
homepage            http://www.modsecurity.org
master_sites        sourceforge:mod-security
distname            ${name_package}_${version}

checksums           rmd160  e5df3c4915f08e902def1645dd18b21b78f21a94 \
                    sha256  5bc57fe42825e87fbccab1d88ba5480eaba32c5a166802ac7aa6daae19b44e5f

worksrcdir          ${distname}

depends_lib         port:apache2 \
                    port:libxml2 \
                    port:lua \
                    port:curl

configure.args      --with-apxs=${prefix}/apache2/bin/apxs \
                    --with-pcre=${prefix}/bin/pcre-config \
                    --with-apr=${prefix}/bin/apr-1-config \
                    --with-apu=${prefix}/bin/apu-1-config \
                    --with-curl=${prefix}/bin/curl-config \
                    --with-libxml=${prefix} \
                    --with-lua=${prefix}

destroot.violate_mtree yes

destroot {
    xinstall -d -m 755 ${destroot}${prefix}/apache2/modules
    xinstall -m 644 -W ${worksrcpath}/apache2/.libs mod_security2.so \
                        ${destroot}${prefix}/apache2/modules
    xinstall -m 755 -W ${worksrcpath}/mlogc mlogc mlogc-batch-load.pl \
                        ${destroot}${prefix}/bin
    xinstall -m 755 -W ${worksrcpath}/tools rules-updater.pl \
                        ${destroot}${prefix}/bin
    xinstall -m 755 -W ${worksrcpath}/mlogc mlogc-default.conf \
                        ${destroot}${prefix}/etc
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} CHANGES LICENSE NOTICE README.TXT \
                        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type      regex
livecheck.regex     "(?!${name_package}).*${name_package}_((?!${extract.suffix}).*)${extract.suffix}"

notes "

# Now edit ${prefix}/apache2/conf/httpd.conf and add the following lines at the end of the LoadModules section:
    LoadFile ${prefix}/lib/libxml2.dylib
    LoadFile ${prefix}/lib/liblua.dylib
    LoadModule security2_module modules/mod_security2.so

# And finally reload apache.
    $ sudo apachectl graceful

"
