# -*- 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 100367 2012-12-09 17:26:51Z and.damore@macports.org $

PortSystem          1.0
PortGroup           github 1.0 

github.setup        zedshaw mongrel2 1.8.0 v
license             BSD
categories          www
platforms           darwin
maintainers         and.damore openmaintainer
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.

checksums           md5     0ec44b3cd3518a8e58c591c932075b52 \
                    sha1    27c942b5c3c72c65084b355f6cbafd814f8cd64b \
                    rmd160  f3ad949a503d5e9b36abf74333d0af3e0615fd1f

use_configure       no
use_parallel_build  no
depends_lib         path:lib/libzmq.dylib:zmq22 \
                    port:sqlite3

patch {
    reinplace "s|-rdynamic||" ${worksrcpath}/Makefile
    reinplace "s|gcc|\$(CC)|" ${worksrcpath}/tools/procer/Makefile
}

# override variables in build and destroot phases
build.args-append   PREFIX=${prefix} \
                    CC=${configure.cc} \
                    OPTFLAGS="${configure.cflags} -I${prefix}/include [get_canonical_archflags cc]" \
                    OPTLIBS="${configure.ldflags} -L${prefix}/lib [get_canonical_archflags ld]"
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
    eval file copy [glob ${worksrcpath}/examples/*] ${destroot}${prefix}/share/examples/${name}
}

