# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=libdeflate
pkgver=1.22
pkgrel=0
pkgdesc="Library for fast, whole-buffer DEFLATE-based compression and decompression"
url="https://github.com/ebiggers/libdeflate"
arch="all"
license="MIT"
makedepends="
	cmake
	samurai
	"
checkdepends="
	zlib-dev
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-utils
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/ebiggers/libdeflate/archive/refs/tags/v$pkgver.tar.gz
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DLIBDEFLATE_BUILD_TESTS="$(want_check && echo ON || echo OFF)" \
		-DLIBDEFLATE_USE_SHARED_LIB=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j 4
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

utils() {
	pkgdesc="Command line utilities for the DEFLATE library"
	amove /usr/bin
}

sha512sums="
ca3ec7eb3e44da13164f33e56c856dbffc4ccc7b86d995afca6a23fa3f201b766d08a047871407e14a7964dd3da843be23c316e51d981cdd98f25166092de3a9  libdeflate-1.22.tar.gz
"
