# -*- 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
# O_CLOEXEC
legacysupport.newest_darwin_requires_legacy 10

github.setup        facebook proxygen 2026.10.26.00 v
revision            0
categories          devel
license             BSD
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Collection of C++ HTTP libraries including an easy to use HTTP server
long_description    This project comprises the core C++ HTTP abstractions used at Facebook. \
                    Internally, it is used as the basis for building many HTTP servers, proxies and clients. \
                    This release focuses on the common HTTP abstractions and our simple HTTPServer framework. \
                    Future releases will provide simple client APIs as well. The framework supports \
                    HTTP/1.1, SPDY/3, SPDY/3.1, HTTP/2 and HTTP/3. The goal is to provide a simple, \
                    performant and modern C++ HTTP library.
checksums           rmd160  f80f226b1f70db6a5b01c99b360e2392dcc0c85e \
                    sha256  a528e50d3bf7139cdc30bbcd73224f720dc3422849441a8231151262a3be2281 \
                    size    1869326
github.tarball_from archive

# Fix macOS compat:
patchfiles          patch-tcpinfo.diff

# Fix broken linking:
patchfiles-append   patch-fix-monolith-httpserver-link.diff

set ca_path         ${prefix}/share/curl/curl-ca-bundle.crt
post-patch {
    reinplace "s|/etc/ssl/certs/ca-certificates.crt|${ca_path}|" ${worksrcpath}/proxygen/httpclient/samples/curl/CurlClientMain.cpp
}

# hq(93915) malloc: *** error for object 0xa04da754: pointer being freed was not allocated
legacysupport.redirect_bins hq masque_client proxygen_cocurl proxygen_curl proxygen_echo \
                    proxygen_h3datagram_client proxygen_httperf2 proxygen_proxy proxygen_static

set libfmt_v        12
cmake.prefix_path-append \
                    ${prefix}/lib/libfmt${libfmt_v}/cmake

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]
depends_build-append \
                    port:gperf \
                    port:python${py_ver_nodot}
depends_lib-append  port:c-ares \
                    port:folly \
                    port:fizz \
                    port:libfmt${libfmt_v} \
                    port:libsodium \
                    port:mvfst \
                    port:wangle \
                    port:zlib \
                    port:zstd

depends_run         port:curl-ca-bundle

compiler.blacklist-append \
                    {clang < 1400}
compiler.cxx_standard   2020

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DPROXYGEN_PYTHON=${prefix}/bin/python${py_ver}

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

if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    # ___atomic_compare_exchange_8, ___atomic_store_8, ___atomic_load_8
    configure.ldflags-append \
                    -latomic
}

github.livecheck.branch main
