# Maintainer: PktSurf <smlinux@pktsurf.in>
app=db
version=6.2.23
build=2sml
homepage="https://www.oracle.com/database/technologies/related/berkeleydb.html"
download="http://download.oracle.com/berkeley-db/db-$version.tar.gz"
desc="Berkeley embedded database library"
requires="gcc-libs"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  applypatch $srcdir/bdb-configure.patch
}

build() {
  if [[ $arch = aarch64 ]]; then
    db_atomic=gcc-builtin
  else
    db_atomic=x86/gcc-assembly
  fi

  cd build_unix

  db_cv_clock_monotonic=yes \
  db_cv_build_sequence=yes \
  db_cv_mmap_extend=yes \
  db_cv_atomic="$db_atomic" \
  ../dist/configure \
    --prefix= \
    --enable-shared \
    --disable-static \
    --enable-dbm \
    --enable-cxx 
  
  # Disable documentation
  sed -i 's/^install_docs:/install_docs:\n\ttrue\ninstall_crap:/' Makefile

  make
  make install DESTDIR=$pkg

  cp ../LICENSE $pkgdocs/

  mkfinalpkg
}

sha512sums="
beb17661a44a4bb3feb3e95d6670599087fe38dd604f3902f90bf0336dc1d823adc7f56be854a55caa995f1503681896842ecfcd3dd668e47370c624255bd4ee  db-6.2.23.tar.lz
8a91a6ff079792bf36efc11302140eef857019ab8e66058e39ea8b9a81dc2b4837fe2941b380343cf74e219d800eba2a08194d5b76fb48afc9cf0a599f1bf919  bdb-configure.patch
"
