# -*- 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           github 1.0
PortGroup           cmake 1.1

github.setup        pupnp pupnp 22.2.1 release-

github.tarball_from releases
name                libupnp
distname            ${name}-${version}
checksums           rmd160  f854e345efc1868a8de1ee98ded5d29411233ab8 \
                    sha256  11ac0f670aad96bd9c81cc84a6d4ae874a7b4b11073d5b88a03fd43efd097cc6 \
                    size    848926

categories          devel net
maintainers         nomaintainer

description         portable open source UPnP development kit
long_description \
    The portable SDK for UPnP(tm) Devices (libupnp) provides developers with \
    an API and open source code for building control points, devices, and \
    bridges that are compliant with Version 1.0 of the Universal Plug and Play \
    Device Architecture Specification.

license             BSD
use_bzip2           yes

# Apple Clang 15 does not accept an atomic-qualified enum as a switch
# expression. Cast the atomic load to its underlying enum type.
patchfiles-append   patch-atomic-state-switch.diff

compiler.c_standard 2011
cmake.set_c_standard \
                    yes

configure.args-append \
                    -DUPNP_ENABLE_TESTING:BOOL=OFF \
                    -DUPNP_ENABLE_TESTING_INTEGRATION:BOOL=OFF

set python_branch   3.14
set python_version  [string map {. ""} ${python_branch}]

depends_test        port:gtest \
                    port:python${python_version} \
                    port:py${python_version}-pytest

variant test description {enable tests} {
    PortGroup               legacysupport 1.1

    compiler.cxx_standard   2017
    cmake.set_cxx_standard  yes

    # clock_gettime, used by the test suite
    legacysupport.newest_darwin_requires_legacy \
                            15

    configure.args-replace  -DUPNP_ENABLE_TESTING:BOOL=OFF \
                            -DUPNP_ENABLE_TESTING:BOOL=ON
    configure.args-replace  -DUPNP_ENABLE_TESTING_INTEGRATION:BOOL=OFF \
                            -DUPNP_ENABLE_TESTING_INTEGRATION:BOOL=ON
    configure.args-append   -DPython3_EXECUTABLE=${prefix}/bin/python${python_branch}

    test.run                yes
}
