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

PortSystem          1.0
PortGroup           compiler_blacklist_versions 1.0
PortGroup           cxx11 1.1
PortGroup           cmake 1.1

cmake.generator     Ninja

name                inkscape-gtk3-devel
conflicts           inkscape inkscape-devel
set git_commit      42f2371f
set git_date        20190429
revision            3
version             1.0alpha-${git_date}
license             GPL-2 LGPL-2.1
maintainers         {devans @dbevans}
categories          graphics gnome
platforms           darwin

description         This a recent snapshot of the upstream master branch.

long_description    Inkscape is an multi-platform, Open-Source Vector Graphics Editor \
                    that uses SVG as its native file format. \
                    ${description}

homepage            http://www.inkscape.org/

fetch.type          git
git.url             -b master --depth 200 https://gitlab.com/inkscape/inkscape.git
git.branch          ${git_commit}

post-fetch {
    system -W ${worksrcpath} "git submodule update --init"
}

set python_major    3
set python_minor    7
set python_version  ${python_major}${python_minor}

depends_build-append \
                    port:pkgconfig \
                    port:libtool \
                    port:intltool \
                    port:gtest

depends_lib-append \
                    port:desktop-file-utils \
                    port:libxslt \
                    port:adwaita-icon-theme \
                    port:double-conversion \
                    port:gdl3 \
                    port:libsoup \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:boehmgc \
                    port:gsl \
                    port:glibmm \
                    port:gtkmm3 \
                    port:gtkspell3 \
                    port:aspell \
                    port:dbus-glib \
                    port:lcms2 \
                    port:poppler \
                    port:boost \
                    port:ImageMagick \
                    port:libcdr-0.1 \
                    port:libexif \
                    port:libvisio-0.1 \
                    port:libwpg-0.3 \
                    port:libyaml \
                    port:potrace \
                    port:python${python_version} \
                    port:py${python_version}-lxml \
                    port:py${python_version}-numpy

post-patch {
    reinplace "s|\"python-interpreter\", \"python\"|\"python-interpreter\", \"python${python_major}.${python_minor}\"|g" ${worksrcpath}/src/extension/implementation/script.cpp
    reinplace "s|^#include \"Object.h\"|#include \"${prefix}/include/poppler/Object.h\"|" ${worksrcpath}/src/extension/internal/pdfinput/pdf-parser.h
    reinplace "s|^#include \"Object.h\"|#include \"${prefix}/include/poppler/Object.h\"|" ${worksrcpath}/src/extension/internal/pdfinput/pdf-parser.cpp
    reinplace "s|lib/inkscape|lib|" ${worksrcpath}/src/CMakeLists.txt
}

# py-numpy is currently not universal (#48263).

universal_variant no

# clang-425.0.28 cannot handle glibmm's headers
# allow build with more modern gcc on 10.5 and earlier
compiler.blacklist-append {clang < 500} *gcc-3.* *gcc-4.*

configure.args-append \
    -DWITH_DBUS:BOOL=ON \
    -DWITH_GRAPHICS_MAGICK:BOOL=OFF \
    -DWITH_OPENMP=OFF \
    -DWITH_JEMALLOC=OFF

#
# the following dummy variants are used
# to identify this port's binary dependencies
# based on which variant of gtkmm is used for the build
#

variant x11 conflicts quartz {}
variant quartz conflicts x11 {}

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

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

livecheck.type      none