# -*- 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        mongrel2 mongrel2 1.12.2 v
revision            0
checksums           rmd160  111e1724cc6e679217e3a4398e4a13ada7ea834d \
                    sha256  3bffeae198c37a1efc9c12f77d5f1eb61cdf62b35d661babc2527dd030aa7d8f \
                    size    2855262

license             BSD
categories          www
platforms           darwin
maintainers         nomaintainer
description         The Language Agnostic Web Server
long_description    \
    Mongrel2 is an application, language, and network architecture agnostic \
    web server that focuses on web applications using modern browser \
    technologies.

homepage            http://mongrel2.org/
github.tarball_from releases
distname            ${name}-${github.tag_prefix}${version}
use_bzip2           yes

depends_lib         port:sqlite3 \
                    port:mbedtls \
                    port:zmq

patchfiles          mbedtls.patch \
                    no-tests.patch

use_configure       no

variant universal {}

configure.ldflags-append -bind_at_load -undefined dynamic_lookup

build.args-append   PREFIX=${prefix} \
                    CC=${configure.cc} \
                    OPTFLAGS="${configure.cflags} ${configure.cppflags} [get_canonical_archflags cc]" \
                    OPTLIBS="${configure.ldflags} [get_canonical_archflags ld]"

# The tests fail...
# https://github.com/mongrel2/mongrel2/issues/342
test.run            yes
test.target         tests
test.args           {*}${build.args}

destroot.args-append    PREFIX=${prefix}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${prefix}/share/examples/${name}
    
    xinstall -m 644 ${worksrcpath}/LICENSE ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/docs/manual/book.wiki ${destroot}${prefix}/share/doc/${name}/book.html

    xinstall -m 644 ${worksrcpath}/tests/config.sqlite ${destroot}${prefix}/share/examples/${name}/test-config.sqlite
    file copy {*}[glob ${worksrcpath}/examples/*] ${destroot}${prefix}/share/examples/${name}
}
