# -*- 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

PortSystem          1.0
PortGroup           github 1.0

github.setup        maxmind mod_maxminddb 1.1.0
revision            0
checksums           rmd160  bab39c27d8aba3e6a6cb8f010ebdab3ef23575da \
                    sha256  b31e63764ddcc1379229059a4726c733ee0538018727b1336d02afaaa8940782 \
                    size    99821

categories          www
platforms           darwin
maintainers         nomaintainer
license             Apache-2

description         This module allows you to query MaxMind DB files from Apache 2.2+ \
                    using the libmaxminddb library.

long_description    ${description}

homepage            https://maxmind.github.io/mod_maxminddb/
github.tarball_from releases

depends_lib         port:apache2 \
                    port:libmaxminddb

set apxs            ${prefix}/bin/apxs
set ddir            ${prefix}/share/doc/${name}
set dbdir           ${prefix}/share/GeoIP
set mdir            ${prefix}/lib/apache2/modules

patchfiles          patch-Wl.diff

configure.args      --with-apxs=${apxs}

test.run            yes
test.target         check

destroot {
    xinstall -d -m 0755 ${destroot}${ddir} ${destroot}${dbdir} ${destroot}${mdir}
    xinstall -m 0644 -W ${worksrcpath} Changes.md CONTRIBUTING.md \
        LICENSE README.md TESTING.md ${destroot}${ddir}
    xinstall -m 0755 ${worksrcpath}/src/.libs/${name}.so ${destroot}${mdir}

    set plist [open "${destroot}${dbdir}/ReadMe_DBFiles.md" w 0644]
    puts ${plist} "## MaxMindDB Files"
    puts ${plist} ""
    puts ${plist} "The database files can be downloaded from here:"
    puts ${plist} ""
    puts ${plist} "  - <https://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads>"
    puts ${plist} ""
    puts ${plist} "There are 2 versions, and a MD5 checksum file of each."
    puts ${plist} ""
    close ${plist}
}

notes "
If this is your first install, you might want to enable ${name} in Apache:

    cd ${mdir}
    sudo ${apxs} -a -e -n \"maxminddb\" mod_maxminddb.so

And then relaunch Apache:

    $ sudo apachectl restart

- - -

Examples/setup: https://github.com/maxmind/mod_maxminddb#examples
                https://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads
                ---> ${dbdir}
"
