#!/bin/sh

echo "Running aclocal..."
aclocal

echo "Running libtoolize..."
libtoolize -f -c

echo "Running automake..."
if [ "$PLAT" != "i686-pc-linux-gnu" ]; then
	automake --foreign -i
else
	automake --foreign
fi

echo "Running aclocal again..."
aclocal

echo "Running autoconf..."
autoconf

echo "Removing cache..."
rm -f config.cache

# Somehow it only works properly running automoc after configure.
# Makefile will be regenerated automatically upon running make.
echo "Running automoc..."
if [ "$SITE" = "discreet" ]; then
	 (cd src ; /usr/bin/perl ../automoc ; cd .. )
else
	 (cd src ; perl ../automoc ; cd .. )
fi

echo "Running configure..."
if [ "$PLAT" = "mips-sgi-irix6.5" ]; then
	LD=CC CXX=CC ./configure $* 

elif [ "$PLAT" = "i686-pc-linux-gnu" ]; then
	LD=gcc ./configure $*

else
	./configure $*
fi



