# -*- 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 2026.07.27.00 v
revision            0
epoch               1
categories          devel
license             Apache-2
maintainers         {@barracuda156 macos-powerpc.org:barracuda}

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

checksums           rmd160  a994a358c41e3cdadb959944e8aeb118b29a15f3 \
                    sha256  d368683b6f6b083bcb0a250315f1c161c5ce327242c8ba4e126d953db754cfc0 \
                    size    319453
github.tarball_from archive

set libfmt_v        12
cmake.prefix_path-append \
                    ${prefix}/lib/libfmt${libfmt_v}/cmake
depends_build-append \
                    port:bison \
                    port:flex
depends_lib-append  port:fbthrift \
                    port:folly \
                    port:google-glog \
                    port:libfmt${libfmt_v} \
                    port:mstch \
                    port:wangle

# Fix error: invalid output constraint '=@ccc' in asm
compiler.blacklist-append \
                    {clang < 1200}
# As of 2025.08.04.00, still uses C++17:
compiler.cxx_standard   2017

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
}
