# -*- 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
# $Id: Portfile 106044 2013-05-14 01:31:00Z jeremyhu@macports.org $

PortSystem          1.0
PortGroup           active_variants 1.1

name                gobject-introspection
version             1.36.0
revision            1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          gnome
platforms           darwin
# library under LGPL-2+, tools under GPL-2+
license             {LGPL GPL-2+}
maintainers         nomaintainer
description         GObject Introspection

long_description    Gobject Introspection acts as a bridge between low-level C+GObject code and \
                    a managed runtime (JavaScript, Python, Java, Lua, .NET, Scheme, etc.).

homepage            http://live.gnome.org/GObjectIntrospection
master_sites        gnome:sources/${name}/${branch}/
use_xz              yes

checksums           rmd160  bcc541a021ca409395a82fc4dd52a1353679908a \
                    sha256  e3e76d9d428e7534761bf8cdf75338865a4b0872e8052bef51792744608b6383

depends_build       port:pkgconfig

depends_lib         path:lib/pkgconfig/cairo.pc:cairo \
                    port:libffi \
                    port:python27 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2

depends_run         bin:glibtool:libtool

patchfiles          patch-giscanner-shlib.py-use-absolute-linkage-paths.patch \
                    patch-giscanner-utils.py-use-absolute-linkage-paths.patch \
                    patch-giscanner-dumper.py-clang-is-not-msvc.patch \
                    glibtool_path.patch

post-patch {
    reinplace "s|'cc'|'${configure.cc}'|g" ${worksrcpath}/giscanner/sourcescanner.py
    reinplace "s|'gcc'|'${configure.cc}'|g" ${worksrcpath}/giscanner/dumper.py
    reinplace "s|libcairo-gobject.2.dylib|${prefix}/lib/libcairo-gobject.2.dylib|g" ${worksrcpath}/configure
}

configure.python    ${prefix}/bin/python2.7

# GObject introspection doesn't build with tiger's make, #32358
platform darwin 8 {
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
}

build.args          CC="${configure.cc} ${configure.cc_archflags}" V=1

# gobject-introspection needs to be aware whether it was compiled against python +ucs4, see #35603
variant python_ucs4 description {Build against Python with +ucs4} {
    require_active_variants python27 ucs4
}

if {![variant_isset python_ucs4]} {
    pre-configure {
        if {![active_variants python27 "" ucs4]} {
            error "You have python installed with the +ucs4 variant. Please build ${name} with +python_ucs4"
        }
    }
}

if {![catch {set result [active_variants python27 ucs4]}]} {
    if {$result} {
        default_variants +python_ucs4
    }
}

livecheck.type      gnome
