# -*- 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 fb303 2024.09.23.00 v
epoch               1
revision            0
checksums           rmd160  930c893ccd3bcf7912c3f1f7fbced8b6d2f574eb \
                    sha256  abcabd8bb16a37dd27906148d31eb169ce7277bd5ffe16ed06d4335d09f8312b \
                    size    293541

categories          devel
license             Apache-2

maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         fb303 is a base Thrift service and a common set of functionality for querying stats, options, and other information from a service.
long_description    {*}${description}

github.tarball_from archive

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

depends_build-append \
                    port:bison \
                    port:flex
depends_lib-append  port:fbthrift \
                    port:folly \
                    port:google-glog \
                    port:mstch \
                    port:wangle \
                    port:${port_libfmt}

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

compiler.cxx_standard   2017

# Related to: https://github.com/facebook/folly/issues/2266
platform darwin {
    if {${os.major} < 20 && ${configure.cxx_stdlib} eq "libc++"} {
        patchfiles-append \
                    patch-revert-2a8ffe3a4048f3b71e9c315036a8f46248f14ecd.diff
    }
}

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

# https://github.com/facebook/fb303/issues/30
if {${os.platform} eq "darwin" && ${os.major} < 11} {
    configure.args-replace \
                    -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=OFF
}

github.livecheck.branch main

legacysupport.newest_darwin_requires_legacy 19

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

# platform darwin {
    # The following does not seem to be needed anymore.
    # Possibly, has been fixed in GCC. Yet, retain the block for now.
    # Fixes alignment-related static assert failures on PPC:
    #   if {${build_arch} in [list ppc ppc64]} {
    #       configure.cflags-append \
    #                       -malign-natural
    #       configure.cxxflags-append \
    #                       -malign-natural
    #   }
# }

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