# Maintainer: Anatol Pomozov
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgname=apr-util
pkgver=1.6.3
pkgrel=2
pkgdesc="The Apache Portable Runtime"
arch=(x86_64 aarch64)
url="https://apr.apache.org/"
license=(Apache-2.0)
depends=(
  apr
  expat
  glibc
  libxcrypt
)
makedepends=(
  db
  gdbm
  libldap
  mariadb-libs
  nss
  openssl
  postgresql-libs
  python
  sqlite
  unixodbc
)
optdepends=(
  'gdbm: enable gdbm support'
  'libldap: enable ldap support'
  'unixodbc: enable odbc support'
  'mariadb-libs: enable mysql/mariadb support'
  'postgresql-libs: enable postgres support'
  'db: enable berkley db support'
  'sqlite: enable sqlite support'
  'nss: enable nss crypto support'
  'openssl: enable openssl crypto support'
)
source=(
  "https://archive.apache.org/dist/apr/apr-util-$pkgver.tar.bz2"{,.asc}
  "disable-failing-nss-tests.patch"
)
sha256sums=('a41076e3710746326c3945042994ad9a4fcac0ce0277dd8fea076fec3c9772b5'
            'SKIP'
            'fa1646e1d9fa579dfe3cb91fa3acb3d699111e656eb12bfc057d48e7dae9015b')
validpgpkeys=(
  '5B5181C2C0AB13E59DA3F7A3EC582EB639FF092C' # Jeff Trawick
  'B1B96F45DFBDCCF974019235193F180AB55D9977' # William A. Rowe, Jr. <wrowe@rowe-clan.net> 
  '3CE3BAC2EB7BBC624D1D22D8F3B9D88CB87F79A9' # Nick Kew <niq@apache.org>
  '65B2D44FE74BD5E3DE3AC3F082781DE46D5954FA' # "Eric Covener <covener@apache.org>"
)

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i "$srcdir/disable-failing-nss-tests.patch"
}

build() {
  cd $pkgname-$pkgver
  export CFLAGS="$CFLAGS -std=gnu89"
  ./configure \
    --prefix=/usr \
    --with-apr=/usr \
    --with-ldap \
    --with-crypto \
    --with-gdbm=/usr \
    --with-sqlite3=/usr \
    --with-nss=/usr \
    --with-odbc=/usr \
    --with-berkeley-db=/usr \
    --with-pgsql=/usr \
    --with-mysql=/usr \
    --with-oracle=/usr \
    --with-openssl=/usr
  make
}

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

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