# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Rémy Oudompheng <oudomphe@clipper.ens.fr>

pkgname=singular
_majver=4-2-1
_patchver=3
#pkgver=${_majver//-/.}.p${_patchver}
pkgver=${_majver//-/.}
pkgrel=3
pkgdesc='Computer Algebra System for polynomial computations'
arch=(x86_64)
url='https://www.singular.uni-kl.de/'
license=(GPL)
depends=(flint cddlib)
makedepends=(doxygen)
#source=(ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/$_majver/singular-${_majver//-/.}p${_patchver}.tar.gz)
source=(ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/$_majver/singular-${_majver//-/.}.tar.gz)
sha256sums=('28a56df84f85b116e0068ffecf92fbe08fc27bd4c5ba902997f1a367db0bfe8d')
options=(!zipman)

build() {
  cd singular-${_majver//-/.}
  ./configure \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --docdir=/usr/share/doc \
    --enable-bigintm-module \
    --enable-bigintm-module \
    --enable-Order-module \
    --enable-python-module \
    --enable-gfanlib-module \
    --enable-polymake-module
# https://bugzilla.gnome.org/show_bug.cgi?id=655517
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd singular-${_majver//-/.}
  make check
}
  
package() {
  cd singular-${_majver//-/.}
  make DESTDIR="$pkgdir" install

  install -Dm644 doc/singular.idx -t "$pkgdir"/usr/share/singular
}
