# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=BLAKE3
pkgname=libblake3
pkgver=1.8.2
pkgrel=1
pkgdesc='The official C implementation of BLAKE3'
arch=(x86_64 i686)
url=https://github.com/BLAKE3-team/BLAKE3
msys2_reference=(
  'archlinux: libblake3'
  'aur: libblake3'
  'gentoo: dev-libs/blake3'
)
license=('spdx:CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception')
depends=(gcc-libs)
makedepends=(
  gcc
  cmake
  ninja
)
source=("https://github.com/BLAKE3-team/BLAKE3/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('6b51aefe515969785da02e87befafc7fdc7a065cd3458cf1141f29267749e81f')

build() {

  # FIXME: fails to link otherwise
  CFLAGS+=" -DBLAKE3_NO_AVX512"

  cmake \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -D BUILD_SHARED_LIBS=ON \
    -S "${_realname}-${pkgver}/c" \
    -B "build-${CARCH}"

  cmake --build "build-${CARCH}"
}

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