# -*- 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           active_variants 1.1
PortGroup           gobject_introspection 1.0
PortGroup           perl5 1.0
PortGroup           yelp 1.0

name                gnumeric
version             1.12.57
revision            0
set branch          [join [lrange [split ${version} .] 0 1] .]

license             GPL-2+
maintainers         {devans @dbevans} openmaintainer
categories          gnome math science

description         A powerful Gtk3 based spreadsheet with Excel, ODF, R and Python support.
long_description    A powerful Gtk3 based spreadsheet that features full Excel function \
                    and file compatibility and additional functions not found in Excel, \
                    and statistics operations based on R. Functionality can be extended \
                    with Python and plugins. Other file compatibility includes OASIS ODF, \
                    Quattro Pro, Psion 5, Paradox DB, and more (see homepage). GDA \
                    database support is available with the +database variant.

homepage            http://www.gnumeric.org/
master_sites        gnome:sources/${name}/${branch}/
use_xz              yes

checksums           rmd160  c06961db4f4e37d5c173feb4d228dd041ff4b38e \
                    sha256  aff50b1b62340c24fccf453d5fad3e7fb73f4bc4b34f7e34b6c3d2d9af6a1e4f \
                    size    18149400

perl5.branches      5.34

depends_build       port:pkgconfig \
                    port:intltool \
                    port:gettext \
                    port:gsed \
                    port:gtk-doc \
                    port:itstool \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    port:bison

# update-desktop-database is provided by desktop-file-utils

depends_lib         port:desktop-file-utils \
                    port:gettext-runtime \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:goffice \
                    port:psiconv \
                    port:pxlib \
                    port:perl${perl5.major}

depends_run         port:adwaita-icon-theme

gobject_introspection yes

patchfiles          patch-perl5.26-Makefile-fix.diff \
                    patch-dont-build-broken-sstest.diff \
                    patch-python-introspection-install-fix.diff

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
}

configure.cmd       ./autogen.sh

configure.perl      ${perl5.bin}

configure.args      --disable-silent-rules \
                    --disable-schemas-compile \
                    --without-gda \
                    --without-python \
                    ac_cv_prog_AWK=/usr/bin/awk

variant quartz {}

if {[variant_isset quartz]} {
    require_active_variants gtk3 quartz
    require_active_variants goffice quartz
} else {
    require_active_variants gtk3 x11
    require_active_variants goffice "" quartz
}

variant database description {builds with support for GDA database} {
    depends_lib-append        port:libgda5
    configure.args-replace    --without-gda --with-gda
}

variant python38 conflicts python39 python310 description {Build Python plugin loader using python 3.8} {
    configure.python          ${prefix}/bin/python3.8
    configure.args-replace    --without-python --with-python
    depends_lib-append        port:py38-gobject3
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.8
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
}

variant python39 conflicts python38 python310  description {Build Python plugin loader using python 3.9} {
    configure.python          ${prefix}/bin/python3.9
    configure.args-replace    --without-python --with-python
    depends_lib-append        port:py39-gobject3
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.9
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
}

variant python310 conflicts python38 python39 description {Build Python plugin loader using python 3.10} {
    configure.python          ${prefix}/bin/python3.10
    configure.args-replace    --without-python --with-python
    depends_lib-append        port:py310-gobject3
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.10
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
}

if {![variant_isset python38] && \
    ![variant_isset python39]} {
    default_variants +python310
}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
# gtk3 provides gtk-update-icon-cache
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type  gnome
