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

_realname=BLAKE3
pkgname=libblake3
pkgver=1.8.1
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=('fc2aac36643db7e45c3653fd98a2a745e6d4d16ff3711e4b7abd3b88639463dd')

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}"
}
