# -*- 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
# $Id: Portfile 119552 2014-04-30 09:28:54Z devans@macports.org $

PortSystem          1.0

name                libpeas
version             1.10.0
revision            1
license             LGPL-2
set branch          [join [lrange [split ${version} .] 0 1] .]
description         libpeas is a GObject-based plugins engine
long_description    ${description}
maintainers         devans openmaintainer
categories          gnome
platforms           darwin
homepage            https://wiki.gnome.org/Projects/Libpeas
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  c5406a1eae9b67db9a849c10164a3c2797959382 \
                    sha256  4695bc40e4885a903dbc5ce6a3704392feae63af51fd4da7a3888bb88ca78c47

depends_build       port:pkgconfig \
                    port:intltool \
                    port:gnome-common

depends_lib         port:gtk3 \
                    port:gobject-introspection \
                    port:seed

# update m4/intltool.m4 and autoreconf

pre-configure {
    copy -force ${prefix}/share/aclocal/intltool.m4 ${worksrcpath}/m4
}

use_autoreconf      yes
autoreconf.args     -fvi

configure.args      --enable-gtk \
                    --enable-seed \
                    --disable-glade-catalog \
                    --disable-python2 \
                    --disable-python3 \
                    --disable-silent-rules

variant glade description {Enable glade catalog support} {
    depends_lib-append      port:glade
    configure.args-replace  --disable-glade-catalog --enable-glade-catalog
}

# supports one version each of python2 python3 in parallel

variant python27 description {Use python 2.7} {
    depends_lib-append          port:py27-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/2.7
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
    configure.env-append        PYTHON2=${prefix}/bin/python2.7 \
                                PYTHON2_CONFIG=${python_prefix}/bin/python-config
    configure.args-replace      --disable-python2 --enable-python2
}

default_variants +python27

# python3 minimum version is 3.2.0

variant python32 conflicts python33 python34 description {Use python 3.2} {
    depends_lib-append          port:py32-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.2
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
    configure.python            ${prefix}/bin/python3.2
    configure.env-append        PYTHON3_CONFIG=${prefix}/bin/python3.2-config
    configure.cflags-append     -L${python_prefix}/lib
    configure.args-replace      --disable-python3 --enable-python3
}

variant python33 conflicts python32 python34 description {Use python 3.3} {
    depends_lib-append          port:py33-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.3
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
    configure.python            ${prefix}/bin/python3.3
    configure.env-append        PYTHON3_CONFIG=${prefix}/bin/python3.3-config
    configure.cflags-append     -L${python_prefix}/lib
    configure.args-replace      --disable-python3 --enable-python3
}

variant python34 conflicts python32 python33 description {Use python 3.4} {
    depends_lib-append          port:py34-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.4
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
    configure.python            ${prefix}/bin/python3.4
    configure.env-append        PYTHON3_CONFIG=${prefix}/bin/python3.4-config
    configure.cflags-append     -L${python_prefix}/lib
    configure.args-replace      --disable-python3 --enable-python3
}

if {![variant_isset python32] && ![variant_isset python34]} {
    default_variants +python33
}

# glade expects catalog modules and libraries to have a .so suffix

post-destroot {
    if {[variant_isset glade]} {
        set libdir ${prefix}/lib
        ln -s ${libdir}/libpeas-gtk-1.0.dylib ${destroot}${libdir}/libpeas-gtk-1.0.so
    }
}

post-activate {
    system "${prefix}/bin/gtk-update-icon-cache-3.0 -f -t ${prefix}/share/icons/hicolor"
}

livecheck.type  gnome
