# -*- 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 118489 2014-04-03 09:49:39Z and.damore@macports.org $

PortSystem          1.0

name                lua-luaexpat
version             1.3.0
categories          devel
license             MIT
platforms           darwin
maintainers         nomaintainer
description         SAX XML parser
long_description    LuaExpat is a SAX XML parser based on the Expat library. \
                    LuaExpat is free software and uses the same license as Lua 5.1.

depends_build       port:lua
depends_lib         port:expat

#  bind lua-expat to current port:lua version in dports tree
#  set commit hash for tag 1.3.0 on remote mercurial repository
set lua_version     5.2
set hash            1adb0c435b54

homepage            http://www.keplerproject.org/luaexpat/index.html

master_sites        http://code.matthewwild.co.uk/lua-expat/archive

distname            ${hash}

checksums           sha1    794426889ddfdfe08d552495012b1d6a05826c6b \
                    rmd160  113e88216cfd9d379ba76c11fb6fc6902478d888

worksrcdir          lua-expat-${hash}

use_configure       no

build.target
build.args          CC=${configure.cc} \
                    CFLAGS="${configure.cppflags} ${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld] -llua" \
                    LUA_INC="" \
                    EXPAT_INC="" \
                    COMMON_LDFLAGS="-bundle -undefined dynamic_lookup"

destroot.args       LUA_LDIR=${prefix}/share/lua/${lua_version} \
                    LUA_CDIR=${prefix}/lib/lua/${lua_version}

patchfiles          patch-Makefile.diff

post-destroot {
    #  install docs
    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 -W ${worksrcpath} README \
             ${destroot}${prefix}/share/doc/${name}
    foreach f [glob ${worksrcpath}/doc/us/*] {
        xinstall -m 0644 $f ${destroot}${prefix}/share/doc/${name}
    }
        
    #  install tests
    xinstall -d -m 0755 ${destroot}${prefix}/share/examples
    copy ${worksrcpath}/tests ${destroot}${prefix}/share/examples/${name}
}

