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

name                mm-common
version             1.0.6
revision            0

categories          gnome devel
license             GPL-2+
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer
supported_archs     noarch
platforms           any

description         The mm-common module provides the build infrastructure and \
                    utilities shared among the GNOME C++ binding libraries.

long_description    The mm-common module provides the build infrastructure and \
                    utilities shared among the GNOME C++ binding libraries. \
                    It is only a required dependency for building the C++ bindings \
                    from the gnome.org version control repository.  An installation \
                    of mm-common is not required for building tarball releases, \
                    unless configured to use maintainer-mode.
homepage            https://www.gnome.org/

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

checksums           sha256  b55c46037dbcdabc5cee3b389ea11cc3910adb68ebe883e9477847aa660862e7 \
                    rmd160  dee3bcc1b20cdd776634d61cb6ade4ab552220b0 \
                    size    287832

# 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:curl \
                    port:gsed \
                    port:wget

depends_lib-append \
                    port:python${py_ver_nodot}

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

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

    reinplace "s|/usr/bin/env python3$|${configure.python}|" \
                    util/mm-common-get.in

    fs-traverse f ${worksrcpath} {
        if {[string match *.py ${f}]} {
            ui_info "patching script: ${f}"
            reinplace "s|/usr/bin/env python3$|${configure.python}|" ${f}
        }
    }
}

configure.args-append \
                    -Duse-network=false

livecheck.type      gnome
