# Contributor: Antonio Rojas <arojas@archlinux.org>
# Contributor: Lex Black <autumn-wind@web.de>
# Contributor: Jesin <Jesin00@gmail.com>

_pkgname=libb2
pkgname=$_pkgname-static
pkgver=0.98.1
pkgrel=2
arch=(x86_64)
pkgdesc='C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp hash functions'
url='https://blake2.net/'
license=(custom:CC0)
depends=(gcc-libs)
options=(staticlibs)
source=("https://github.com/BLAKE2/libb2/releases/download/v$pkgver/$_pkgname-$pkgver.tar.gz")
sha256sums=('53626fddce753c454a3fea581cbbc7fe9bbcf0bc70416d48fdbbf5d87ef6c72e')

# libb2's build system discards the $CFLAGS variable.
# We can get around this by putting those flags in $CC.
export CC="${CC-cc} $CFLAGS"

build() {
  cd "$_pkgname-$pkgver"
  ./configure --prefix=/usr/static --disable-shared --enable-static --disable-native --enable-fat
  make
}

check() {
  cd $_pkgname-$pkgver
  make check
}

package() {
  cd $_pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname
}
