#!/bin/sh

find_program()
{
    prog="$1"
    vers="$2"

    if test `"$prog-$vers" --version | head -1 | grep -c "$vers"` != 0 ; then
	program="$prog-$vers"
    else
	program="$prog"
    fi
}

# Find appropriate versions of the auto tools
find_program aclocal 1.5
aclocal="$program"
find_program autoheader 2.53
autoheader="$program"
find_program automake 1.5
automake="$program"
find_program autoconf 2.53
autoconf="$program"

set -x

# Remove autoconf 2.5x's cache directory
rm -rf autom4te*.cache

$aclocal -I .                            || exit 1
$autoheader                              || exit 1
# libtoolize --force --copy               || exit 1
$automake --foreign --add-missing --copy || exit 1
$autoconf                                || exit 1
