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

github.setup        confluentinc librdkafka 2.12.1 v
revision            0

categories          net
license             BSD
maintainers         {@alexeyt820 gmail.com:alexey.trenikhin+macports} openmaintainer
description         The Apache Kafka C/C++ library
long_description    Full Apache Kafka protocol support, including producer and consumer

checksums           sha256  ec103fa05cb0f251e375f6ea0b6112cfc9d0acd977dc5b69fdc54242ba38a16f \
                    rmd160  06a32ef995af1817c5c713092852bb419a8c08b6 \
                    size    4873212
github.tarball_from archive

# https://github.com/confluentinc/librdkafka/issues/4759
patchfiles-append   patch-unbreak-configure.diff

configure.args-append   --disable-curl \
                        --disable-gssapi \
                        --disable-lz4-ext \
                        --disable-ssl \
                        --disable-syslog \
                        --disable-zstd

depends_build-append    path:bin/pkg-config:pkgconfig
depends_lib-append      port:zlib

# rdkafka_queue.h: error: thread-local storage not supported for this target
compiler.thread_local_storage yes

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne "" && ${os.major} < 22} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

variant zstd description {Enable support for zstd compression} {
  depends_lib-append      port:zstd
  configure.args-replace  --disable-zstd --enable-zstd
}

variant lz4 description {Enable external LZ4 library support} {
  depends_lib-append      port:lz4
  configure.args-replace  --disable-lz4-ext --enable-lz4-ext
}

variant ssl description {Enable SSL support} {
  depends_lib-append      path:lib/libssl.dylib:openssl
  configure.args-replace  --disable-ssl --enable-ssl
}

variant sasl description {Enable SASL GSSAPI support with Cyrus libsasl2} {
  depends_lib-append      port:cyrus-sasl2
  configure.args-replace  --disable-gssapi --enable-gssapi
}

variant curl description {Enable OpenID Connect support with curl} {
  depends_lib-append      port:curl
  configure.args-replace  --disable-curl --enable-curl
}

default_variants    +zstd +lz4 +ssl +sasl +curl
configure.ldflags-prepend     -L../src

test.run            no

github.livecheck.regex  {([0-9.]+)}
github.tarball_from     archive
