# $Id$
PortSystem          1.0

PortGroup           github 1.0 
github.setup        keplerproject rings 1.2.3 v
github.tarball_from downloads

name                lua-rings
license             MIT
categories          devel
maintainers         nomaintainer
platforms           darwin
description         Multiple Lua States
long_description    Rings is a library which provides a way to create new Lua states from \
					within Lua. It also offers a simple way to communicate between the \
					creator (master) and the created (slave) states.

depends_lib         port:lua
checksums           md5     cba2e8a961fa4f76ebf4972c6044e824 \
                    sha1    788234fb446ee2415fd4be894eb4ad65ef9b2662 \
                    rmd160  3ff0989ec77c39f3711e97af2886e548254f6af1

# package configure script is not from autotools and only searches for lua binary prefix
# we patch it and force it to ${prefix}
patchfiles          patch-config.diff
post-patch {
    reinplace "s|%PREFIX%|${prefix}|g" ${worksrcpath}/config
    reinplace "s|%CC%|${configure.cc}|g" ${worksrcpath}/config
}

variant universal {}

# it is needed to manually set flags env variable as well
build.env-append    CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld] -llua -lm" 

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    eval file copy ${worksrcpath}/README \
                         [glob ${worksrcpath}/doc/us/*] \
        ${destroot}${prefix}/share/doc/${name}

    xinstall -d ${destroot}${prefix}/share/examples/${name}
    xinstall -m 644 ${worksrcpath}/tests/sample.lua \
                    ${worksrcpath}/tests/sample_state.lua \
        ${destroot}${prefix}/share/examples/${name}
    xinstall -m 755 ${worksrcpath}/tests/test.lua \
        ${destroot}${prefix}/share/examples/${name}
}