# -*- 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 89913 2012-02-14 23:09:21Z and.damore@macports.org $

PortSystem          1.0

name                mongrel2
version             1.7.5
revision            1
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.

homepage            http://mongrel2.org
# MEMO sources are available on github as well
master_sites        ${homepage}/static/downloads
use_bzip2           yes
checksums           md5     c243efc59e5972fa381bd13a7eeafdc7 \
                    sha1    456561fe04f1c0ee4a996cfc9deadab8c57ee6dc \
                    rmd160  e623bb17a42dfa509d9d14c1208b8fb6047f22a2

use_configure       no
depends_lib         port:gmake \
                    path:lib/libzmq.dylib:zmq \
                    port:sqlite3

patch {
    reinplace "s|-rdynamic||" ${worksrcpath}/Makefile
}

# override variables in Makefile for 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}
}

