Support Automake's `aclocal' scheme. Deposit Autoconf fragments in
[cfd] / mkaclocal.in
index 8a56ac4..c425633 100755 (executable)
@@ -30,6 +30,8 @@
 #
 # $Log$
 
+set -e
+
 # --- Configuration variables ---
 
 prefix=@prefix@
@@ -132,13 +134,12 @@ EOF
 done
 
 if $stdlib; then
-  set \
-    "$datadir/aclocal.glob" \
+  set -- \
     `test -r $datadir/aclocal.site && echo "$datadir/aclocal.site"` \
     `test -r ./aclocal.lib && echo "./aclocal.lib"` \
     "$@"
 else
-  set \
+  set -- \
     `test -r ./aclocal.lib && echo "./aclocal.lib"` \
     "$@"
 fi
@@ -153,6 +154,11 @@ case $mode in
 
   x)
     t=${TMPDIR-/tmp}/mkaclocal.$$
+    doaclocal=false
+    if $stdlib && [ $out = aclocal.m4 ]; then
+      doaclocal=true
+      out=acinclude.m4
+    fi
     if mkdir -m700 $t; then :
     else
       echo >&2 "mkaclocal: cculd not create temporary directory"
@@ -180,11 +186,13 @@ $LINE"
          grep "\*@--TOP--@\*" ./aclocal.lib >/dev/null &&
          sed -e "/\*@--TOP--@\*/, $ d" ./aclocal.lib
        cat $out.tmp
-      } >$out
+      } >$out.new
+      mv $out.new $out
     else
       rm -f $out
     fi
 
     rm -fr $t $out.tmp
+    if $doaclocal; then aclocal; fi
     ;;
 esac