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

. /etc/autobench.conf || . functions
. $AUTODIR/var/server-repository

wget -O $AUTODIR/sources/readcg-latest.tar.gz $SERVER_REPO/sources/readcg-latest.tar.gz
if [ $? -ne 0 ]; then
	echo "WARNING: could not retrieve readcg source from the server repo"
	exit 1
fi

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

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

pushd readcg > /dev/null

# Enable 64bit support for ppc64
ARCH=`uname -m`
if [ $ARCH = "ppc64" ]; then
	cat Makefile | sed 's/^# CFLAGS/CFLAGS/' > Makefile.new
	mv -f Makefile.new Makefile
fi

make clean
make

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