# -*- 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                glibmm
conflicts           glibmm-devel
set my_name         glibmm

# this version should match glib2, as closely as possible
version             2.88.0
epoch               1

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

description         C++ interface to glib
long_description    {*}${description}
homepage            https://www.gtkmm.org/

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

checksums           rmd160  0b7afc211194261ba709ef3647f6e1e1d93db888 \
                    sha256  a6549da3a6c43de83b8717dae5413c57a60d92f6ecc624615c612d0bb0ad0fe2 \
                    size    9523144

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

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

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

depends_lib-append  path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libsigcxx3

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

# glibmm > 2.68.0 requires C++17 or better
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-documentation=false \
                    -Dbuild-examples=true \
                    -Dmaintainer-mode=false

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

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

variant quartz conflicts x11 {
    require_active_variants \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 quartz
}

variant x11 conflicts quartz {
    require_active_variants \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 x11
    patchfiles-append \
                    patch-no_cocoa.diff
}

if {![variant_isset quartz]} {
    default_variants +x11
}
if {![variant_isset x11]} {
    default_variants +quartz
}
if {![variant_isset quartz] && ![variant_isset x11]} {
    error "Either +x11 or +quartz is required"
}

test.run            yes
test.target         check

livecheck.type      gnome
livecheck.name      ${my_name}
