# $Id: PKGBUILD 144938 2015-10-24 18:31:34Z arojas $
# Maintainer: Antonio Rojas < nqn76sw@gmail.com >

pkgname=linbox
pkgver=1.3.2
pkgrel=7
pkgdesc="A template library for exact, high-performance linear algebra computation with dense, sparse, and structured matrices over the integers and over finite fields"
arch=(i686 x86_64)
url="http://linalg.org/"
license=(LGPL)
depends=(m4rie lapack ntl libfplll iml givaro) 
makedepends=(fflas-ffpack)
source=("http://linalg.org/$pkgname-$pkgver.tar.gz" 'linbox-fplll.patch' 'underlink.patch' 'lapack.patch')
md5sums=('67c80345c8c3e93d213f2d7d37d8c9af'
         '76fbb525cceff1dd74a7c1892ca965d0'
         '731a6b17c40a56e38fef79e03391e0b5'
         '3525650c88f9a2809214216b914f4f46')

prepare() {
  cd $pkgname-$pkgver
# fix build with newer givaro
  sed -i 's|version_max=30800|version_max=30900|' configure
# fix libfplll support - Fedora patch
  patch -p0 -i ../linbox-fplll.patch
# fix underlink - Fedora patch
  patch -p0 -i ../underlink.patch
# fix detecting lapack support in fflas-ffpack
  patch -p0 -i ../lapack.patch
}

build() {
  cd $pkgname-$pkgver

  export CFLAGS="$CFLAGS -g -fPIC"
  export CXXFLAGS="$CXXFLAGS -g -fPIC"
  export LDFLAGS="$LDFLAGS -L/usr/lib"

  ./configure --prefix=/usr --enable-sage --enable-optimization --with-fplll=/usr
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}

