PortSystem          1.0
PortGroup   github  1.0

github.setup        keplerproject cgilua 5.1.4 v
github.tarball_from downloads

name                lua-${github.project}
license             MIT
categories          devel
platforms           darwin
maintainers         nomaintainer
description         Building Web Scripts with Lua
long_description    CGILua is a tool for creating dynamic Web pages and manipulating input \
					data from Web forms. CGILua allows the separation of logic and data \
					handling from the generation of pages, making it easy to develop web \
					applications with Lua.

checksums           md5     6c120f3bb235e1edd9baad762eb303c1 \
                    sha1    573da0ffbaed5c60eb6b2f1c5587d32f9cdc5a49 \
                    rmd160  e094af41d5162a0793b68f46597983a8d4d220e5

depends_lib         port:lua \
                    port:lua-luafilesystem

patchfiles          patch-Makefile.diff
use_configure       no
supported_archs     noarch
build {}
destroot.args        PREFIX="${prefix}"

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${prefix}/share/examples/${name}

    # binaries
    xinstall -m 755 -W ${worksrcpath}/src/launchers cgilua.cgi cgilua.fcgi \
        ${destroot}${prefix}/bin

    # documentation
    file copy  ${worksrcpath}/README \
                    ${worksrcpath}/doc/br \
                    {*}[glob ${worksrcpath}/doc/us/*] \
        ${destroot}${prefix}/share/doc/${name}

    # examples
    file copy  {*}[glob ${worksrcpath}/examples/*] \
                    ${worksrcpath}/tests \
        ${destroot}${prefix}/share/examples/${name}

    # set module files non-executable
    file attributes       ${destroot}${prefix}/share/lua/5.1/cgilua.lua    -permissions -x
    foreach a_file [glob ${destroot}${prefix}/share/lua/5.1/cgilua/*.lua] {
        file attributes ${a_file} -permissions -x
    }
}