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

name                py-gobject
set my_name         pygobject
version             2.28.7
revision            2
epoch               20110613
set branch          [join [lrange [split ${version} .] 0 1] .]

categories-append   gnome
license             LGPL-2.1+
maintainers         nomaintainer
platforms           darwin

description         Python bindings for GObject.

long_description \
    PyGObject provides a convenient wrapper for the GObject+ library \
    for use in Python programs, and takes care of many of the boring details \
    such as managing memory and type casting. \
    When combined with PyGTK, PyORBit and gnome-python, \
    it can be used to write full featured Gnome applications.

homepage            http://www.pygtk.org/
master_sites        gnome:sources/${my_name}/${branch}/
distname            ${my_name}-${version}
use_xz              yes

checksums           rmd160  e9fea538da79ad27c42434d4a2173b3eb636408b \
                    sha256  bb9d25a3442ca7511385a7c01b057492095c263784ef31231ffe589d83a96a5a \
                    size    744584

python.versions     27

if {${subport} ne ${name}} {
    depends_build-append \
                    port:pkgconfig

    depends_lib-append \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libffi \
                    port:py${python.version}-cairo \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection

    patchfiles  patch-pygi-info.c.diff patch-tpprint-py3.patch \
                py-gobject-dynamic_lookup-11.patch

    use_configure           yes
    configure.python        ${python.bin}
    configure.pkg_config_path-append \
                            ${python.prefix}/lib/pkgconfig
    configure.pre_args      --prefix='${python.prefix}'
    configure.args-append	--disable-glibtest \
                            --enable-introspection=no \
                            --disable-silent-rules
    configure.cppflags-append \
                            -I${python.prefix}/include \
                            -I${prefix}/include/cairo
    build.cmd	    [portbuild::build_getmaketype]
    build.target

    destroot.cmd            ${build.cmd}
    destroot.target         install
    destroot.destdir        DESTDIR=${destroot}

    test.run        yes
    python.test_framework
    test.target     check

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
            ${destroot}${docdir}
    }

    variant quartz {
        require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 quartz
        patchfiles-append patch-quartz.diff

        # Work-around for https://trac.macports.org/ticket/61113
        configure.cflags-append -Wno-implicit-function-declaration
    }

    variant x11 {
        require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 x11
    }

    if {![variant_isset quartz]} {
        default_variants +x11
    }
    if {![variant_isset x11]} {
        default_variants +quartz
    }
    if {![variant_isset quartz] && ![variant_isset x11]} {
        pre-configure {
            return -code error "Either +x11 or +quartz is required"
        }
    }
}

livecheck.type  none
