#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=libaio
pkgver=0.3.113
pkgrel=01
pkgdesc="The Linux-native asynchronous I/O facility (aio) library"
arch=(x86_64)
url="https://pagure.io/libaio"
depends=(glibc)
provides=(libaio.so)
# options=(debug) # uncomment to build debug package
#source=(https://releases.pagure.org/libaio/${pkgname}-${pkgver}.tar.gz)  # previous source
source=(https://pagure.io/libaio/archive/$pkgname-$pkgver/$pkgname-$pkgname-$pkgver.tar.gz)

prepare() {
  # -Werror, not even once
  sed 's/-Werror//' -i $pkgname-$pkgname-$pkgver/harness/Makefile
}

build() {
  # libaio is a thin wrapper around kernel syscalls, it does not use stdlib and
  # other helpers like stack protection libraries
  CFLAGS="-march=${CARCH/_/-} -mtune=generic -O2 -pipe"
  make -C $pkgname-$pkgname-$pkgver
}

check() {
#  cd "$srcdir/$pkgname-$pkgver"
#  ###  keep tjos fix for next time it fails, you mever know with this one
#  # work around gcc warning (-Werror) in test suite
#  sed -i '/strncpy/s#sizeof(TEMPLATE)#sizeof(template)#' harness/cases/19.t
#  sed -i '/strncpy/s#sizeof(TEMPLATE)#sizeof(temp_file)#' harness/cases/21.t
#  make partcheck
##  make partcheck -k -C $pkgname-$pkgver
  make partcheck -k -C $pkgname-$pkgname-$pkgver
}

package() {
  make DESTDIR="$pkgdir" install -C $pkgname-$pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgname-$pkgver/{ChangeLog,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 $pkgname-$pkgname-$pkgver/man/*.3 -t "$pkgdir/usr/share/man/man3/"
}

#---- license gpg-key sha256sums ----

license=(LGPL2.1)

sha256sums=(716c7059703247344eb066b54ecbc3ca2134f0103307192e6c2b7dab5f9528ab) # libaio-libaio-0.3.113.tar.gz
