# -*- 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 118356 2014-03-31 22:14:36Z devans@macports.org $

PortSystem      1.0
PortGroup       archcheck 1.0

name            dia
version         0.97.2
revision        5
set branch      [join [lrange [split ${version} .] 0 1] .]
maintainers     nomaintainer
license         GPL-2+
categories      gnome graphics
platforms       darwin
description     A diagram program.

long_description \
    Dia is designed to be much like the commercial Windows \
    program Visio. It can be used to draw many different kinds \
    of diagrams. It currently has special objects to help draw \
    entity relationship diagrams, UML diagrams, flowcharts, \
    network diagrams, and simple circuits. It is also possible \
    to add support for new shapes by writing simple XML files, \
    using a subset of SVG to draw the shape.

homepage        https://wiki.gnome.org/Apps/Dia
master_sites    gnome:sources/${name}/${branch}/
use_xz          yes

checksums       sha1    dc7ed6f8cd83acc8f421d28f30e4042fe370e9ba \
                rmd160  f9270f1f2cb6ad505219463827d02e3759693796

# backport patches for glib 2.32 compatibility and to fix crash on
# start (#34520)
patch.pre_args  -p1
patchfiles      \
    0001-aa94ba030885f3105e6452929d04917a2ef94393.patch \
    0002-ae61326cf5e7aaba6e72af757a5cd33efe8280a1.patch \
    0003-3a589dedfbf2b0ada111a3e2cb6b14837f2c8b5e.patch

# backport patches for glib 2.36 compatibility and to fix crash on
# start (#39027)
patchfiles-append \
    0004-7ac3e9ffac09f99a1aa2fe97a4dc0a688c9746b0.patch

patchfiles-append patch-freetype-2.5.1.diff

post-patch {
    reinplace s/isspecial/char_isspecial/ \
        ${worksrcpath}/objects/GRAFCET/boolequation.c
}

depends_build \
    port:intltool \
    port:pkgconfig

depends_lib \
    port:desktop-file-utils \
    path:lib/pkgconfig/cairo.pc:cairo \
    port:freetype \
    port:libart_lgpl \
    port:libpng \
    port:libxml2 \
    port:libxslt \
    port:gettext \
    path:lib/pkgconfig/glib-2.0.pc:glib2 \
    port:gtk2 \
    path:lib/pkgconfig/pango.pc:pango \
    port:popt \
    port:zlib

depends_run \
    port:librsvg

archcheck.files \
    lib/libcairo.dylib \
    lib/libfreetype.dylib \
    lib/libart_lgpl_2.dylib \
    lib/libgdk_pixbuf-2.0.dylib \
    lib/libglib-2.0.dylib \
    lib/libintl.dylib \
    lib/libpango-1.0.dylib \
    lib/libpng.dylib \
    lib/libxml2.dylib \
    lib/libxslt.dylib \
    lib/libpopt.dylib \
    lib/libz.dylib

# autoreconf to reconfigure with our intltool.m4

use_autoreconf  yes
autoreconf.args -fvi

configure.args \
    --with-cairo \
    --disable-libemf \
    --with-xslt-prefix=${prefix}

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

livecheck.type  gnome-with-unstable

variant python27 description {Add python 2.7 bindings} {
    set python_prefix       ${frameworks_dir}/Python.framework/Versions/2.7
    depends_build-append    port:swig
    depends_lib-append      port:py27-pygtk

    patchfiles-append       configure.diff

    configure.args-append   --with-swig \
                            --with-python
    configure.python        ${python_prefix}/bin/python2.7
    configure.env-append    am_cv_python_pyexecdir=${python_prefix} \
                            am_cv_python_pythondir=${python_prefix}
}
