# Maintainer: Sundaram Ramaswamy <legends2k@yahoo.com>

pkgname=bc
pkgver=1.07.1
pkgrel=2
pkgdesc="An arbitrary precision calculator language"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/bc"
license=('GPL')
depends=('libreadline' 'ncurses')
makedepends=('ed' 'gcc' 'libreadline-devel' 'ncurses-devel')
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('62adfca89b0a1c0164c2cdca59ca210c1d44c3ffc46daf9931cf4942664cb02a')

prepare () {
  cd "${srcdir}"/${pkgname}-${pkgver}
  # patch -p1 -i "${srcdir}"/0001-Fix-readline-prototype.patch
  return 0
}

build () {
  [[ -d ${srcdir}/build-${CHOST} ]] && rm -rf ${srcdir}/build-${CHOST}
  mkdir ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST}
  
  ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --with-readline

  make
}

check () {
  cd build-${CHOST}
  echo "quit" | ./bc/bc -l "${srcdir}"/${pkgname}-${pkgver}/Test/checklib.b # 10 failures
}

package () {
  cd build-${CHOST}
  make prefix="${pkgdir}/usr" install
}
