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

github.setup        blackhole89 notekit ff37a8b9115bd3a023ca8c6d80ad923af8d9df8f
version             2024.03.14
categories          gnome sysutils
license             MIT
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         GTK3 hierarchical markdown note-taking application
long_description    {*}${description} with tablet support.
checksums           rmd160  4e56fc48e614e3cfd507466cac4a062da93949b4 \
                    sha256  b1068d5c9207153833f9b2dce5538e4424d789bb65a6a9ce9ba29b790495be97 \
                    size    2911104
github.tarball_from archive

depends_build-append \
                    port:pkgconfig

depends_lib-append  port:desktop-file-utils \
                    port:fontconfig \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:gtkmm3 \
                    port:gtksourceviewmm3 \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    port:jsoncpp \
                    port:MicroTeX \
                    port:zlib

# Used to provide wrappers.
legacysupport.newest_darwin_requires_legacy 0
legacysupport.redirect_bins ${name}

# https://github.com/blackhole89/notekit/issues/158
# Clang needs this patch; GCC does not fail without it, but still complains:
# warning: capture of variable 'mainwindow' with non-automatic storage duration
# So use it for both.
patchfiles-append   clang-build.patch

# Find resources:
patchfiles-append   patch-use-correct-path.diff

# Meson fails to find a version from GTK3.
# But we do not need it, since we do it manually below.
patchfiles-append   patch-gtk_update_icon_cache.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/mainwindow.cpp
}

compiler.cxx_standard   2020

configure.args-append \
                    -Dclatexmath=true

# Port installs hicolor icons, desktop application file and gschemas
post-activate {
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}
