#!/bin/bash
# This is the script to install the ffsb program
#

. /etc/autobench.conf || . functions

WEB_LOCATION="ftp://ausgsa.austin.ibm.com/projects/l/ltcperformance/2003benchmarks/ffsb/resources/ffsb-latest.tar.gz"
. $AUTODIR/var/server-repository

wget -q -O $AUTODIR/sources/ffsb-latest.tar.gz $SERVER_REPO/sources/ffsb-latest.tar.gz
if [ $? -ne 0 ]; then
  # Didn't find it on the repo, try the web location
  echo "Fetching from the network"
  wget -q -O $AUTODIR/sources/ffsb-latest.tar.gz $WEB_LOCATION
  if [ $? -ne 0 ]; then
    # Couldn't get the source -- complain
    echo "WARNING: could not download the source for ffsb"
    exit 1
  fi
fi

# Uncompress it
pushd $AUTODIR/sources > /dev/null
rm -rf ffsb 2> /dev/null

DST_DIR=`tar ztf ffsb-latest.tar.gz | head -n 1`
tar zxf ffsb-latest.tar.gz
ln -sf $DST_DIR ffsb

# build it...
popd > /dev/null
pushd $AUTODIR/sources/ffsb > /dev/null
export CFLAGS=-D_GNU_SOURCE $CFLAGS
aclocal
autoconf
automake
#diable dependenciy tracking to work around autoconf bug.
./configure --disable-dependency-tracking
make
if [ $? -ne 0 ]; then
  echo "ERROR: unable to make ffsb"
  popd > /dev/null
  exit 1
fi
popd > /dev/null

