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

name                gtk-sharp2
set my_name         gtk-sharp
version             2.12.45
revision            0
set branch          [join [lrange [split ${version} .] 0 1] ""]
categories          x11 devel
license             LGPL-2
platforms           darwin
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
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            https://www.mono-project.com/docs/gui/gtksharp/
master_sites        https://download.mono-project.com/sources/${my_name}${branch}/
distname            ${my_name}-${version}

checksums           rmd160  f11d2e151e2266b0b4a2aea620a4c2d6d8753676 \
                    sha256  02680578e4535441064aac21d33315daa009d742cab8098ac8b2749d86fffb6a \
                    size    2644209

# taken from Debian (https://sources.debian.org/patches/gtk-sharp2/2.12.40-2/01_dllmaps/)
patchfiles          patch-dllmaps.diff

depends_build       port:pkgconfig

depends_lib         port:atk \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:gtk2 \
                    port:libglade2 \
                    port:mono \
                    path:lib/pkgconfig/pango.pc:pango

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

use_parallel_build  no

post-destroot {
    set docdir ${prefix}/share/doc/${my_name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING README README.generator \
        ${destroot}${docdir}
}

variant debug description {Enable debug build} {
    configure.args-append   --enable-debug
}

# gtk-sharp2 builds differently depending on how gtk2 is installed
variant x11 conflicts quartz {}
variant quartz conflicts x11 {}

if {![variant_isset quartz]} {
    default_variants +x11
}

if {[variant_isset quartz]} {
    require_active_variants gtk2 quartz
} else {
    require_active_variants gtk2 x11
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     ${my_name}-(\\d+(?:\\.\\d+)*)