# nghttp2 - HTTP/2 library
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=nghttp2
version=1.68.0
release=3
desc="HTTP/2 library"
url="https://nghttp2.org/"
license="MIT"
depend="glibc"
makedepend=""
source="https://github.com/nghttp2/nghttp2/releases/download/v1.68.0/nghttp2-1.68.0.tar.xz"
sha256="SKIP"

build() {
	cd "nghttp2-1.68.0"
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# The examples are not installed and are the only part of this package
	# that needs libevent, so they are the only part that can fail a build
	# nothing would have shipped.
	case "$_help" in *--enable-examples*) _opts="$_opts --disable-examples" ;; esac
	# Library only. nghttp2 is here because curl speaks HTTP/2 through it;
	# the applications that come with it - nghttpx, h2load, nghttpd - are
	# C++ and link libc++, which on this distribution means any image
	# carrying curl also has to carry the LLVM package to satisfy one
	# runtime library. 350 MiB of compiler for a proxy nothing runs.
	case "$_help" in *--enable-app*)      _opts="$_opts --disable-app" ;; esac
	case "$_help" in *--enable-hpack-tools*) _opts="$_opts --disable-hpack-tools" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	make -j"$JOBS"
}

package() {
	cd "nghttp2-1.68.0"
	make DESTDIR="$pkgdir" install
	# inflatehd and deflatehd are HPACK development tools - they read and
	# write header-compression test vectors and are of no use on a running
	# system. They are also the only things in this package that link
	# jemalloc, so shipping them meant a malloc, a C++ runtime and a
	# compiler all had to be on any image that carried nghttp2.
	rm -f "$pkgdir/usr/bin/inflatehd" "$pkgdir/usr/bin/deflatehd"
}
