# -*- 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$

PortSystem          1.0
PortGroup           gobject_introspection 1.0
PortGroup           active_variants 1.1

name                glade
version             3.20.0
revision            1
license             LGPL-2+ GPL-2+
set branch          [join [lrange [split ${version} .] 0 1] .]
description         Glade is a RAD tool to enable quick & easy development of user interfaces \
                    for the GTK+ 3.* toolkit and the GNOME desktop environment.
long_description    ${description}
maintainers         devans openmaintainer
categories          devel gnome
platforms           darwin
homepage            https://wiki.gnome.org/Apps/Glade
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  41f49e78492e52f9a5f51c3a8d0aecadb147796d \
                    sha256  82d96dca5dec40ee34e2f41d49c13b4ea50da8f32a3a49ca2da802ff14dc18fe

depends_skip_archcheck devhelp

depends_build       port:pkgconfig \
                    port:intltool \
                    port:itstool \
                    port:gnome-common \
                    port:yelp-tools \
                    port:gtk-doc \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:gtk3 \
                    port:libxml2

depends_run         port:desktop-file-utils \
                    port:devhelp

gobject_introspection yes

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

configure.cmd       ./autogen.sh

#
# disable optimization which (at least with clang)
# causes glade to segfault on startup
# after displaying main window
#

configure.optflags  -O0

configure.args      --enable-gladeui \
                    --enable-debug \
                    --disable-python \
                    --disable-silent-rules

configure.cflags-append \
                    -Wno-format-nonliteral

variant python27 conflicts python34 python35 description {Build Python 2.7 widgets support} {
    configure.args-replace      --disable-python --enable-python
    configure.python            ${prefix}/bin/python2.7
    set python_framework        ${frameworks_dir}/Python.framework/Versions/2.7
    configure.env-append        PYTHON_LIBS=-lpython2.7 \
                                PYTHON_LIB_LOC=${prefix}/lib
    depends_lib-append          port:py27-gobject3
    configure.pkg_config_path   ${python_framework}/lib/pkgconfig
}

variant python34 conflicts python27 python35 description {Build Python 3.4 widgets support} {
    configure.args-replace      --disable-python --enable-python
    configure.python            ${prefix}/bin/python3.4
    set python_framework        ${frameworks_dir}/Python.framework/Versions/3.4
    configure.env-append        PYTHON_LIBS="-L${python_framework}/lib -lpython3.4" \
                                PYTHON_LIB_LOC=${python_framework}/lib
    depends_lib-append          port:py34-gobject3
    configure.pkg_config_path   ${python_framework}/lib/pkgconfig
}

variant python35 conflicts python27 python34 description {Build Python 3.5 widgets support} {
    configure.args-replace      --disable-python --enable-python
    configure.python            ${prefix}/bin/python3.5
    set python_framework        ${frameworks_dir}/Python.framework/Versions/3.5
    configure.env-append        PYTHON_LIBS="-L${python_framework}/lib -lpython3.5" \
                                PYTHON_LIB_LOC=${python_framework}/lib
    depends_lib-append          port:py35-gobject3
    configure.pkg_config_path   ${python_framework}/lib/pkgconfig
}

if {![variant_isset python27] && ![variant_isset python35]} {
    default_variants +python34
}

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

variant x11 conflicts quartz {
    require_active_variants gtk3 x11 quartz
}

variant quartz conflicts x11 {
    require_active_variants gtk3 quartz x11
    depends_lib-append port:gtk-osx-application-gtk3
# disable dependency on devhelp at runtime
# until +quartz problem solved for webkit2-gtk (#52688)
    depends_run-delete port:devhelp

    # compile glade-registration.c as Objective-C file since it includes
    #    /System/Library/Frameworks/AppKit.framework/Headers/AppKit.h
    post-configure {
        reinplace \
            "s|-o glade-glade-registration.o|-xobjective-c -o glade-glade-registration.o|g" \
            ${worksrcpath}/src/Makefile
    }
}

if {![variant_isset quartz]} {
    default_variants +x11
}

livecheck.type      gnome