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

name                libsoup-devel
conflicts           libsoup
set my_name         libsoup
version             3.6.5
revision            0

categories          gnome net
license             LGPL-2+
maintainers         {mascguy @mascguy} {devans @dbevans} openmaintainer

description         Soup is an HTTP library implementation in C.
long_description    Soup provides a queued asynchronous callback-based \
                    mechanism for sending and servicing SOAP requests \
                    and a WSDL (Web Service Definition Language) for C \
                    compilers which generates client stubs and server \
                    skeletons for easily calling and implementing SOAP \
                    methods.
homepage            https://wiki.gnome.org/Projects/libsoup

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

checksums           rmd160  860d589debefd3c74faa4adb15e9494faea4e944 \
                    sha256  6891765aac3e949017945c3eaebd8cc8216df772456dc9f460976fbdb7ada234 \
                    size    1568404

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

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

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

depends_lib-append \
                    port:brotli \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:glib-networking \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    port:kerberos5 \
                    port:libpsl \
                    port:libxml2 \
                    port:nghttp2 \
                    port:sqlite3 \
                    port:zlib

# Pull in legacy bindings via 'libsoup-2.4', so that dependents don't have to be changed
depends_lib-append \
                    port:libsoup-2.4

compiler.blacklist-append \
                    {*gcc-[34].*} {clang < 421}

configure.args-append \
                    -Dbrotli=enabled \
                    -Dgssapi=enabled \
                    -Ddocs=disabled \
                    -Dintrospection=enabled \
                    -Dntlm=disabled \
                    -Dsysprof=disabled \
                    -Dtests=false

# help it to find python
configure.python    ${prefix}/bin/python${py_ver}

post-patch {
    reinplace "s|/usr/bin/env python3|${configure.python}|" \
        ${worksrcpath}/get_apache_modules_dirs.py \
        ${worksrcpath}/libsoup/generate-header-names.py \
        ${worksrcpath}/libsoup/generate-version-header.py
}

# uses g-ir-scanner, which uses $CC from env
if { ${universal_possible} && [variant_isset universal] } {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})     "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch})  "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append       "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
}

platform darwin 8 {
    # meson on Tiger cannot use rpaths, so we workaround with this to find dylib
    destroot.env-append    "DYLD_LIBRARY_PATH=${build_dir}/${my_name}"
}

variant docs description {Enable doc generation} {
    depends_build-append \
                    port:gi-docgen \
                    port:gtk-doc
    configure.args-replace \
                    -Ddocs=disabled \
                    -Ddocs=enabled
}

livecheck.type      gnome
livecheck.name      ${my_name}
