# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

pkgbase=mpdecimal
pkgname=('mpdecimal' 'mpdecimal-devel')
pkgver=4.0.1
pkgrel=1
pkgdesc="Package for correctly-rounded arbitrary precision decimal floating point arithmetic"
arch=('i686' 'x86_64')
url="https://www.bytereef.org/mpdecimal/index.html"
license=('spdx:BSD-2-Clause')
depends=('gcc-libs')
makedepends=('autotools' 'gcc')
checkdepends=('wget')
source=("http://www.bytereef.org/software/${pkgname}/releases/${pkgname}-${pkgver}.tar.gz")
sha256sums=('96d33abb4bb0070c7be0fed4246cd38416188325f820468214471938545b1ac8')

prepare() {
  cd ${pkgname}-${pkgver}

  autoreconf -fiv
}

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr
  make
  make DESTDIR=${srcdir}/dest install
}

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

package_mpdecimal() {
  depends=('gcc-libs')
  cd ${srcdir}/dest

  mkdir -p ${pkgdir}/usr/bin
  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  install -Dm644 ${srcdir}/${pkgname}-${pkgver}/COPYRIGHT.txt "${pkgdir}"/usr/share/licenses/${pkgname}/COPYRIGHT.txt
}

package_mpdecimal-devel() {
  depends=("mpdecimal=${pkgver}")
  pkgdesc="mpdecimal headers and libraries"

  cd ${srcdir}/dest
  cp -rf usr ${pkgdir}/usr
  rm -r ${pkgdir}/usr/bin
}
