# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup       github 1.0
PortGroup       cmake  1.1

github.setup    libglui glui 2.37
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision		1
categories      x11
maintainers     {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description     A GLUT-based C++ user interface library.
long_description \
    GLUI is a GLUT-based C++ user interface library \
    which provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications.
license         zlib

checksums       rmd160  44cb8c9e30e8dbdfee6ed0ae609029c1ca449211 \
                sha256  2f505a5320b6002f940a33d88e59d52333164cc0f2de8d6bd55b7d4d83664dfe \
                size    487960

# see https://github.com/libglui/glui/commit/eaca63aea72ed4db055514dfec2abc71a106aa70
# see https://github.com/libglui/glui/commit/4299e8fa43bb1e67370be36cad4b21115ab88af9
# install bins and examples
patchfiles-append patch-CMakeLists.txt.diff

# see https://github.com/libglui/glui/commit/fc9ad76733034605872a0d1323bb19cbc23d87bf
patchfiles-append patch-glui.h.diff

variant x11 {
    depends_lib-append \
        port:mesa \
        port:libGLU \
        port:freeglut

    # only use FreeGLUT headers
    patchfiles-append \
        patch-glui.h-freeglut.diff

    configure.args-append \
        -DOPENGL_gl_LIBRARY=${prefix}/lib/libGL.dylib \
        -DOPENGL_glu_LIBRARY=${prefix}/lib/libGLU.dylib \
        -DGLUT_glut_LIBRARY=${prefix}/lib/libglut.dylib \
        -DGLUT_INCLUDE_DIR=${prefix}/include \
        -DOPENGL_INCLUDE_DIR=${prefix}/include \
        -DGLUT_cocoa_LIBRARY=""
}
default_variants +x11

if {![variant_isset x11]} {
    configure.args-append \
        -DGLUT_glut_LIBRARY=/System/Library/Frameworks/GLUT.framework
}

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/doc/glui_manual.pdf ${destroot}${prefix}/share/doc/${name}
}
