# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=libfabric
pkgver=1.21.0
pkgrel=1
pkgdesc="User-space API for OpenFabrics Interfaces (OFI)"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="https://ofiwg.github.io/libfabric/"
license=(GPL2)
depends=(glibc gcc-libs numactl)
options=(!lto)
source=(https://github.com/ofiwg/libfabric/releases/download/v${pkgver}/libfabric-${pkgver}.tar.bz2)
sha512sums=('6d1a561995a545f50993580c34ede0676f3e60726c99461786b9bb67bfd815709c4939a6995cbdd4e67f4548491b8ff47716d4291801d5b8750d86b91b9d2f03')

prepare() {
  cd ${pkgname}-${pkgver}
  autoreconf -fvi
}

build() {
  cd ${pkgname}-${pkgver}

  case "${CARCH}" in
    powerpc) CFLAGS+=' -latomic' ;;
  esac

  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make test
}

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