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

name                gucharmap
version             15.0.4
revision            0
description         gucharmap is a featureful unicode character map.
long_description    {*}${description}
maintainers         {devans @dbevans} openmaintainer
categories          gnome
license             {GPL-3+ GFDL}
platforms           darwin
homepage            https://wiki.gnome.org/Apps/Gucharmap
master_sites        https://gitlab.gnome.org/GNOME/${name}/-/archive/${version}:source \
                    https://www.unicode.org/Public/15.0.0/ucd:ucd

use_bzip2           yes

set source_distfile ${distfiles}
set ucd_distfile    UCD.zip
set unihan_distfile Unihan.zip

distfiles           ${source_distfile}:source \
                    ${ucd_distfile}:ucd \
                    ${unihan_distfile}:ucd

dist_subdir         ${name}/${version}

checksums           ${source_distfile} \
                    rmd160  4f72a067e0b88be4b49bdbc15edd3ced07d8ce24 \
                    sha256  ddd219ffd22ff72ae9c938d7bd0192a3d63b04bc570ee8214790298418b02078 \
                    size    1453197 \
                    ${ucd_distfile} \
                    rmd160  cacd96bc1f717260ae55c8d11ada45dcc8a3ea9b \
                    sha256  5fbde400f3e687d25cc9b0a8d30d7619e76cb2f4c3e85ba9df8ec1312cb6718c \
                    size    7059105 \
                    ${unihan_distfile} \
                    rmd160  188a798e5c1a7b514906c82f9fb24d8445c9fee3 \
                    sha256  24b154691fc97cb44267b925d62064297086b3f896b57a8181c7b6d42702a026 \
                    size    7293545

depends_extract     port:unzip

extract.only        ${source_distfile}

post-extract {
    system -W ${workpath} "${prefix}/bin/unzip -q '${distpath}/${ucd_distfile}' -d ./UCD"
    copy ${distpath}/${unihan_distfile} ${workpath}/UCD
}

depends_build-append \
                    port:pkgconfig \
                    port:appstream-glib \
                    port:itstool \
                    port:gettext \
                    port:gtk-doc \
                    port:python311

depends_lib         port:desktop-file-utils \
                    port:freetype \
                    port:gettext-runtime \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:pcre2 \
                    path:bin/vala:vala

depends_run         port:adwaita-icon-theme

patchfiles          patch-no-Bsymbolic-functions.diff

post-patch {
    reinplace "s|^#!.*|#!${prefix}/bin/python3.11|" \
        ${worksrcpath}/data/meson_desktopfile.py
}

# requires support for C11
compiler.c_standard 2011

# requires support for -fvisibility
compiler.blacklist-append   {clang < 700}

configure.args      -Ducd_path=${workpath}/UCD

# uses g-ir-scanner, which uses $CC from env
if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})  "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch})  "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append       "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
}

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

livecheck.type      regex
livecheck.url       https://gitlab.gnome.org/GNOME/${name}/-/tags
livecheck.regex     tags/(\\d+(?:\\.\\d+)*)
