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

_realname=mpdecimal
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.0.1
pkgrel=1
pkgdesc="Package for correctly-rounded arbitrary precision decimal floating point arithmetic (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.bytereef.org/mpdecimal/index.html'
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
checkdepends=("wget")
source=("http://www.bytereef.org/software/${_realname}/releases/${_realname}-$pkgver.tar.gz")
sha256sums=('96d33abb4bb0070c7be0fed4246cd38416188325f820468214471938545b1ac8')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX}

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}

  make install DESTDIR="${pkgdir}"

  install -vDm 644 "${srcdir}"/${_realname}-${pkgver}/COPYRIGHT.txt \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/$_realname/LICENSE
}
