+
+[ "${AMVER#1.}" -ge "10" ] && AMOPT="-W no-portability"
+
+check_version automake automake-$AMVER "1.9"
+check_version autoconf autoconf "2.57"
+
+run_cmd()
+{
+ cmd="$@"
+ echo -n "Running $cmd"
+ eval $cmd
+ res=$?
+ if [ $res -ne 0 ]; then
+ echo " failed: $res"
+ echo "Aborting"
+ exit 1
+ fi
+ echo
+}
+
+export ACLOCAL="aclocal-$AMVER"
+export AUTOMAKE="automake-$AMVER"
+
+run_cmd "$ACLOCAL $ACLOCAL_FLAGS"
+run_cmd "autoheader"
+run_cmd "$AUTOMAKE -a -c $AMOPT"
+run_cmd autoconf
+
+# Run autogen.sh in these directories
+for dir in $CONFIGURE_DIRS; do
+ if [ -d $dir ] ; then
+ pushd $dir >/dev/null
+ echo "Running autogen for $dir..."
+ run_cmd "sh autogen.sh"
+ popd >/dev/null
+ fi
+done