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

github.setup        FontManager font-manager 0.8.9
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  e6161a97cf844cb9793f2be92cc71dca9d232828 \
                    sha256  55e48601dd5f924412931e29c4137f6fdf6a07d7c41d977c840b60f0837740ec \
                    size    3479197
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: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/gtk+-3.0.pc:gtk3 \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    port:json-glib \
                    port:libxml2 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:sqlite3

patchfiles-append   patch-use-right-python.diff

configure.python    ${prefix}/bin/python${py_ver}

post-patch {
    reinplace "s|@PYTHON_BIN@|${configure.python}|" ${worksrcpath}/meson.build
}

configure.args-append \
                    -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
    }
}
