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

boost.version       1.81

github.setup        facebook fbthrift 2024.09.23.00 v
revision            0
checksums           rmd160  3278b6182d12a97c0bd070ee19cdc63d11ac6428 \
                    sha256  109cc46b64844f51c0b5e35140da48fc4c58e1a78be8f589227a5d02633e2d68 \
                    size    15041175

categories          devel
license             Apache-2

maintainers         nomaintainer

description         Facebook's branch of Apache Thrift, including a new C++ server.
long_description    {*}${description}

github.tarball_from archive

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

depends_build-append \
                    port:bison \
                    port:flex
depends_lib-append  port:fizz \
                    port:mstch \
                    port:mvfst \
                    port:wangle \
                    port:${port_libfmt}

patchfiles          patch-cpp2.diff

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

compiler.cxx_standard   2017

cmake.generator     Ninja

legacysupport.newest_darwin_requires_legacy 19

if {[string match *clang* ${configure.compiler}]} {
    # Don’t use libcxx with gcc.
    legacysupport.use_mp_libcxx yes
}

configure.args-append \
                    -Dthriftpy=OFF

platform darwin {
    # Disable aligned_alloc support for 10.13 and earlier
    if {${os.major} < 18} {
        # gcc does not recognize -fno-aligned-allocation
        if {[string match *clang* ${configure.compiler}]} {
            configure.cxxflags-append \
                            -fno-aligned-allocation
        }
    }
}

if {[string match *gcc* ${configure.compiler}] \
    && (${configure.build_arch} in [list i386 ppc])} {
    configure.ldflags-append \
                            -latomic
}
