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

pkgbase=isl
pkgname=('isl' 'isl-devel')
pkgver=0.27
pkgrel=1
pkgdesc="Library for manipulating sets and relations of integer points bounded by linear constraints"
arch=('i686' 'x86_64')
url="https://libisl.sourceforge.io/"
groups=('libraries')
depends=('gmp')
makedepends=('gmp-devel' 'autotools' 'gcc')
license=('spdx:MIT')
source=(https://libisl.sourceforge.io/${pkgbase}-${pkgver}.tar.xz
        isl-0.14.1-no-undefined.patch)
sha256sums=('6d8babb59e7b672e8cb7870e874f3f7b813b6e00e6af3f8b04f7579965643d5c'
            '83655a7202f0a0dcce1782d4b365252bf1ad12a522b7ad82ab578ee5ec46433b')

prepare() {
  cd "${srcdir}/${pkgbase}-${pkgver}"
  patch -p1 -i ${srcdir}/isl-0.14.1-no-undefined.patch

  autoreconf -fi
}

build() {
  cd "$srcdir/${pkgbase}-${pkgver}"

  ./configure \
    --build="${CHOST}" \
    --prefix=/usr \
    --enable-shared \
    --disable-static
  make
  make -j1 DESTDIR="${srcdir}/dest" install
}

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

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

  install -Dm644 ${srcdir}/${pkgbase}-${pkgver}/LICENSE ${pkgdir}/usr/share/licenses/isl/LICENSE
}

package_isl-devel() {
  pkgdesc="ISL headers and libraries"
  groups=('development')
  depends=("isl=${pkgver}" 'gmp-devel')

  mkdir -p ${pkgdir}/usr

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

  install -dm755 "${pkgdir}"/usr/share/gdb/auto-load/usr/lib/
  mv "$pkgdir"/usr/lib/libisl.dll.*-gdb.py "${pkgdir}"/usr/share/gdb/auto-load/usr/lib/
}
