diff --git a/src/run_autoconfig b/src/run_autoconfig
index c31d89c19e7173398bd81f177e5bb7092f05d237..183a323d1f812e04cddca785286bce1c885a2679 100755
--- a/src/run_autoconfig
+++ b/src/run_autoconfig
@@ -6,6 +6,15 @@ need_to_make_depend=no
 
 
 find . -type d -print|egrep -v '/(CVS)|(RCS)$'| while read dir; do
+
+  if [ -f $dir/Makefile.am ]; then
+    # aclocal needs to be run before autoconf
+    echo "Running aclocal in $dir"
+    (cd $dir ; aclocal)
+    echo "Running automake in $dir"
+    (cd $dir ; automake)
+  fi
+
   if [ -f $dir/acconfig.h -a $dir/configure.in ]; then
     echo "Running autoheader in $dir"
     ( cd $dir ; autoheader && echo foo >stamp-h.in )