# Maintainer: Omar Roth <omarroth@protonmail.com>
pkgname=lsquic
pkgver=2.18.1
pkgrel=0
pkgdesc="LiteSpeed QUIC and HTTP/3 Library"
url="https://github.com/litespeedtech/lsquic"
arch="all"
license="MIT"
depends="boringssl-dev boringssl-static zlib-static libevent-static"
makedepends="cmake git go perl bsd-compat-headers linux-headers"
subpackages="$pkgname-static"
source="v$pkgver.tar.gz::https://github.com/litespeedtech/lsquic/tarball/v2.18.1
ls-qpack-$pkgver.tar.gz::https://github.com/litespeedtech/ls-qpack/tarball/a8ae6ef
ls-hpack-$pkgver.tar.gz::https://github.com/litespeedtech/ls-hpack/tarball/bd5d589"
builddir="$srcdir/litespeedtech-$pkgname-692a910"

prepare() {
	cp -r -T "$srcdir/litespeedtech-ls-qpack-a8ae6ef" "$builddir/src/liblsquic/ls-qpack"
	cp -r -T "$srcdir/litespeedtech-ls-hpack-bd5d589" "$builddir/src/lshpack"
}

build() {
	cmake \
		-DCMAKE_BUILD_TYPE=None \
		-DBORINGSSL_INCLUDE=/usr/include/openssl \
		-DBORINGSSL_LIB_crypto=/usr/lib \
		-DBORINGSSL_LIB_ssl=/usr/lib .
	make lsquic
}

check() {
	make tests
}

package() {
	install -d "$pkgdir/usr/lib"
	install -Dm755 src/liblsquic/liblsquic.a "$pkgdir/usr/lib/liblsquic.a"
}
sha512sums="
d015a72f1e88750ecb364768a40f532678f11ded09c6447a2e698b20f43fa499ef143a53f4c92a5938dfece0e39e687dc9df4aea97c618faee0c63da771561c3  v2.18.1.tar.gz
c5629085a3881815fb0b72a321eeba8de093eff9417b8ac7bde1ee1264971be0dca6d61d74799b02ae03a4c629b2a9cf21387deeb814935339a8a2503ea33fee  ls-qpack-2.18.1.tar.gz
1b9f7ce4c82dadfca8154229a415b0335a61761eba698f814d4b94195c708003deb5cb89318a1ab78ac8fa88b141bc9df283fb1c6e40b3ba399660feaae353a0  ls-hpack-2.18.1.tar.gz
"
