#!/bin/bash
# Install script for reaim
# Author: Enrique Gaona Jr.
#		   IBM LTC Infrastructure
# Date:		   08/19/2003
#
. /etc/autobench.conf || $AUTODIR/scripts/functions

#
#
# You may want to specify a web location as well as sourcing the server repo:
WEB_LOCATION="http://unc.dl.sourceforge.net/sourceforge/re-aim-7/osdl-aim-7-0.1.9.tar.gz"
# If the weblocation fails, you can try this internal address
#WEB_LOCATION="http://matrix.ltc.austin.ibm.com/whee-data/packages/reaim-0.1.8.tar.gz"

. $AUTODIR/var/server-repository

#
# Get it from the server repo first, if it's there
wget -q -O $AUTODIR/sources/reaim-latest.tar.gz $SERVER_REPO/sources/reaim-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/reaim-latest.tar.gz $WEB_LOCATION
  if [ $? -ne 0 ]; then
    # Couldn't get the source -- complain
    echo "WARNING: could not download the source for reaim."
    exit 1
  fi
fi


pushd $AUTODIR/sources > /dev/null
rm -rf reaim 2> /dev/null
DST_DIR=`tar ztf reaim-latest.tar.gz | head -n 1`
tar zxf reaim-latest.tar.gz
ln -sf $DST_DIR reaim 

# build it...
pushd reaim > /dev/null
./bootstrap
if [ $? -ne 0 ]; then
  echo "WARNING: unable to bootstrap reaim"
fi
./configure
if [ $? -ne 0 ]; then
  echo "WARNING: unable to configure reaim"
fi
make
if [ $? -ne 0 ]; then
  echo "WARNING: unable to make reaim"
fi

popd > /dev/null
popd > /dev/null
