# -*- 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

PortSystem          1.0
PortGroup           github 1.0
PortGroup           cmake 1.1

github.setup        luvit luv 1.50.0-1
revision            0
categories          devel
license             Apache-2
maintainers         {l2dy @l2dy} openmaintainer

description         Bare libuv bindings for lua
long_description    libuv bindings for luajit and lua. This library makes \
                    libuv available to lua scripts.

github.tarball_from releases

checksums           rmd160  1f046f0e22478abef61496151b6d9146f7415149 \
                    sha256  d867c3024d9c981d54f2edd83e13fd6dc1158f0608635f7b1c0f6b5586b5bc34 \
                    size    1523695

depends_lib         port:libuv \
                    port:lua

# If Lua engine is LuaJIT, prefer lua.h from LUAJIT_INCLUDE_DIR over
# ${prefix}/include/lua.h provided by port lua.
# See: https://trac.macports.org/ticket/68126#comment:34
patchfiles          patch-CMakeLists.txt.diff

configure.args      -DLUA_BUILD_TYPE=System \
                    -DBUILD_MODULE=OFF \
                    -DBUILD_SHARED_LIBS=ON \
                    -DWITH_LUA_ENGINE=Lua \
                    -DWITH_SHARED_LIBUV=ON

if {${name} eq ${subport}} {
    conflicts       luv-luajit
}

subport luv-luajit {
    depends_lib-replace port:lua path:lib/libluajit-5.1.2.dylib:luajit
    configure.args-replace \
                    -DWITH_LUA_ENGINE=Lua -DWITH_LUA_ENGINE=LuaJIT

    conflicts luv
}
