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

name                gnome-chemistry-utils
version             0.14.17
revision            2
checksums           rmd160  096bf5606326ee894885a81a0160b9600a1f4477 \
                    sha256  add1433fcaa9861b59426d8db236e51047752b47fd788575ee0fe2dc3af3926e \
                    size    5911248

set major           [join [lrange [split ${version} .] 0 1] .]
categories          gnome science chemistry
platforms           darwin linux freebsd
maintainers         nomaintainer
license             GPL-3

description         This package provides a set of Gtk3-based applications for drawing \
                    and viewing molecules, crystals and spectra.

long_description    This package provides the following programs: \
                    \n-  GChem3D displays molecule structures in 3D \
                    \n-  GChemCalc provides calculations for chemistry \
                    \n-  GChemPaint draws 2D chemical structures and reactions \
                    \n-  GChemTable provides the periodic table of the elements \
                    \n-  GCrystal displays and edits 3D crystal structures \
                    \n-  GSpectrum displays spectra files (NMR, IR, etc) \
                    \n-  Includes plugins for Gnumeric spreadsheet

homepage            https://gchemutils.nongnu.org
master_sites        https://download.savannah.gnu.org/releases/gchemutils/${major}/
use_xz              yes

depends_build       port:autoconf \
                    port:automake \
                    port:intltool \
                    port:gnome-common \
                    port:libtool \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:desktop-file-utils \
                    port:rarian \
                    port:shared-mime-info \
                    port:gnome-doc-utils \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:goffice \
                    port:gnumeric \
                    port:openbabel2 \
                    port:bodr \
                    port:chemical-mime-data \
                    port:gnome-mime-data \
                    port:libGLU \
                    port:mesa

depends_run         port:adwaita-icon-theme

patchfiles          patch-libs-gcr-document.cc.diff \
                    gnumeric-1.12.42.patch \
                    patch-plugins-loaders.diff

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 0755 ${filespath}/autogen.sh ${worksrcpath}
    reinplace "s|/usr|${prefix}|" ${worksrcpath}/autogen.sh
}

configure.cmd       ./autogen.sh

configure.args      --disable-mozilla-plugin \
                    --disable-scrollkeeper \
                    --disable-schemas-compile \
                    --disable-update-databases \
                    --disable-silent-rules

# TODO: work with the upstream devs to make a +quartz variant…
#       currently it fails to build in a +quartz environment
#       due to <gdk/gdkx.h> and OpenGL dependencies in the code.
require_active_variants gtk3 x11

post-activate {
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/scrollkeeper-update"
    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"
}

post-deactivate {
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/scrollkeeper-update"
    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  regex
livecheck.url   ${master_sites}
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
