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

name            xorg-libxcb
version         1.17.0
revision        0

checksums       rmd160  a5e36fb6d60154354c60c6fe94082f4c2d23e5fd \
                sha256  599ebf9996710fea71622e6e184f3a8ad5b43d0e5fa8c4e407123c88a59a6d55 \
                size    455208

categories      x11 devel
license         X11
maintainers     {jeremyhu @jeremyhu} openmaintainer
description     X.org libxcb
homepage        https://xcb.freedesktop.org/
long_description The X C Binding (XCB) library
master_sites     xorg:individual/lib

distname        libxcb-${version}

use_xz          yes

depends_build   port:pkgconfig

depends_lib     port:xorg-libXau \
                port:xorg-libXdmcp \
                port:xorg-xcb-proto

configure.checks.implicit_function_declaration.whitelist-append strchr

configure.args  --disable-devel-docs \
                --disable-silent-rules

variant docs description "Install extra documentation" {
    depends_build-append \
        path:bin/doxygen:doxygen \
        path:bin/dot:graphviz

    depends_skip_archcheck-append \
        doxygen

    configure.args-delete \
        --disable-devel-docs

    configure.args-append \
        --enable-devel-docs

    configure.env-append \
        DOXYGEN=${prefix}/bin/doxygen
}

# No need to use require_active_variants here. Technically, `xorg-libxcb +python37` builds fine
# with `xorg-xcb-proto +python36` as the xcbgen module in xorg-xcb-proto is not located using
# usual Python import mechanism. Instead, the path for xcbgen is recorded in
# `$prefix/lib/pkgconfig/xcb-proto.pc` as the pythondir variable when building xorg-xcb-proto
# and the build system of libxcb loads xcbgen using that pkg-config variable [1].
#
# [1] https://gitlab.freedesktop.org/xorg/lib/libxcb/blob/1.13.1/configure.ac#L85

set python_vers {3.10 3.11 3.12 3.13 3.14}
set python_ports [lmap v $python_vers {string cat python[string map {. ""} $v]}]
foreach python_ver $python_vers python_port $python_ports {
    variant $python_port conflicts {*}[ldelete $python_ports $python_port] \
            description "Use python $python_ver" "
        depends_build-append    port:${python_port}
        license_noconflict      $python_port
        configure.python        ${prefix}/bin/python${python_ver}
    "
}

if {![variant_isset python310] && ![variant_isset python311]
        && ![variant_isset python312] && ![variant_isset python313]} {
    default_variants +python314
}

livecheck.type  regex
livecheck.url   https://xorg.freedesktop.org/archive/individual/lib/?C=M&O=D
livecheck.regex libxcb-(\\d+(?:\\.\\d+)*)
