# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=nghttp2
pkgver=1.69.0
pkgrel=0
pkgdesc="HTTP/2 C client, server and proxy"
url="https://nghttp2.org"
arch="all"
license="MIT"
makedepends_host="libev-dev openssl-dev>3 zlib-dev c-ares-dev"
checkdepends="cunit-dev"
subpackages="$pkgname-static $pkgname-doc $pkgname-dev $pkgname-libs"
source="https://github.com/nghttp2/nghttp2/releases/download/v$pkgver/nghttp2-$pkgver.tar.xz"

# secfixes:
#   1.68.1:
#     - CVE-2026-27135
#   1.57.0-r0:
#     - CVE-2023-44487
#   1.41.0-r0:
#     - CVE-2020-11080
#   1.39.2-r0:
#     - CVE-2019-9511
#     - CVE-2019-9513

check() {
	make check
	# integration tests require go, which is only available
	# in community at the moment of writing. Disabling until
	# go is moved into main
#	cd "integration-tests"
#	make itprep
#	make it
}

build() {
	if [ -z "$BOOTSTRAP" ]; then
		# fat to keep static non-lto too for non-gcc
		# -20% size
		export CFLAGS="$CFLAGS -ffat-lto-objects -flto=auto"
		export CXXFLAGS="$CXXFLAGS -ffat-lto-objects -flto=auto"
	fi
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-examples \
		--disable-http3 \
		--disable-werror \
		--enable-app \
		--enable-static \
		--enable-threads \
		--with-libcares \
		--with-libev \
		--with-openssl \
		--without-jansson \
		--without-jemalloc \
		--without-libbpf \
		--without-libnghttp3 \
		--without-libngtcp2 \
		--without-libxml2 \
		--without-mruby \
		--without-neverbleed \
		--without-systemd \
		"$(want_check && echo --with-cunit || echo --without-cunit)"
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
31858cfd4a85995d006753c40393a7c23d2bfdd54fdb355757bef1a72b42177d31fff958e9e765a19d83e949eac77998e2bbe933b9390d1f2a1365506f5f6271  nghttp2-1.69.0.tar.xz
"
