# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=libetebase
pkgver=0.5.6
pkgrel=2
pkgdesc='Etebase C library'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://github.com/etesync/libetebase'
license=(BSD)
depends=(gcc-libs
         glibc
         libsodium
         openssl)
makedepends=(rust)
source=(https://github.com/etesync/libetebase/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('b149afcabce839347cb3cef870e781d34df32016885bfed50c08dcab0ab9b1f0')

prepare() {
  cd $pkgname-$pkgver

  case "${CARCH}" in
    riscv64) CARCH=riscv64gc ;;
  esac
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $pkgname-$pkgver
  env CARGO_INCREMENTAL=0 SODIUM_USE_PKG_CONFIG= cargo build --release --locked --offline
  make pkgconfig
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
