# -*- 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           boost 1.0
PortGroup           cmake 1.1
PortGroup           compiler_blacklist_versions 1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

# O_CLOEXEC
legacysupport.newest_darwin_requires_legacy 10

boost.version       1.81

github.setup        facebookincubator fizz 2024.09.23.00 v
revision            2
checksums           rmd160  804d87fb37e7ed5fd6a5803f5763ec6b8c877738 \
                    sha256  becb7ba4a31f18afe1f92d0effabcc22edd41e82a83d8710e02ea3a12f2c8b95 \
                    size    765586

categories          devel
license             BSD
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         Fizz is a TLS 1.3 implementation
long_description    {*}${description}

github.tarball_from releases
distname            ${name}-v${version}
extract.mkdir       yes

set port_libfmt     libfmt11
cmake.module_path-append \
                    ${prefix}/lib/${port_libfmt}/cmake

depends_lib-append  port:bzip2 \
                    port:double-conversion \
                    port:folly \
                    port:gflags \
                    port:google-glog \
                    port:libevent \
                    port:liboqs \
                    port:libsodium \
                    port:libunwind \
                    port:lz4 \
                    port:zlib \
                    port:zstd \
                    port:${port_libfmt}

cmake.source_dir    ${worksrcpath}/${name}

# Fix error: invalid output constraint '=@ccc' in asm
compiler.blacklist-append \
                    {clang < 1200}

compiler.cxx_standard   2017
cmake.generator     Ninja

configure.args-append \
                    -DBUILD_TESTS=OFF \
                    -DBUILD_SHARED_LIBS=ON

# There is a configure check, but it is broken:
# https://github.com/facebookincubator/fizz/issues/139
if {[string match *gcc* ${configure.compiler}]} {
    # ___atomic_fetch_add_8
    configure.ldflags-append  -latomic
}