# $Id$
# Maintainer: Allan McRae <allan@archlinux.org>

pkgname=('cloog' 'cloog-devel')
pkgver=0.20.0
pkgrel=1
groups=('libraries')
pkgdesc="Library that generates loops for scanning polyhedra"
arch=('i686' 'x86_64')
url="https://www.bastoul.net/cloog/"
license=('GPL')
depends=('isl')
makedepends=('isl-devel')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/periscop/cloog/releases/download/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz
        cloog-0.18.4-msys2.patch
        cloog-0.18.4-no-undefined.patch
        cloog-019.1-dont-build-doc.patch)
sha256sums=('835c49951ff57be71dcceb6234d19d2cc22a3a5df84aea0a9d9760d92166fc72'
            'fc4c552e4ce633f4f99bb7f4b59078ee1edd89728f66d044b314a2ffff88c552'
            '8233e5cf165bbe3aab553b560b48128d059e879398274b9c847888119c469a31'
            'f960d873bace207a3b7e575560c503ed87833c5d045be45a134ba2e7f6fc1ac3')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/cloog-0.18.4-msys2.patch
  patch -p1 -i ${srcdir}/cloog-0.18.4-no-undefined.patch
  patch -p1 -i ${srcdir}/cloog-019.1-dont-build-doc.patch
  WANT_AUTOMAKE=latest autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
      --prefix=/usr \
      --enable-shared \
      --disable-static \
      --with-isl=system \
      --with-bits=gmp \
      --program-suffix=-isl
  make
  make DESTDIR=${srcdir}/dest install
}

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

package_cloog() {
  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin
}

package_cloog-devel() {
  pkgdesc="CLOOG headers and libraries"
  groups=('development')
  depends=("cloog=${pkgver}" 'isl-devel')

  mkdir -p ${pkgdir}/usr

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