# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           gitlab 1.0
PortGroup           meson 1.0

name                libmm-glib
gitlab.instance     https://gitlab.freedesktop.org
gitlab.setup        mobile-broadband ModemManager 1.22.0
revision            0
categories          comms devel gnome
license             LGPL-2.1+
maintainers         nomaintainer

description         Cellular modem control and connectivity
long_description    {*}${description}.
use_bzip2           yes

checksums           rmd160  664e3abc5a7bca1ec979c08026b32aaf29ceec07 \
                    sha256  772133aae2f34c12ee19751e0b61f0b8223a85beead0debd4ee42e8fc7a6dcd7 \
                    size    1426814

meson.wrap_mode     nodownload

# https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1241
# https://gitlab.gnome.org/World/Chatty/-/issues/947
# https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/910
# https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/912
# https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/913
patch.pre_args-replace -p0 -p1
patchfiles-append   0001-mm-netlink.c-fix-include-order.patch \
                    0002-mm-netlink.c-include-Linux-specific-headers-only-on-.patch \
                    0003-mm-port-serial-qcdm.c-fix-for-macOS.patch \
                    0004-mm-port-serial.c-fix-build-when-non-POSIX-constants-.patch \
                    0005-libqcdm-fix-endian-macros.patch \
                    0006-libqcdm-fix-build-when-non-POSIX-constants-are-undef.patch \
                    0007-libqcdm-fix-malloc-include.patch \
                    0008-mm-port-serial.c-B460800-and-B921600-undefined-on-ma.patch \
                    0009-mm-port-serial.c-move-Linux-specific-stuff-inside-ma.patch \
                    0010-No-netlink-on-macOS.patch \
                    0011-mm-port-net.c-fix-header-for-macOS.patch

# Use the right python.
set python_branch   3.12
set python_version  [string map {. {}} ${python_branch}]
configure.python    ${prefix}/bin/python${python_branch}

patchfiles-append   patch-meson.build.diff
post-patch {
    reinplace "s|@PYTHON@|${configure.python}|" ${worksrcpath}/meson.build
}

depends_build-append \
                    path:bin/pkg-config:pkgconfig \
                    port:python${python_version} \
                    path:bin/vala:vala

depends_lib-append  port:dbus \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection

depends_run-append  port:bash-completion

compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

configure.args-append \
                    -Dat_command_via_dbus=false \
                    -Dbuiltin_plugins=false \
                    -Dexamples=false \
                    -Dgtk_doc=false \
                    -Dintrospection=true \
                    -Dmbim=false \
                    -Dpolkit=no \
                    -Dpowerd_suspend_resume=false \
                    -Dqmi=false \
                    -Dqrtr=false \
                    -Dsystemd_journal=false \
                    -Dsystemd_suspend_resume=false \
                    -Dsystemdsystemunitdir=no \
                    -Dtests=false \
                    -Dudev=false \
                    -Dudevdir=share/ModemManager \
                    -Dvapi=true
