# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=plfit
pkgver=1.0.1
pkgrel=0
pkgdesc="Tool for fitting power-law distributions to empirical data"
url="https://github.com/ntamas/plfit"
arch="all"
license="GPL-2.0-or-later"
makedepends="cmake samurai"
subpackages="$pkgname-static $pkgname-libs $pkgname-dev"
source="https://github.com/ntamas/plfit/archive/$pkgver/plfit-$pkgver.tar.gz"

build() {
	cmake -B builddir -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DBUILD_SHARED_LIBS=ON
	cmake -B builddir-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release

	cmake --build builddir
	cmake --build builddir-static
}

check() {
	ctest --test-dir builddir
}

package() {
	# Install static build first because we want the utilities to be linked dynamically.
	DESTDIR="$pkgdir" cmake --install builddir-static
	DESTDIR="$pkgdir" cmake --install builddir
}

sha512sums="
8d1f43bdd038310504500367d808b07b14d226af116bf205d2185fc9bdd669be5e28b773df1d100b396f40ae918e3c86ea94e5f10892167514a139b0505a6c15  plfit-1.0.1.tar.gz
"
