# -*- 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                gtkmm4
set gname           gtkmm
version             4.14.0
revision            0

categories          gnome devel
license             LGPL-2.1+
maintainers         {makr @mohd-akram} {mascguy @mascguy} openmaintainer

description         C++ interface to GTK+ version 4
long_description    gtkmm4 is the official C++ interface \
                    for the popular GUI library GTK+ version 4
homepage            https://www.gtkmm.org/

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        gnome:sources/${gname}/${branch}/
dist_subdir         ${gname}
distname            ${gname}-${version}
use_xz              yes

checksums           rmd160  88254ec90b23de9db6bb4440d2367b6d4379fd75 \
                    sha256  9350a0444b744ca3dc69586ebd1b6707520922b6d9f4f232103ce603a271ecda \
                    size    16713784

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]
set port_ver_major  [lindex [split ${version} .] 0]

depends_build-append \
                    port:gtk-doc \
                    port:json-glib \
                    port:mm-common \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot}

depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    path:lib/pkgconfig/cairomm.pc:cairomm \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/glibmm-2.68.pc:glibmm \
                    path:lib/pkgconfig/gtk4.pc:gtk4 \
                    path:lib/pkgconfig/pangomm-2.48.pc:pangomm \
                    port:graphene \
                    port:libsigcxx3

# Python only needed for scripts
depends_skip_archcheck-append \
                    python${py_ver_nodot}

compiler.cxx_standard 2017

configure.perl      /usr/bin/perl
configure.python    ${prefix}/bin/python${py_ver}
configure.env-append \
                    PERL_PATH=${configure.perl}

configure.args-append \
                    -Dbuild-demos=false \
                    -Dbuild-documentation=false \
                    -Dbuild-tests=false

patchfiles-append \
                    patch-meson-build-python-path.diff \
                    patch-aboutdialog.diff

post-patch {
    reinplace -W ${worksrcpath} \
        "s|@@PYTHON@@|${configure.python}|" \
        meson.build
}

variant x11 conflicts quartz {
    require_active_variants path:lib/pkgconfig/cairomm.pc:cairomm x11
    require_active_variants path:lib/pkgconfig/gtk4.pc:gtk4 x11
    require_active_variants path:lib/pkgconfig/pangomm-2.48.pc:pangomm x11
}

variant quartz conflicts x11 {
    require_active_variants path:lib/pkgconfig/cairomm.pc:cairomm quartz
    require_active_variants path:lib/pkgconfig/gtk4.pc:gtk4 quartz
    require_active_variants path:lib/pkgconfig/pangomm-2.48.pc:pangomm quartz
}

if {![variant_isset quartz]} {
    default_variants +x11
}

variant tests description {Enable test support} {
    configure.args-replace \
                    -Dbuild-tests=false \
                    -Dbuild-tests=true

    test.run        yes
}

livecheck.type      gnome
livecheck.name      ${gname}
livecheck.regex     "LATEST-IS-(${port_ver_major}\\.\\d*\[02468\](?:.\\d+)*)"
