# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           legacysupport 1.1
PortGroup           meson 1.0

# LegacySupport only used for providing wrappers here.
# Neither headers nor the lib are used.
legacysupport.newest_darwin_requires_legacy 0

name                polari
version             3.38.1
revision            0
license             GPL-2+
set branch          [join [lrange [split ${version} .] 0 1] .]
description         An IRC Client for GNOME
long_description    Polari is an IRC chat client designed to integrate \
                    with the GNOME desktop. Polari supports group chatting \
                    in chat rooms and private messaging on a wide range of \
                    popular IRC servers
maintainers         {devans @dbevans} openmaintainer
categories          gnome

homepage            https://wiki.gnome.org/Apps/Polari
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  cd0e65f6a06b592bf7ee9529e0dd18aa5223bea1 \
                    sha256  9eebd3f95cb9c2792e2f5519c5921551bcfd7069470006296b748e5b447c6bac \
                    size    1050280

depends_build       port:appstream-glib \
                    port:gettext \
                    port:itstool \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:desktop-file-utils \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/gjs-1.0.pc:gjs \
                    port:gspell \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libiconv \
                    port:libsecret \
                    path:lib/pkgconfig/libsoup-2.4.pc:libsoup \
                    port:telepathy-glib \
                    port:telepathy-idle \
                    port:telepathy-logger \
                    port:telepathy-mission-control

depends_run         port:gnome-keyring \
                    port:adwaita-icon-theme

# polari(12725,0x931408) malloc: *** error for object 0x3d717cc: Non-aligned pointer being freed
legacysupport.redirect_bins polari

# data/appdata/meson.build:2:15: ERROR: Function does not take positional arguments
patchfiles-append   patch-meson.build.diff
# JS ERROR: ReferenceError: globalThis is not defined
patchfiles-append   patch-fix-main.js.diff

# Build installs dylib into one location, but the app looks for it at runtime elsewhere:
# Failed to load shared library '/opt/local/lib/libpolari-1.0.dylib' referenced by the typelib: dlopen(/opt/local/lib/libpolari-1.0.dylib, 9): image not found
post-destroot {
    move ${destroot}${prefix}/lib/polari/libpolari-1.0.dylib ${destroot}${prefix}/lib/libpolari-1.0.dylib
}

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

livecheck.type      gnome
