# -*- 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           github 1.0
PortGroup           meson 1.0
PortGroup           active_variants 1.1

github.setup        FontManager font-manager 0.9.0
revision            0
categories          sysutils office print
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             GPL-3

description         Simple font management application for GTK Desktop Environments
long_description    {*}${description}

checksums           rmd160  1859417dd9bceb76b5de41c266eb0c99c2dc4b21 \
                    sha256  8c2a2bfd4b26430a9f376e2e868d11e2d7a0695523f97a5402c0c3edb0b5762c \
                    size    3865493
github.tarball_from archive

set py_ver          3.11
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    port:gettext \
                    port:gtk-doc \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot} \
                    bin:vala:vala
# FIXME: on older macOS there are dbus-related errors on start-up:
# https://github.com/FontManager/font-manager/issues/338
depends_lib-append  port:dbus \
                    port:desktop-file-utils \
                    port:fontconfig \
                    port:freetype \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk4.pc:gtk4 \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    port:json-glib \
                    port:libadwaita \
                    port:libxml2 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:sqlite3

# UserActions.c:30:10: fatal error: 'gio/gdesktopappinfo.h' file not found
require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 x11

meson.native.binaries \
                    python=${prefix}/bin/python${py_ver}

configure.args-append \
                    -Dadwaita=true \
                    -Denable-nls=true \
                    -Dgtk-doc=true \
                    -Dmanager=true \
                    -Dnautilus=false \
                    -Dnemo=false \
                    -Dreproducible=false \
                    -Dsearch-provider=false \
                    -Dthunar=false \
                    -Dviewer=true \
                    -Dwebkit=false \
                    -Dyelp-doc=false

# https://github.com/FontManager/font-manager/issues/337
compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

# https://github.com/FontManager/font-manager/issues/358
if {${os.platform} eq "darwin" && ${os.major} > 22} {
    if {[string match *clang* ${configure.compiler}]} {
        configure.cflags-append \
                    -Wno-error=incompatible-function-pointer-types
    }
}

post-activate {
   system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
   system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}
