#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=mpfr
_pkgver=4.2.1
_patchver=0
if (( _patchver == 0 )); then
  pkgver=$_pkgver
else
  pkgver=$_pkgver.p$_patchver
fi
pkgrel=01
pkgdesc='Multiple-precision floating-point library'
url='https://www.mpfr.org/'
depends=('glibc' 'gmp')
makedepends=('autoconf-archive' 'automake')
#options=(debug)  ### uncomment here for debug pkg
provides=(libmpfr.so)
# NOTE: download potentially existing patches from upstream:
# `curl patches.diff -o https://www.mpfr.org/mpfr-${_pkgver}/allpatches`
source=(https://ftp.gnu.org/gnu/$pkgname/$pkgname-$_pkgver.tar.xz{,.sig}
        patches.diff::https://www.mpfr.org/mpfr-${_pkgver}/allpatches)
##  options=(debug)  ## uncomment this to produce the debug pkg

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

  for src in "${source[@]}"; do
    [[ "$src" == *.diff ]] || [[ "$src" == *.patch ]] || continue
    printf "Applying patch %s...\n" "$src"
    patch -Np1 -i "../$src"
  done

  autoreconf -fiv
}

build() {
  cd $pkgname-${_pkgver}
  ./configure --prefix=/usr \
    --enable-thread-safe \
    --enable-shared
  make
}

check() {
  cd $pkgname-${_pkgver}
  make check
  make check-exported-symbols
}

package() {
  cd $pkgname-${_pkgver}
  make DESTDIR="$pkgdir" install
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('GPL3' 'LGPL3')

validpgpkeys=('07F3DBBECC1A39605078094D980C197698C3739D'
              'A534BE3F83E241D918280AEB5831D11A0D4DB02A') # Vincent Lefevre <vincent@vinc17.net>

sha256sums=(277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2  # mpfr-4.2.1.tar.xz
	9fc30cf79beae3e4b06520611ad47dbc69cc5953b06f79cb228334066ecf4e97  # mpfr-4.2.1.tar.xz.sig
	a9099cee74188d5f522b7b3fca0097196c6dd38126f8f042d233010cbf92e8d0) # patches.diff

sha512sums=('bc68c0d755d5446403644833ecbb07e37360beca45f474297b5d5c40926df1efc3e2067eecffdf253f946288bcca39ca89b0613f545d46a9e767d1d4cf358475'
            'SKIP'
            'SKIP')
b2sums=('ad69f53bc910294647523e7613b18a683f1d0f3dd994168ab2a46b66d0371ffa9b8e7cb59495f898470aea69d343e83fc722f11babe4af7b3a12665a1e65860c'
            'SKIP'
        'SKIP')


##  3ca1223043e41abea216cdcfe1bbc71020638bf1e13ce10aebab4ed82f760b62  mpfr-4.2.1-01-x86_64.pkg.tar.lz
