# -*- 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.4
revision            1
categories          sysutils office print
maintainers         nomaintainer
license             GPL-3

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

checksums           rmd160  5322c6b8e671cdd63eac99b663edaedebf96dfc5 \
                    sha256  3e4aefdaa0fbd37410c35421501819b19ba1f6847bad7a1f51707209c4147063 \
                    size    4145891
github.tarball_from archive

set py_ver          3.13
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 \
                    port:libarchive

license_noconflict  vala

# 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"
}
