# $Id: PKGBUILD 147948 2012-01-28 21:21:33Z ronald $
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: damir <damir@archlinux.org>
# Contributor: Jason Taylor <jftaylor21@gmail.com>

pkgname=lapack
pkgver=3.4.0
pkgrel=1
url="http://www.netlib.org/lapack"
pkgdesc="Linear Algebra PACKage"
makedepends=('gcc-fortran')
depends=("blas=${pkgver}")
arch=('i686' 'x86_64')
license=("custom")
source=(http://www.netlib.org/${pkgname}/${pkgname}-${pkgver}.tgz
        Makefile.lapack) 
sha1sums=('910109a931524f8dcc2734ce23fe927b00ca199f'
          '2bedfe0d778b401b24d1fbf0eb1dc576d374be28')


build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cp -f INSTALL/make.inc.gfortran make.inc
  cp -f "${srcdir}/Makefile.lapack" SRC/Makefile

  export FC=gfortran

  pushd INSTALL
  make clean
  make NOOPT="${CFLAGS/-O?/-O0} -fPIC" OPTS="${CFLAGS} -fPIC"
  popd
  # make sure no files with '_', *vxx.o *vfx.o and *2.O as defined in *ASRC
  #  are in OBJS
  pushd SRC
  make clean
  
  make FFLAGS="${CFLAGS} -fPIC" CFLAGS="${CFLAGS} -fPIC" shared
  cp liblapack.so.${pkgver} "${srcdir}/${pkgname}-${pkgver}/"
  popd
}

package() {
  install -m755 -d "${pkgdir}/usr/lib"
  install -m755 "${srcdir}/${pkgname}-${pkgver}/liblapack.so.${pkgver}" \
    "${pkgdir}/usr/lib/"
  ln -sf liblapack.so.${pkgver} "${pkgdir}/usr/lib/liblapack.so"
  ln -sf liblapack.so.${pkgver} "${pkgdir}/usr/lib/liblapack.so.3"

  install -m755 -d "${pkgdir}/usr/share/licenses/lapack"
  install -m644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" \
    "${pkgdir}/usr/share/licenses/lapack/"
}