# -*- 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 82620 2011-08-16 22:23:37Z ryandesign@macports.org $

PortSystem          1.0

name                lpeg
version             0.10.2
categories          devel
platforms           darwin
maintainers         gmail.com:andremm

description         Parsing Expression Grammars for Lua

long_description    LPeg is a new pattern-matching library for Lua, based on \
                    Parsing Expression Grammars (PEGs).

homepage            http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html
master_sites        http://www.inf.puc-rio.br/~roberto/lpeg/

checksums           sha1    f2cd5857efb6e1bb02dfb9fbd68e74a451467462 \
                    rmd160  77dc2f7ca88ac84e6f185cf6077aaf88a130c3af

depends_build       port:pkgconfig

depends_lib         port:lua

patchfiles          patch-makefile.diff

use_configure       no

variant universal {}

build.target
build.args          CC="${configure.cc} [get_canonical_archflags]" \
                    LUADIR=${prefix}/include

destroot {
    set lua_cmod [exec ${prefix}/bin/pkg-config lua --variable INSTALL_CMOD]
    set lua_lmod [exec ${prefix}/bin/pkg-config lua --variable INSTALL_LMOD]

    xinstall -m 755 -d ${destroot}${lua_cmod} ${destroot}${lua_lmod}

    xinstall ${worksrcpath}/lpeg.so ${destroot}${lua_cmod}
    xinstall ${worksrcpath}/re.lua ${destroot}${lua_lmod}

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}/html/
    xinstall -m 644 ${worksrcpath}/HISTORY ${destroot}${prefix}/share/doc/${name}/
    xinstall -m 644 -W ${worksrcpath} lpeg-128.gif lpeg.html re.html ${destroot}${prefix}/share/doc/${name}/html/
}
