# Require $prefix, $workdir, $openblas_src
install_openblas()
(
  [[ -e $prefix/lib/libopenblas.so ]] && exit 0

  [[ "$workdir" = */hscpipe_build_dir ]] || exit 1
  rm -rf "$workdir"; mkdir -p "$workdir"; pushd "$workdir"

  curl -L "$openblas_src" | tar -xzf -

  cd *

  config=(
    NO_STATIC=1
    DYNAMIC_ARCH=1
    NO_AFFINITY=1
    NUM_THREADS=32
    BINARY=64
    CC=gcc
    FC=gfortran
  )

  make PREFIX="$prefix" ${config[@]}
  make PREFIX="$prefix" ${config[@]} install
)
