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

github.setup        garrigue lablgl 1.07 v
revision            1
epoch               1
categories          graphics ocaml
license             BSD Tcl/Tk
maintainers         {pmetzger @pmetzger} openmaintainer
description         Objective Caml interface to OpenGL
long_description    LablGL is is an Objective Caml interface to OpenGL. \
                    Support is included for use with both \
                    Glut (standalone) and LablTk.\
                    LablGTK also includes specific support for LablGL.

homepage            https://github.com/garrigue/lablgl

checksums           rmd160  f27d546750c8fe126ea29d33ab65f2a4d1efc628 \
                    sha256  845477ed8d5aeaad63907a9edfc1d8f8d62b932c6e37a32502926ee402a6271f \
                    size    567464
github.tarball_from archive

post-patch {
    reinplace "s|/usr/local|${prefix}|" ${worksrcpath}/Makefile.config.osx
    reinplace "s|/opt/local|${prefix}|g" ${worksrcpath}/Makefile.config.osx
}

depends_lib         port:ocaml \
                    port:ocaml-camlp-streams \
                    port:ocaml-findlib

# togl target is broken:
# File "togl.mli", line 4, characters 16-29:
# 4 | type widget = w Widget.widget
#                     ^^^^^^^^^^^^^
# Error: Unbound module Widget

# depends_lib-append  port:mesa \
#                     port:tk-x11 \
#                     port:xorg-libXmu

build.target        lib glut

if {${configure.build_arch} ni [list i386 ppc ppc64]} {
    build.target-append \
                    libopt glutopt
}

configure {
    copy ${worksrcpath}/Makefile.config.osx ${worksrcpath}/Makefile.config
}

use_parallel_build  no

# ocaml is not universal
universal_variant   no

set stublibsdir     ${destroot}${prefix}/lib/ocaml/stublibs/
pre-destroot {
    file mkdir ${stublibsdir}
}
destroot.args \
    INSTALLDIR=${destroot}${prefix}/lib/ocaml/lablgl \
    BINDIR=${destroot}${prefix}/bin \
    DLLDIR=${stublibsdir}

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/lib/ocaml/site-lib/lablgl
    xinstall -m 644 ${filespath}/META ${destroot}${prefix}/lib/ocaml/site-lib/lablgl/META
}
