# $Id: PKGBUILD 144936 2015-10-24 18:31:32Z arojas $
# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=lcalc
pkgver=1.23
pkgrel=8
pkgdesc="C++ L-function class library and command line interface"
arch=('i686' 'x86_64')
url="http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/L.html"
license=('GPL2')
depends=('pari-sage')
makedepends=('chrpath')
source=("http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/CODE/L-$pkgver.tar.gz"
 'Lcommon.h.patch' 'gcc-4.9.patch' 'pari-2.7.patch' 'gcc-5.patch')
md5sums=('8262d4495e0bbe0283e5341ef8694c23'
         '8af1dd6d3118bb785f193283a31305a2'
         '436dd35b06766dffad0941bcfb511e89'
         '187024b6d6f259209645af68ca8787f2'
         '88d8a28a75e0bc143d0898f2797d1c54')

prepare() {
  cd L-$pkgver
  patch -p1 -i "$srcdir"/Lcommon.h.patch  
  patch -p1 -i "$srcdir"/gcc-4.9.patch
  patch -p1 -i "$srcdir"/gcc-5.patch
# port to PARI 2.7 API
  patch -p1 -i "$srcdir"/pari-2.7.patch
}

build() {
  cd L-$pkgver/src
  make PARI_DEFINE="-DINCLUDE_PARI" LOCATION_PARI_H="/usr/include/pari"	LOCATION_PARI_LIBRARY="/usr/lib" all
}

package() {
  cd L-$pkgver/src
  mkdir -p "$pkgdir"/usr/{bin,include,lib}
  make INSTALL_DIR="$pkgdir"/usr install

# remove leftover files
  rm "$pkgdir"/usr/include/Lfunction/{Lexplicit_formula.h.swap.crap,.*.swp,.DS*}
# fix wrong permissions
  chmod 644 "$pkgdir"/usr/include/Lfunction/Ldokchitser.h
# fix insecure rpath
  chrpath -d "$pkgdir"/usr/bin/lcalc
}

