# $Id$
PortSystem 1.0

name                lua-luafilesystem
version             1.5.0
revision            5
license             MIT
categories          devel
platforms           darwin
maintainers         nomaintainer
description         File System Library for the Lua Programming Language
long_description    LuaFileSystem is a Lua library developed to complement the set of functions \
                    related to file systems offered by the standard Lua distribution.

homepage            http://keplerproject.github.com/luafilesystem/
master_sites        http://github.com/downloads/keplerproject/luafilesystem

checksums           md5     3cf4882bbce956e7a0b010f148f194a3 \
                    sha1    1ee2ca3b5dbc3cf7c21c7168a0873b2983b7e241 \
                    rmd160  db1e597046d47ab12df202e7c65fb3b815c9f922

distname            luafilesystem-${version}
depends_lib         port:lua
patchfiles          patch-config.diff

post-patch {
   reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/config
   reinplace "s|luaL_reg |luaL_Reg |g" ${worksrcpath}/src/lfs.c
   reinplace "/^LUA_LIBDIR=/s,lib/lua/5.1,lib/lua/5.2," ${worksrcpath}/config
}

use_configure       no

variant universal {}

build.args          CC="${configure.cc}" \
                    CFLAGS="${configure.cflags} -I${prefix}/include [get_canonical_archflags cc] -DLUA_COMPAT_MODULE" \
                    LDFLAGS="${configure.ldflags} -llua -lm [get_canonical_archflags ld]"

build.target        lib

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${prefix}/share/examples/${name}
    
    xinstall -m 644 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}
    eval xinstall -m 644 [glob ${worksrcpath}/doc/us/*] ${destroot}${prefix}/share/doc/${name}
    eval xinstall -m 644 [glob ${worksrcpath}/tests/*] ${destroot}${prefix}/share/examples/${name}
}