# $Id: Portfile 90297 2012-03-01 06:16:13Z and.damore@macports.org $
PortSystem          1.0
name                luarocks
version             2.0.8
categories          devel
platforms           darwin
maintainers         and.damore openmaintainer
supported_archs     noarch

description         Manager for rocks, lua extensions.
long_description    \
    LuaRocks is a deployment and management system for Lua modules that allows \
    you to install self-contained modules (\"rocks\") which also contain \
    version dependency information. It handles both install time dependencies \
    and runtime version check. LuaRocks supports local and remote \
    repositories, and multiple local rocks trees.

homepage            http://www.luarocks.org/
master_sites        http://luarocks.org/releases/
depends_run         port:lua

checksums           rmd160  b6a83fe329b7f305f7e0b99bf64f62d2324b15db \
                    sha256  f8abf1ab03b744a817721a0ff4a0ee454e068735efaa8d1aadcfcd0f07cdaa88

configure.args      --with-lua=${prefix} \
                    --rocks-tree=${prefix}/share/${name}

patchfiles          patch-src_luarocks_cfg.lua.diff
post-patch {
    reinplace   "s|%PREFIX%|${prefix}|g"       ${worksrcpath}/src/luarocks/cfg.lua
    reinplace "s|%COMPILER%|${configure.cc}|g" ${worksrcpath}/src/luarocks/cfg.lua
}

use_parallel_build  no

variant md5 conflicts openssl description { Use md5 as checker } {
    configure.args-append   --with-md5-checker=md5sum
}
    
variant openssl conflicts md5 description { Use openssl as checker } {
    configure.args-append   --with-md5-checker=openssl
    depends_run-append  port:openssl
}

if {![variant_isset md5]} {
    default_variants +openssl
}

variant wget conflicts curl description { Use wget as downloader } {
    configure.args-append   --with-downloader=wget
    depends_run-append  port:wget
}

variant curl conflicts wget description { Use curl as downloader } {
    configure.args-append   --with-downloader=curl
    depends_run-append  port:curl
}

if {![variant_isset wget]} {
    default_variants +curl
}

destroot.keepdirs  ${destroot}${prefix}/share/luarocks/  
post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/luarocks/
}
