# -*- 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.0.6 release-

github.tarball_from releases
name                libupnp
distname            ${name}-${version}
checksums           rmd160  b86053b0cefd8dfeb0e697a31bc9b78a01b9d8b3 \
                    sha256  7f4e1eed75d904180b705570c8c55d70a47885e46f702f4b96e4fac03159f5d7 \
                    size    776325

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
}
