# -*- 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
PortGroup           makefile 1.0

github.setup        mongrel2 mongrel2 1.13.0 v
revision            0
categories          www
license             BSD
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            https://mongrel2.org

distname            ${name}-${github.tag_prefix}${version}
use_bzip2           yes
checksums           rmd160  3f4b0a678785bcb0496bcd7fa6b2cb22ca9827ee \
                    sha256  b6f1f50c9f65b605342d8792b1cc8a1c151105339030313b9825b6a68d400c10 \
                    size    2848288
github.tarball_from releases

patchfiles          no-tests.patch \
                    patch-Makefile.diff

depends_lib-append  port:sqlite3 \
                    port:mbedtls \
                    path:lib/libzmq.dylib:zmq

compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

variant universal   {}

configure.ldflags-append \
                    -bind_at_load -undefined dynamic_lookup

build.args-append   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}

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}
}
