# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>

pkgname=db
pkgver=5.3.28
pkgrel=5
pkgdesc="The Berkeley DB embedded database system"
arch=('x86_64')
url="https://www.oracle.com/technology/software/products/berkeley-db/index.html"
license=('custom')
depends=('gcc-libs' 'sh')
source=(https://download.oracle.com/berkeley-db/db-${pkgver}.tar.gz atomic.patch)
sha1sums=('fa3f8a41ad5101f43d08bc0efb6241c9b6fc1ae9'
          '70a51fe2a39a21652ef01767a9c8a30515b95a33')

prepare() {
  cd $pkgname-$pkgver
  patch -p0 -i ../atomic.patch # Fix build 
}

build() {
  cd "${srcdir}"/$pkgname-${pkgver}/build_unix
  ../dist/configure --prefix=/usr --enable-compat185 \
    --enable-shared --enable-static --enable-cxx --enable-dbm \
    --enable-stl
  make LIBSO_LIBS=-lpthread
}

package() {
  cd "${srcdir}"/$pkgname-${pkgver}/build_unix
  make DESTDIR="${pkgdir}" install
  rm -r "${pkgdir}"/usr/docs
  install -Dm644 "${srcdir}"/${pkgname}-${pkgver}/LICENSE \
    "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
