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

pkgbase=mpdecimal
pkgname=('mpdecimal' 'mpdecimal-devel')
pkgver=2.5.0
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=('custom')
depends=('gcc-libs')
checkdepends=('wget')
source=("http://www.bytereef.org/software/${pkgname}/releases/${pkgname}-${pkgver}.tar.gz"
        "mpdecimal-2.5.0-msys-mingw.patch")
sha512sums=('6f889f5f8c3e5854204ad7380b63c1bfeb5193c1d464f9a32149d47d1c9bd996c6a57b867ab65ea84f33e87fe69cb45ad78aa2abfb9bb5144eb527587016c472'
            '2fa72d50b6ab3d792c6512c682f48adff14387c259817b5749f54918c06a684015b2dec569148c1fc05147b675a25094531713f9f04ef968c43d8987ba064fcc')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -Nbp1 -i ${srcdir}/mpdecimal-2.5.0-msys-mingw.patch
  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}/LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE.txt
}

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

  cd ${srcdir}/dest
#  mkdir -p ${pkgdir}/usr/include
#  mkdir -p ${pkgdir}/usr/lib
#  mkdir -p ${pkgdir}/bin/share
  cp -rf usr ${pkgdir}/usr
  rm -r ${pkgdir}/usr/bin
}
