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

PortSystem          1.0
PortGroup           active_variants 1.1

name                dia
version             0.97.3
set git_date        20140905
                    # git_date added only to support new livecheck
revision            8
checksums           rmd160  a984efa1663cc154f4394060af37fab146f99175 \
                    sha256  22914e48ef48f894bb5143c5efc3d01ab96e0a0cde80de11058d3b4301377d34 \
                    size    5548500

set branch          [join [lrange [split ${version} .] 0 1] .]
maintainers         nomaintainer
license             GPL-2+
categories          gnome graphics
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

depends_build       port:intltool \
                    port:pkgconfig \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    port:docbook-xsl-nons

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 \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:popt \
                    port:shared-mime-info \
                    port:zlib

depends_run         path:lib/pkgconfig/librsvg-2.0.pc:librsvg

patchfiles          patch-autogen.sh.diff \
                    patch-configure.in.diff \
                    patch-commands.c.diff \
                    isfinite.patch \
                    patch-lib-color.c.diff

post-patch {
    reinplace s/isspecial/char_isspecial/ \
        ${worksrcpath}/objects/GRAFCET/boolequation.c
    reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/app/commands.c
}

use_parallel_build  no

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

configure.cmd       ./autogen.sh

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

# required for for ICU
compiler.cxx_standard     2011
configure.cxxflags-append -std=c++11

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

variant quartz {}

if {[variant_isset quartz]} {
    require_active_variants gtk2 quartz
} else {
    require_active_variants gtk2 x11
}

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

    configure.args-append   --with-swig \
                            --with-python
    configure.python        ${python_prefix}/bin/python2.7
    # find correct python-config
    configure.env-append    PATH=${python_prefix}/bin:$env(PATH)
}

# 2025 Dec 9:  Temporary departure from old $master_sites.
# Completely remove this URL after updating to gitlab portgroup.
livecheck.url       https://gitlab.gnome.org/GNOME/dia/-/commits/master?format=atom

# Livecheck by whole date only.  Will miss later updates on same date.
# For use with commit hash versions only, not normal version numbering.
livecheck.regex     <updated>(\[0-9-\]*)T\[0-9:\]*
livecheck.version   [string cat [string range ${git_date} 0 3  ] \
                              - [string range ${git_date} 4 5  ] \
                              - [string range ${git_date} 6 end] ]
