# -*- 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           ocaml 1.0
PortGroup           active_variants 1.1
PortGroup           github 1.0

github.setup        garrigue lablgtk 2.18.13
revision            1
checksums           rmd160  db8f42ccbbc74ee35d04aee27b8a24d2f269a569 \
                    sha256  7b9e680452458fd351cf8622230d62c3078db528446384268cd0dc37be82143c \
                    size    1073083
github.tarball_from archive

name                lablgtk2
categories          x11 ocaml
maintainers         {pmetzger @pmetzger} openmaintainer
# the apps have a much more restrictive license than the library code
license             {LGPL-2 Restrictive/Distributable}

description         OCaml interface to gtk+ 2.x

long_description    LablGTK2 is is an OCaml interface to gtk+ 2.x. \
                    It uses the rich type system of OCaml to provide a \
                    strongly typed, yet very comfortable, object-oriented \
                    interface to gtk+.

github.tarball_from archive

homepage            https://garrigue.github.io/lablgtk/

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         port:ocaml \
                    port:ocaml-findlib \
                    path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                    port:libglade2 \
                    port:libgnomecanvas \
                    port:libgnomeui

configure.args      --with-libdir=${ocamlfind_dir} \
                    --without-gl \
                    --with-glade \
                    --with-gnomecanvas \
                    --with-gnomeui \
                    --without-panel \
                    --without-rsvg \
                    --without-gtkspell \
                    --without-gtksourceview \
                    --without-gtksourceview2

build.target        world
# Temporarily disable installation of docs until the docs
# no longer depend on camlp4
#build.target        world doc
use_parallel_build  no

pre-destroot { xinstall -m 755 -d "${destroot}${prefix}/lib/ocaml/site-libs/stublibs" }

destroot.target     old-install

post-destroot {
    xinstall -m 755 -d ${ocamlfind_destdir}/lablgtk2 \
        ${destroot}${prefix}/share/doc/${name}
    # Temporarily disable installation of docs until the docs
    # no longer depend on camlp4
    #file copy ${worksrcpath}/doc/html ${destroot}${prefix}/share/doc/${name}/
}

variant gl description "enable gtkglarea support" {
    configure.args-delete   --without-gl
    configure.args-append   --with-gl
    depends_lib-append      port:lablgl port:gtkglarea2
}

variant rsvg description "enable rsvg support" {
    configure.args-delete   --without-rsvg
    configure.args-append   --with-rsvg
    depends_lib-append      path:lib/pkgconfig/librsvg-2.0.pc:librsvg
}

variant gtksourceview description "enable gtksourceview support" {
    configure.args-delete   --without-gtksourceview
    configure.args-append   --with-gtksourceview
    depends_lib-append      port:gtksourceview
}

variant gtksourceview2 description "enable gtksourceview2 support" {
    configure.args-delete   --without-gtksourceview2
    configure.args-append   --with-gtksourceview2
    depends_lib-append      port:gtksourceview2
}

variant x11 conflicts quartz {
    configure.args-append   --without-quartz
}

variant quartz conflicts x11 {
    configure.args-append   --with-quartz

    # for now, libgnomeui does not install if gtk2 was installed with +quartz
    depends_lib-delete      port:libgnomeui
    configure.args-replace  --with-gnomeui --without-gnomeui
}

if {![variant_isset quartz]} {
    default_variants +x11
    require_active_variants gtk2 x11 quartz
} else {
    require_active_variants gtk2 quartz x11
}

default_variants-append     +rsvg

github.livecheck.regex      {(\d+(?:\.\d+)+)}