PortSystem      1.0
PortGroup       python 1.0
PortGroup       active_variants 1.1

set my_name     pygtk
name            py-${my_name}
version         2.24.0
revision        3
set branch      [join [lrange [split ${version} .] 0 1] .]

python.versions 27

categories-append \
                x11

license         LGPL-2.1+
maintainers     nomaintainer
platforms       darwin
description     PyGTK is the Python binding to GTK+ 2.x

long_description \
                PyGTK contains modules that allow you to use gtk in Python programs. \
                At present, it is a fairly complete set of bindings.

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

checksums       rmd160  33f597def646261483cbbf5491aeb27bf0d22ea6 \
                sha256  cd1c1ea265bd63ff669e92a2d3c2a88eb26bcd9e5363e0f82c896e649f206912

build.cmd       make
build.target    all

destroot.cmd    make

if {${name} ne ${subport}} {
    depends_build-append \
                    port:pkgconfig
    depends_lib-append \
                    port:atk \
                    port:gtk2 \
                    port:libglade2 \
                    port:py${python.version}-cairo \
                    port:py${python.version}-gobject \
                    port:py${python.version}-numpy

    patchfiles      patch-gtk-quartz.diff patch-new-automake.diff
    use_autoreconf  yes 
    autoreconf.post_args        "-I m4"

    use_configure   yes
    configure.python ${python.bin}
    configure.pre_args-delete   --prefix=${prefix}
    configure.pre_args-append   --prefix=${python.prefix}
    configure.cflags-append     -I${python.prefix}/include
    configure.ldflags-append    -L${python.prefix}/lib
    configure.pkg_config_path   ${python.prefix}/lib/pkgconfig
                
    platform darwin 9 {
        post-patch {
            reinplace "s| -export-symbols-regex.*||g" \
                ${worksrcpath}/Makefile.in \
                ${worksrcpath}/gtk/Makefile.in
        }
    }

    destroot.destdir "DESTDIR=${destroot}"

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
            ${destroot}${docdir}
        xinstall -d ${destroot}${prefix}/share/gtk-doc/html
        ln -s ${python.prefix}/share/${my_name} ${destroot}${prefix}/share/${my_name}${python.branch}
        # devhelp requires gtk-doc directory name  and .devhelp file name (less the .devhelp) to match
        file rename ${destroot}${python.prefix}/share/gtk-doc/html/${my_name}/${my_name}.devhelp \
                    ${destroot}${python.prefix}/share/gtk-doc/html/${my_name}/${my_name}${python.branch}.devhelp
        file rename ${destroot}${python.prefix}/share/gtk-doc/html/${my_name} \
                    ${destroot}${prefix}/share/gtk-doc/html/${my_name}${python.branch}
    }

    variant quartz conflicts x11 {
        require_active_variants gtk2 quartz
    }
    variant x11 conflicts quartz {
        require_active_variants gtk2 x11
    }
    if {![variant_isset x11] && ![variant_isset quartz]} {
        default_variants +x11
    }

    livecheck.type  none
} else {
    livecheck.type  gnome
    livecheck.name  ${my_name}
}