#!/bin/bash

package=lapack
version=-3.4.2

progname=$0

source ../cascade-make/lib/cascade-lib.bash GEXT_HUGIN ../.. $*

prefix=$GEXTHUGIN_INSTALLED

opt_run_untar $force_untar $auto_untar $package $version

if [ $force_config = "1" ] ; then
  echo "[pushd $package$version]"
  ( cd $package$version ; \
    if [ ! -d release ] ; then \
      echo "Creating 'release' directory" ; \
      mkdir release ; \
    fi ; \
    #LAPACK has an unusual CMAKE. Which breakes the OPT_MAKE if it doesn't run it in the root dir.
    cmake -D CMAKE_INSTALL_PREFIX=$prefix \
    	  -D CMAKE_Fortran_FLAGS=-fPIC \
          .;
   )
  if [ $? != 0 ] ; then
      echo "      Error encountered running *configure* stage of $progname"
      exit 1
  fi
  echo "[popd]"
else
  if [ $auto_config = "1" ] ; then
    echo "Found top-level for ${progname%.*} => no need to run configure/initialize CMake"
  fi
fi
opt_run_make $compile $package $version
opt_run_make $install $package $version "install"
opt_run_make $clean $package $version "clean"
opt_run_make $distclean $package $version "distclean"

opt_run_tarclean $tarclean $package $version

