# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libcork
pkgver=0.15.0
pkgrel=7
pkgdesc="Simple, easily embeddable cross-platform C library"
url="https://github.com/dcreager/libcork"
arch="all"
license="BSD-3-Clause"
makedepends="cmake check-dev samurai"
checkdepends="python3"
subpackages="$pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/dcreager/libcork/archive/$pkgver.tar.gz
	fix-dumb-script.patch
	fix-gcc-10.patch
	no-git.patch
	format-security.patch
	"

prepare() {
	default_prepare

	echo "$pkgver" > RELEASE-VERSION
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DENABLE_STATIC=OFF \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	ctest -E '(shared-test-core|shared-test-file|run-paths-01)'
}

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

tools() {
	pkgdesc="$pkgdesc (tools)"

	amove usr/bin
}

sha512sums="
8f41cce2101b96707068a21e5bd0a43c23f996c3620e7dd36621ed4bdd3f92851a92ea56ed92db40d7d8fe55ddfbdfcdaac4d2c8b2fc6cb3b1abe3b0e74c6a75  libcork-0.15.0.tar.gz
c80c3edb45e4051b5b3aac4b4980296e54d78bee0410e833278034a9dcdd971f174be01f8420bb94e294bc229e69d13b200679c600ee56920348af94ccd51b45  fix-dumb-script.patch
b0ce51a8f63eb8095160dd018f54134988fce7cb18d9fcdce45aae250ea098339aab786509d3bd3bbdd3d71c6cbd459f9ff3950ebeb21a0ea0774d53b3892067  fix-gcc-10.patch
26d4ae2e433b4c969c6991fa3607956df9732614cd51628d05286907cfed91dbcce418033e266461c0a3fb5671629f5155b50bf1ba56875ed51dc2b497748a2b  no-git.patch
9a2dcc1bb939cbce1401388dd4aa6c4a8cf83c1f0801cb3836beab3feaeab751ddafa1af972b0ff160989e38081bb157925d2502cc837f70204c56366c156728  format-security.patch
"
