-autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
-autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
-automake_ver=$(automake --version 2>/dev/null | head -n1)
-aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
-libtool_ver=$(libtool --version 2>/dev/null | head -n1)
-
+test -z "$AUTOCONF" && type autoconf >/dev/null 2>&1 && AUTOCONF=autoconf
+export AUTOCONF
+test -z "$AUTORECONF" && type autoreconf >/dev/null 2>&1 && AUTORECONF=autoreconf
+export AUTORECONF
+test -z "$AUTOHEADER" && type autoheader >/dev/null 2>&1 && AUTOHEADER=autoheader
+export AUTOHEADER
+test -z "$AUTOMAKE" && type automake >/dev/null 2>&1 && AUTOMAKE=automake
+export AUTOMAKE
+test -z "$ACLOCAL" && type aclocal >/dev/null 2>&1 && ACLOCAL=aclocal
+export ACLOCAL
+test -z "$LIBTOOL" && type libtool >/dev/null 2>&1 && LIBTOOL=libtool
+export LIBTOOL
+
+autoconf_ver=$($AUTOCONF --version 2>/dev/null | head -n1)
+if test -z "$autoconf_ver"; then
+ echo Could not determine autoconf
+ exit 1
+fi
+autoreconf_ver=$($AUTORECONF --version 2>/dev/null | head -n1)
+if test -z "$autoreconf_ver"; then
+ echo Could not determine autoreconf
+ exit 1
+fi
+autoheader_ver=$($AUTOHEADER --version 2>/dev/null | head -n1)
+if test -z "$autoheader_ver"; then
+ echo Could not determine autoheader
+ exit 1
+fi
+automake_ver=$($AUTOMAKE --version 2>/dev/null | head -n1)
+if test -z "$automake_ver"; then
+ echo Could not determine automake
+ exit 1
+fi
+aclocal_ver=$($ACLOCAL --version 2>/dev/null | head -n1)
+if test -z "$aclocal_ver"; then
+ echo Could not determine aclocal
+ exit 1
+fi
+libtool_ver=$($LIBTOOL --version 2>/dev/null | head -n1)
+if test -z "$libtool_ver"; then
+ echo Could not determine libtool
+ exit 1
+fi