-echo "Running aclocal-1.7 $ACLOCAL_FLAGS..."
-aclocal-1.7 $ACLOCAL_FLAGS
-echo "Running autoheader..."
-autoheader
-echo "Running automake-1.7..."
-automake-1.7 -a -c
-echo "Running autoconf..."
-autoconf
-
-if [ -d libsysio ] ; then
- pushd libsysio >/dev/null
- echo "Running autogen for libsysio..."
- sh autogen.sh
- popd >/dev/null
-fi
+run_cmd()
+{
+ cmd="$@"
+ echo -n "Running $cmd"
+ eval $cmd
+ res=$?
+ if [ $res -ne 0 ]; then
+ echo " failed: $res"
+ echo "Aborting"
+ exit 1
+ fi
+ echo
+}
+
+run_cmd "aclocal-$AMVER $ACLOCAL_FLAGS"
+run_cmd "autoheader"
+run_cmd "automake-$AMVER -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