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

pkgname=('mpc' 'mpc-devel')
pkgver=1.2.1
pkgrel=1
pkgdesc='Multiple precision complex arithmetic library'
groups=('libraries')
url='http://www.multiprecision.org'
license=('LGPL')
arch=('i686' 'x86_64')
depends=('gmp>=5.0' 'mpfr')
makedepends=('gmp-devel' 'mpfr-devel')
install=mpc.install
options=('!emptydirs')
source=(https://ftp.gnu.org/gnu/mpc/mpc-${pkgver}.tar.gz{,.sig}
        mpc-1.2.1-msys2.patch)
sha256sums=('17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459'
            'SKIP'
            '8dbbff9597c38c98c658adec0f3d22f3f2bcc6eb4ac4504630e07fe9519abb4a')
validpgpkeys=('AD17A21EF8AED8F1CC02DBD9F7D5C9BF765C61E3')  # Andreas Enge


prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/mpc-1.2.1-msys2.patch

  autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr --enable-shared --disable-static
  make
  make DESTDIR="$srcdir/dest" install
}

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

package_mpc() {
  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/bin ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/share ${pkgdir}/usr/
}

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

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