# -*- 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 107320 2013-06-25 16:54:36Z devans@macports.org $

PortSystem      1.0

name            gnome-python-desktop
version         2.32.0
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      gnome python
license         GPL-2+ LGPL-2.1+
maintainers     devans openmaintainer
description     Python modules for some GNOME Desktop libraries.
long_description ${description}
platforms       darwin
homepage        http://www.pygtk.org/
master_sites    gnome:sources/${name}/${branch}/

use_bzip2       yes

checksums       rmd160  f9b619aa335b88fbf0e5b70d6b362cb08c4df07d \
                sha256  09dbd580bf3b0ef60f91b090eafe6d08ddcc50a609e2b425a7f8eca46d4e0ee9

depends_build   port:pkgconfig

depends_lib     port:gtksourceview \
                port:libcomerr \
                port:libgtop \
                port:gnome-media \
                port:libpanel-applet2 \
                port:evolution-data-server \
                port:evince \
                port:bug-buddy \
                port:totem-pl-parser

patchfiles      pycairo.patch \
                automake.patch

use_autoreconf  yes
autoreconf.args -fvi

configure.args  --disable-nautilusburn

configure.pre_args-delete  --prefix=${prefix}

variant python25 conflicts python26 python27 description {Use python 2.5} {
    set python_ver            2.5

    configure.python          ${prefix}/bin/python${python_ver}
    depends_lib-append        port:py25-gnome

    set python_prefix         ${frameworks_dir}/Python.framework/Versions/${python_ver}
    configure.pre_args-append --prefix=${python_prefix}
    configure.args-append     --includedir=${python_prefix}/include/python${python_ver}
    configure.python          ${prefix}/bin/python${python_ver}
    configure.env             PATH=${python_prefix}/bin:$env(PATH)
    configure.pkg_config_path ${python_prefix}/lib/pkgconfig

    post-destroot {
        set python_prefix ${frameworks_dir}/Python.framework/Versions/2.5
        # devhelp requires gtk-doc directory name  and .devhelp file name (less the .devhelp) to match
        foreach docname {pygnomeprint pygnomeprintui pygtksourceview} {
            file rename ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}.devhelp \
                        ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}25.devhelp
            ln -s ${python_prefix}/share/gtk-doc/html/${docname} ${destroot}${prefix}/share/gtk-doc/html/${docname}25
        }
    }
}

variant python26 conflicts python25 python27 description {Use python 2.6} {
    set python_ver            2.6

    configure.python          ${prefix}/bin/python${python_ver}
    depends_lib-append        port:py26-gnome

    set python_prefix         ${frameworks_dir}/Python.framework/Versions/${python_ver}
    configure.pre_args-append --prefix=${python_prefix}
    configure.args-append     --includedir=${python_prefix}/include/python${python_ver}
    configure.python          ${prefix}/bin/python${python_ver}
    configure.env             PATH=${python_prefix}/bin:$env(PATH)
    configure.pkg_config_path ${python_prefix}/lib/pkgconfig

    post-destroot {
        set python_prefix ${frameworks_dir}/Python.framework/Versions/2.6
        # devhelp requires gtk-doc directory name  and .devhelp file name (less the .devhelp) to match
        foreach docname {pygnomeprint pygnomeprintui pygtksourceview} {
            file rename ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}.devhelp \
                        ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}26.devhelp
            ln -s ${python_prefix}/share/gtk-doc/html/${docname} ${destroot}${prefix}/share/gtk-doc/html/${docname}26
        }
    }
}

variant python27 conflicts python25 python26 description {Use python 2.7} {
    set python_ver            2.7

    configure.python          ${prefix}/bin/python${python_ver}
    depends_lib-append        port:py27-gnome

    set python_prefix         ${frameworks_dir}/Python.framework/Versions/${python_ver}
    configure.pre_args-append --prefix=${python_prefix}
    configure.args-append     --includedir=${python_prefix}/include/python${python_ver}
    configure.python          ${prefix}/bin/python${python_ver}
    configure.env             PATH=${python_prefix}/bin:$env(PATH)
    configure.pkg_config_path ${python_prefix}/lib/pkgconfig

    post-destroot {
        set python_prefix ${frameworks_dir}/Python.framework/Versions/2.7
        # devhelp requires gtk-doc directory name  and .devhelp file name (less the .devhelp) to match
        foreach docname {pygnomeprint pygnomeprintui pygtksourceview} {
            file rename ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}.devhelp \
                        ${destroot}${python_prefix}/share/gtk-doc/html/${docname}/${docname}27.devhelp
            ln -s ${python_prefix}/share/gtk-doc/html/${docname} ${destroot}${prefix}/share/gtk-doc/html/${docname}27
        }
    }
}

if {![variant_isset python25] && ![variant_isset python26]} {
    default_variants +python27
}

variant metacity description {Enable metacity bindings} {
    depends_lib-append      port:metacity
    configure.args-append   --enable-metacity
}

platform darwin 9 {
    post-patch {
        reinplace "s| -export-symbols-regex.*||g" \
            ${worksrcpath}/evolution/Makefile.in \
            ${worksrcpath}/gnomeapplet/Makefile.in \
            ${worksrcpath}/gnomedesktop/Makefile.in \
            ${worksrcpath}/gnomekeyring/Makefile.in \
            ${worksrcpath}/gnomeprint/Makefile.in \
            ${worksrcpath}/gtksourceview/Makefile.in \
            ${worksrcpath}/gtop/Makefile.in \
            ${worksrcpath}/mediaprofiles/Makefile.in \
            ${worksrcpath}/metacity/Makefile.in \
            ${worksrcpath}/nautilusburn/Makefile.in \
            ${worksrcpath}/rsvg/Makefile.in \
            ${worksrcpath}/totem/Makefile.in \
            ${worksrcpath}/wnck/Makefile.in
    }
}

#
# gnome-panel -> evolution-data-server -> nss is not universal
#

universal_variant no

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

livecheck.type  gnome
