# -*- 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                           lua         1.0
PortGroup                           makefile    1.0

name                                lua-glut
version                             0.5
revision                            1
license                             MIT
categories                          lua devel
maintainers                         nomaintainer
description                         a set of libraries providing OpenGL and GLUT bindings for Lua 5
long_description                    luaglut is {*}${description}.

homepage                            http://lua-users.org/wiki/VarolKaptan
master_sites                        macports_distfiles
distname                            luaglut-${version}

checksums                           rmd160  4de4335353d1712bf22b1ed187ef8d35f3b869b3 \
                                    sha256  5e4f462f4c9f9a29be120d39c15b46cdb035eeb242d80db5860048807a40f8b7 \
                                    size    59986

foreach branch {5.1} {
    set subname                     glut
    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.cppflags-append   -DGL_SILENCE_DEPRECATION

        makefile.override-delete    CC
        build.args-append           CC="\$CC \$CPPFLAGS \$CFLAGS" \
                                    LDSO="\$CC \$LDFLAGS \\\$(GCC_OPT_SHARED)" \
                                    LUAGL=luagl.so \
                                    LUAGLUT=luaglut.so \
                                    MEMARRAY=memarray.so

        destroot {
            # documentation and examples
            xinstall -d -m 0755     ${destroot}${prefix}/share/doc/${subport}

            xinstall -m 0644        ${worksrcpath}/README \
                                    ${destroot}${prefix}/share/doc/${subport}

            xinstall -d -m 0755     ${destroot}${prefix}/share/doc/${subport}/examples
            foreach f               {glut_test1.lua glut_test2.lua lua.ppm} {
                xinstall -m 0644    ${worksrcpath}/${f} \
                                    ${destroot}${prefix}/share/doc/${subport}/examples
            }

            # modules
            xinstall -d -m 0755     ${destroot}${prefix}/lib/lua/${lua.version}
            foreach lib             [glob ${worksrcpath}/*.so] {
                xinstall -m 644     ${lib} \
                                    ${destroot}${prefix}/lib/lua/${lua.version}
            }
        }

        livecheck.type              none
    }
}

subport ${name} {
    distfiles
    patchfiles
    extract.rename                  no
    supported_archs                 noarch
    platforms                       any
    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 -m 0755         ${docdir}
        set f                       [open "${docdir}/README" w 0644]
        puts ${f}                   "[option subport] is a stub port"
        close                       ${f}
    }

    # the last release was 10-Mar-2006
    livecheck.type                  none
}
