PKGNAME=nghttp2
PKGSEC=libs
PKGDES="Library to implement the HTTP/2 protocol and the HPACK header compression algorithm"
PKGDEP="c-ares jansson jemalloc libbpf libev"
PKGDEP__RETRO="c-ares jansson libev"
BUILDDEP="cython llvm"
BUILDDEP__RETRO=""

# Building the libbpf binding requires generating a eBPF program, which must be
# built with Clang.
USECLANG=1
# FIXME: Linker test fails on loongson3.
#
# /usr/bin/mips64el-aosc-linux-gnuabi64-ld: conftest: `.got.plt' entry VMA of
# 0x120010fe8 outside the 32-bit range supported; consider using `-Ttext-segment=...'
USECLANG__LOONGSON3=0
# FIXME: Disabling Clang on riscv64.
#
# /usr/bin/riscv64-aosc-linux-gnu-ld: error: LLVM gold plugin: linking module
# flags 'SmallDataLimit': IDs have conflicting values in
# '../third-party/.libs/liburl-parser.a.llvm.184.url_parser.c' and 'ld-temp.o'
USECLANG__RISCV64=0
# FIXME: Disabling Clang on ppc64el.
#
# During configure...
# /usr/include/bits/wchar-ldbl.h:84:1: error: cannot apply asm label to
# function after its first use
USECLANG__PPC64EL=0

USECLANG__RETRO=0

# FIXME: Disabling PIC and PIE flags to make Python module build with GCC.
AB_FLAGS_PIC=0
AB_FLAGS_PIE=0

# Note: --enable-debug turns on debug output.
#       --disable-failmalloc disables a test program.
#       --enable-http3 is experimental (as of 1.58.0).
#
# FIXME: --disable-examples to skip broken examples (event.h incompatibility).
ABTYPE=autotools
AUTOTOOLS_AFTER=(
    '--disable-werror'
    '--disable-debug'
    '--enable-threads'
    '--enable-app'
    '--enable-hpack-tools'
    '--disable-examples'
    '--disable-failmalloc'
    '--disable-lib-only'
    '--disable-http3'
    '--disable-assert'
    '--enable-largefile'
    '--with-libxml2'
    '--with-jansson'
    '--with-zlib'
    '--with-libevent-openssl'
    '--with-libcares'
    '--with-openssl'
    '--with-libev'
    '--with-jemalloc'
    '--with-systemd'
    '--with-mruby=no'
    '--with-neverbleed=no'
    '--with-libngtcp2=no'
    '--with-libnghttp3=no'
    '--with-libbpf'
)
# FIXME: Clang build fails on loongson3, ppc64el, and riscv64, disabling libbpf.
AUTOTOOLS_AFTER__NOBPF=(
    "${AUTOTOOLS_AFTER[@]}"
    '--with-libbpf=no'
)
AUTOTOOLS_AFTER__LOONGSON3=(
    "${AUTOTOOLS_AFTER__NOBPF[@]}"
)
AUTOTOOLS_AFTER__PPC64EL=(
    "${AUTOTOOLS_AFTER__NOBPF[@]}"
)
AUTOTOOLS_AFTER__RISCV64=(
    "${AUTOTOOLS_AFTER__NOBPF[@]}"
)
AUTOTOOLS_AFTER__RETRO=(
    "${AUTOTOOLS_AFTER__NOBPF[@]}"
    '--without-jemalloc'
)

# Needed by Afterglow, whereas FAIL_ARCH defaults to mainline-only.
FAIL_ARCH="!(mainline|retro)"
