#! /bin/sh
#
# $Id: bootstrap,v 1.2.2.1 2006/09/11 20:58:58 arcanum Exp $
#
# bootstrap script to build all the *.in files and configure script.
#

# autoconf-2.59 is required

: ${AUTOHEADER="autoheader${AC_VER}"}
: ${AUTOCONF="autoconf${AC_VER}"}

# automake-1.8.x or 1.9.x is required

: ${ACLOCAL="aclocal${AM_VER}"}
: ${AUTOMAKE="automake${AM_VER}"}

# Verify autoconf version

AUTOCONF_VER=`(${AUTOCONF} --version 2>/dev/null | head -n 1 | \
              cut -d ' ' -f 4) 2>/dev/null`
if [ "$AUTOCONF_VER" != "2.59" ]
then
	echo "You need to use autoconf version 2.59."
	echo "You are using `${AUTOCONF} --version | head -n 1`."
	exit 1
fi

# Verify automake version

AUTOMAKE_VER=`(${AUTOMAKE} --version | head -n 1 | \
              cut -d ' ' -f 4 | cut -d '.' -f -2) 2>/dev/null`
if [ "$AUTOMAKE_VER" != "1.8" -a "$AUTOMAKE_VER" != "1.9" ]
then
	echo "You need to use automake version 1.8 or 1.9."
	echo "You are using `${AUTOMAKE} --version | head -n 1`."
	exit 1
fi

AUTOMAKE="${AUTOMAKE} --foreign --add-missing --copy"

export AUTOMAKE AUTOCONF ACLOCAL AUTOHEADER

# to see what is executed
set -x

rm -rf avr/lib
./devtools/gen-avr-lib-tree.sh

rm -rf autom4te.cache

${ACLOCAL}
${AUTOHEADER}
${AUTOCONF}
${AUTOMAKE} 
