# -*- 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           compiler_blacklist_versions 1.0
PortGroup           conflicts_build 1.0
PortGroup           legacysupport 1.1
PortGroup           meson 1.0

# https://bugzilla.gnome.org/show_bug.cgi?id=636134
PortGroup           muniversal 1.0

# _strnlen
legacysupport.newest_darwin_requires_legacy 10

name                gstreamer1
set my_name         gstreamer
# please only commit stable updates (even numbered releases)
version             1.24.7
revision            0
description         GStreamer is a library for constructing graphs of media-handling components.
long_description    The applications it supports range from simple Ogg/Vorbis playback, audio/video \
                    streaming to complex audio (mixing) and video (non-linear editing) processing.
maintainers         nomaintainer
categories          gnome
license             LGPL-2+
homepage            https://${my_name}.freedesktop.org/
master_sites        https://gstreamer.freedesktop.org/src/${my_name}/
distname            ${my_name}-${version}
use_xz              yes

checksums           rmd160  dd5c10ec1d7aa8286df91eb48c69e7a3c5198d78 \
                    sha256  c0e75b124c52bb7a0c3dcdb734b2ad260ea7286a8745cf2ea629d4c849e6a958 \
                    size    1859604

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]
set python.bin      ${prefix}/bin/python${py_ver}

depends_build-append \
                    port:gettext \
                    port:gtk-doc \
                    port:gzip \
                    path:bin/perl:perl5 \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot}

depends_lib-append  port:bison \
                    port:flex \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    port:libxml2

conflicts_build     check

patchfiles          patch-gstreamer1-darwin-numcpufix-sysctl.diff \
                    patch-gst-gst-c-tiger-no-procpidpath.diff

# Temporary fix until the upstream addresses the breakage.
# https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3437
if {${os.platform} eq "darwin" && ${os.major} < 16} {
    patchfiles-append \
                    0001-Revert-macos-Fix-gst_macos_main-terminating-whole-pr.patch
}

post-patch {
    reinplace "s|/usr/bin/env python3|${python.bin}|" \
        ${worksrcpath}/scripts/extract-release-date-from-doap-file.py \
        ${worksrcpath}/scripts/dist-translations.py \
        ${worksrcpath}/gst/parse/get_flex_version.py \
        ${worksrcpath}/gst/parse/gen_lex.py.in \
        ${worksrcpath}/gst/parse/gen_grammar.py.in \
        ${worksrcpath}/docs/gst-plugins-doc-cache-generator.py
}

configure.env-append    PERL_PATH=${prefix}/bin/perl
configure.cflags-append -funroll-loops -fstrict-aliasing -fno-common

# Match blacklist used in gstreamer1-gst-plugins-base
# error: redefinition of typedef ‘GstHarness’
compiler.blacklist-append \
                    *gcc-3.* *gcc-4.* {clang < 212}

configure.args-append \
                    -Dexamples=disabled \
                    -Dintrospection=enabled \
                    -Dlibdw=disabled \
                    -Dlibunwind=disabled \
                    -Dbash-completion=disabled

test.run            yes
test.target         check

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${my_name}-(\\d+\\\.\\d*\[02468\](?:\\.\\d+)*)${extract.suffix}"
