#!/bin/sh

# Shell script to populate the extern subdirectory with unpatched source
# packages so that "make dist" works.  This is a maintainer-only type
# of script.  

FetchFile()
{
    echo "Looking for $2..."
    if [ ! -f Packages/$2 ] 
	then
	echo "Fetching $2 from $1..."
	curl $1/$2 -o Packages/$2 --disable-epsv
    fi
    if [ ! -f Packages/$2 ] 
	then
	echo "ERROR: Unable to retrieve $2 from $1... please download manually into the Packages directory and rerun the build script"
	exit 1
    fi
}


SetupDirs()
{
    rm -rf Build Root Root/include Root/lib State
    mkdir -p Packages
}

# Setup the build directories
SetupDirs
FetchFile ftp://ftp.santafe.edu/pub/gnu ffcall-1.10.tar.gz
FetchFile http://www.fftw.org fftw-3.1.1.tar.gz
FetchFile http://www.cise.ufl.edu/research/sparse/umfpack/current UMFPACK.tar.gz
FetchFile http://www.cise.ufl.edu/research/sparse/UFconfig/current UFconfig.tar.gz
FetchFile http://www.cise.ufl.edu/research/sparse/amd/current AMD.tar.gz
FetchFile http://www.netlib.org/lapack lapack.tgz
FetchFile http://www.caam.rice.edu/software/ARPACK/SRC arpack96.tar.gz
FetchFile http://www.mathworks.com/matlabcentral/files/8187 matio.zip


