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

name                gtk-vnc
version             1.3.1
revision            3
maintainers         {danchr @danchr} openmaintainer
categories          gnome devel
license             {LGPL GPL-3}
platforms           darwin
description         VNC viewer widget for GTK

long_description    gtk-vnc is a VNC viewer widget for GTK. It is built using \
                    coroutines allowing it to be completely asynchronous  \
                    while remaining single threaded. It provides a core C  \
                    library, and bindings for Python (PyGTK). \
                    \
                    GTK-VNC supports a number of VNC extensions aimed at  \
                    improving the user experience, particularly when  \
                    interacting with virtual machines.

homepage            https://wiki.gnome.org/Projects/gtk-vnc

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        gnome:sources/${name}/${branch}

use_xz              yes

checksums           rmd160  ea70671da05ef0024e93858c1ee41387470a4243 \
                    sha256  512763ac4e0559d0158b6682ca5dd1a3bd633f082f5e4349d7158e6b5f80f1ce \
                    size    222204

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    port:gettext \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    port:intltool \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot} \
                    path:bin/vala:vala

depends_lib-append  path:lib/pkgconfig/cairo.pc:cairo \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:libgcrypt \
                    port:pulseaudio

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

patchfiles-append   MAP_ANONYMOUS.patch

patchfiles-append   patch-meson-python3.diff
post-patch {
   reinplace "s|@@PYTHON3_BIN@@|${configure.python}|" \
                    src/meson.build
}

# for ucontext
configure.cppflags-append \
                    -D_XOPEN_SOURCE

configure.args-append \
                    -Dintrospection=enabled \
                    -Dpulseaudio=enabled \
                    -Dsasl=disabled \
                    -Dwith-vala=enabled

variant quartz conflicts x11 {
    require_active_variants gtk3 quartz
    # src/vncdisplaykeymap.c includes <gdk/gdkquartz.h>, which in turn
    # includes AppKit -- and that one fails hard in a regular C compiler...
    configure.cflags-append \
                    -ObjC
}

variant x11 conflicts quartz {
    require_active_variants gtk3 x11
}

if {![variant_isset quartz]} {
    default_variants +x11
}
if {![variant_isset x11]} {
    default_variants +quartz
}
if {![variant_isset quartz] && ![variant_isset x11]} {
    pre-configure {
        return -code error "Either +x11 or +quartz is required"
    }
}

# Note: Unlike many other GNOME projects, stable releases for 'gtk-vnc' can be odd in number.
# So we must use gnome-with-unstable, to avoid filtering those out.
livecheck.type      gnome-with-unstable
