# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

pkgname=('mpfr' 'mpfr-devel')
_pkgver=4.2.2
pkgver=${_pkgver}
# pkgver=${_pkgver}.p1
pkgrel=1
pkgdesc="Multiple-precision floating-point library"
arch=('i686' 'x86_64')
url="https://www.mpfr.org/"
msys2_references=(
  "cpe: cpe:/a:mpfr:gnu_mpfr"
)
license=('spdx:LGPL-3.0-or-later')
depends=('gmp>=5.0')
makedepends=('gmp-devel>=5.0' 'autotools' 'gcc' 'autoconf-archive')
source=(https://www.mpfr.org/mpfr-current/mpfr-${_pkgver}.tar.xz{,.asc})
        # patches.patch)
# wget https://www.mpfr.org/mpfr-4.2.1/allpatches -O patches.patch
validpgpkeys=('A534BE3F83E241D918280AEB5831D11A0D4DB02A') # Vincent Lefevre <vincent@vinc17.net>
sha256sums=('b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01'
            'SKIP')

prepare() {
  cd "${srcdir}/${pkgname}-${_pkgver}"

  # patch -p1 -i ${srcdir}/patches.patch

  autoreconf -fi
}

build() {
  cd "${srcdir}/${pkgname}-${_pkgver}"

  ./configure --build=${CHOST} \
    --prefix=/usr \
    --enable-shared \
    --disable-static
  make
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "${srcdir}/${pkgname}-${_pkgver}"
  make check
}

package_mpfr() {
  groups=('libraries')

  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_mpfr-devel() {
  groups=('development')
  options=('staticlibs')
  depends=("mpfr=${pkgver}" 'gmp-devel')
  pkgdesc="MPFR headers and libraries"

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
