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

pkgname=('mpc' 'mpc-devel')
pkgver=1.3.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' 'autotools' 'gcc')
options=('!emptydirs')
source=(https://ftp.gnu.org/gnu/mpc/mpc-${pkgver}.tar.gz{,.sig})
sha256sums=('ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8'
            'SKIP')
validpgpkeys=('AD17A21EF8AED8F1CC02DBD9F7D5C9BF765C61E3')  # Andreas Enge
msys2_references=(
  'archlinux: libmpc'
)

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

  autoreconf -fiv
}

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_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/
}
