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

name                gtk2hs
version             0.10.1
revision            1
categories          devel graphics
platforms           darwin
maintainers         nomaintainer

description         Portable and native GUI library for Haskell
long_description    gtk2hs is a Haskell binding to GTK+ 2.x, a comprehensive \
                    C GUI library that is portable across many platforms.

homepage            https://sourceforge.net/projects/${name}/
master_sites        sourceforge

checksums           rmd160  c72acd0e2c5471c7757532cfb44c841be8e83f1d \
                    sha256  07cc98520ce6c9e0d2549fd8fd23fc5118148b7509843b0163340713a762d0c0 \
                    size    1451125

depends_build       port:pkgconfig
depends_lib         port:gconf \
                    port:ghc \
                    path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                    port:gnome-vfs \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                    port:libglade2 \
                    port:gtksourceview2

configure.args      --with-hc=${prefix}/bin/ghc   \
                    --disable-deprecated-packages \
                    --enable-profiling            \
                    --enable-packager-mode        \
                    --enable-gtk                  \
                    --enable-gio                  \
                    --enable-gconf                \
                    --enable-libglade             \
                    --enable-gtksourceview2       \
                    --enable-cairo                \
                    --enable-svg                  \
                    --without-pkgreg

variant x11 {
    depends_lib-append      port:gtkglext
    configure.args-append   --enable-opengl
}

default_variants    +x11

use_parallel_build  no

# Fix gtk.package.conf to allow interoperating with non-MacPorts
# ghc. (MacPorts' ghc adds ${prefix}/lib to the linker path
# automatically.)

post-destroot {
    set pkgs {glib gio cairo svgcairo gtk gconf glade gtkglext gtksourceview2 soegtk}
    if {![variant_isset x11]} {
        set pkgs {glib gio cairo svgcairo gtk gconf glade gtksourceview2 soegtk}
    }
    foreach pkg ${pkgs} {
        reinplace "s|library-dirs: |library-dirs: \"${prefix}/lib\",|" \
                  ${destroot}${prefix}/lib/${name}/${pkg}.package.conf
    }
}

# Note that the order of package registration is important: certain
# packages must be registered before the packages that depend on them.

post-activate {
    set pkgs {glib gio cairo svgcairo gtk gconf glade gtkglext gtksourceview2 soegtk}
    if {![variant_isset x11]} {
        set pkgs {glib gio cairo svgcairo gtk gconf glade gtksourceview2 soegtk}
    }
    foreach pkg ${pkgs} {
        system "ghc-pkg update ${destroot}${prefix}/lib/${name}/${pkg}.package.conf"
    }
}
