# -*- 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                gtkmm3
set gname           gtkmm
version             3.24.9
revision            1

categories          x11 devel
license             LGPL-2.1+
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer

description         C++ interface to GTK+ version 3.
long_description    gtkmm3 is the official C++ interface \
                    for the popular GUI library GTK+ version 3.
homepage            http://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  8c3cfd8adb352aa8ddfa7db172d926e98a436602 \
                    sha256  30d5bfe404571ce566a8e938c8bac17576420eb508f1e257837da63f14ad44ce \
                    size    15122612

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 \
                    port:pkgconfig

depends_lib-append \
                    path:lib/pkgconfig/atkmm-1.6.pc:atkmm-1.6 \
                    path:lib/pkgconfig/cairomm-1.0.pc:cairomm-1.0 \
                    port:libepoxy \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/glibmm-2.4.pc:glibmm-2.4 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    path:lib/pkgconfig/pangomm-1.4.pc:pangomm-1.4 \
                    port:python${py_ver_nodot}

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

# gtkmm3 > 3.16.0 requires C++11 or better
compiler.cxx_standard 2011

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

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

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

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

variant x11 conflicts quartz {
    require_active_variants path:lib/pkgconfig/cairomm-1.0.pc:cairomm-1.0 x11
    require_active_variants path:lib/pkgconfig/pangomm-1.4.pc:pangomm-1.4 x11
    require_active_variants path:lib/pkgconfig/gtk+-3.0.pc:gtk3 x11

    configure.args-append \
                    -Dbuild-x11-api=true
}

variant quartz conflicts x11 {
    require_active_variants path:lib/pkgconfig/cairomm-1.0.pc:cairomm-1.0 quartz
    require_active_variants path:lib/pkgconfig/pangomm-1.4.pc:pangomm-1.4 quartz
    require_active_variants path:lib/pkgconfig/gtk+-3.0.pc:gtk3 quartz

    configure.args-append \
                    -Dbuild-x11-api=false
}

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+)*)"
