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

PortSystem          1.0

name                gnome-sharp2
set my_name         gnome-sharp
version             2.24.2
revision            1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          gnome devel
license             LGPL-2
platforms           darwin
maintainers         nomaintainer
description         Gtk bindings for the Mono .NET Development Framework

long_description    This is the Gtk# toolkit for Mono, an implementation \
                    of the .NET Development Framework.

homepage            http://www.mono-project.com/GtkSharp
master_sites        gnome:sources/${my_name}/${branch}
distname            ${my_name}-${version}

use_bzip2           yes

checksums           rmd160  7cd495debeb92a8517c809f7e9c8d9803e16038c \
                    sha256  122b1e03966d63ec3389decf5440fb94285907d1b6be48352dcf6aca292cf7b0

# Errors creating policy.*.dll multiple times in parallel
use_parallel_build  no

patchfiles          patch-gnome-sharp.dll.config.in.diff

depends_build       port:pkgconfig

depends_lib         port:mono \
                    port:gtk-sharp2 \
                    port:libart_lgpl \
                    port:gnome-vfs \
                    port:libgnomecanvas \
                    port:libgnomeui

# mono is not universal
universal_variant   no

post-configure {
    # TODO This shouldn't be needed, we need to fix Mono dllmap library path.
    fs-traverse {f} ${worksrcpath} {
        if {[string match *.dll.config ${f}]} {
            reinplace -E "s|(target=\")|\\1${prefix}/lib/|" ${f}
        }
    }

    reinplace "s/libgtk-x11-2\\.0\\.0\\.dylib/[glob -tail -path ${prefix}/lib/ libgtk-*-2.0.0.dylib]/" \
        ${worksrcpath}/gnome/gnome-sharp.dll.config

    # http://mono.1490590.n4.nabble.com/gnome-sharp-compilation-error-td3848979.html
    reinplace "/^EXTRA_TARGETS/s/TestXfer.exe//" \
        ${worksrcpath}/sample/gnomevfs/Makefile
}

variant x11 {}

default_variants    +x11

if {![variant_isset x11]} {
    pre-fetch {
        if {[file exists ${prefix}/lib/pkgconfig/gtk+-x11-2.0.pc]} {
            ui_error "Please uninstall or deactivate the gtk2 port and reinstall it by running `port install gtk2 +quartz`."
            error "gtk2 must be installed with the quartz variant enabled."
        }
    }
}

livecheck.type      gnome
livecheck.name      ${my_name}
