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

pkgbase=gmp
pkgname=('gmp' 'gmp-devel')
pkgver=6.2.1
pkgrel=1
pkgdesc="A free library for arbitrary precision arithmetic"
groups=('libraries')
arch=('i686' 'x86_64')
url="https://gmplib.org/"
license=('LGPL3')
install=gmp.install
source=(https://gmplib.org/download/gmp-${pkgver}/gmp-${pkgver}.tar.xz{,.sig})
sha256sums=('fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2'
            'SKIP')
validpgpkeys=('5972C48224C1E7E62AA0275D1150EE33C1A000B0'   # Marco Bodrato
              '343C2FF0FBEE5EC2EDBEF399F3599FF828C67298')   # Niels Möller

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

  autoreconf -fi
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
# get rid of those pesky declspec warnings
  CFLAGS+=" -Wno-attributes" \
  CXXFLAGS+=" -Wno-attributes" \
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --enable-cxx \
    --enable-fat \
    --enable-shared --disable-static
  make
  make DESTDIR="${srcdir}/dest" install
}

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

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

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

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