# -*- 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                   cmake 1.1
PortGroup                   github 1.0
PortGroup                   lua 1.0

name                        lua-luabitop
github.setup                LuaDist luabitop 1.0.2
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from         tarball
revision                    2
license                     MIT
categories                  lua devel
maintainers                 nomaintainer
description                 C extension module for bitwise operators
long_description            Lua BitOp is a C extension module for Lua 5.1/5.2 \
                            which adds bitwise operations on numbers.

homepage                    https://bitop.luajit.org/

checksums                   rmd160  4084b571368cbbaa5f5eaf289d4723167ff92eb3 \
                            sha256  f1773083ece10ab688d72de5b4f24deaad27e547cffe64c51e95e90d0de6178f \
                            size    32249

patchfiles-append           patch-lua_5_3_plus.diff \
                            patch-test-lua_5_3_plus.diff

depends_build-append        port:pkgconfig

foreach branch ${lua.branches} {
    set subname             luabitop
    set branch_no_dot       [join [split ${branch} .] ""]
    set subport_name        lua${branch_no_dot}-${subname}

    subport ${subport_name} {}
    if {${subport} eq ${subport_name}} {
        lua.version         ${branch}

        configure.args      -DINSTALL_CMOD=${prefix}/lib/lua/${branch} \
                            -DINSTALL_LMOD=${prefix}/share/lua/${branch} \
                            -DINSTALL_DATA=${prefix}/share/luabitop/${branch}

        test.run            yes

        livecheck.type      none
    }
}

subport ${name} {
    distfiles
    patchfiles
    use_configure           no
    extract.rename          no
    platforms               any
    supported_archs         noarch
    foreach deptype {depends_extract depends_patch depends_lib depends_build depends_run depends_test} {
        ${deptype}
    }
    proc lua::callback {} {}
    build {}
    destroot {
        set docdir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${docdir}
        set f               [open "${docdir}/README" w 0644]
        puts ${f}           "[option subport] is a stub port"
        close               ${f}
    }

    # skip prebuilt binaries
    github.livecheck.regex  {(\d+(?:\.\d+)*)}
}
