Extract gitiginore files from Subversion.
[cfd] / mkaclocal.in
index 24c4983..a511923 100755 (executable)
@@ -26,9 +26,7 @@
 # along with `common'; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-#----- Revision history -----------------------------------------------------
-#
-# $Log$
+set -e
 
 # --- Configuration variables ---
 
@@ -42,6 +40,7 @@ datadir=@datadir@/@PACKAGE@
 mode=x
 out="aclocal.m4"
 in="configure.in"
+stdlib=true
 
 while [ $# -gt 0 ]; do
   case $1 in
@@ -69,6 +68,7 @@ Options:
 -v, --version          Print the program's version number.
 -l, --list             List chunks defined in text libraries.
 -x, --extract          Extract chunks from text libraries (default).
+-n, --no-stdlib                Don't read from the standard libraries.
 -c, --config=CONFIG    Read CONFIG, not \`configure.in', to decide which
                        macros need extracting.
 -o, --output=OUTPUT    Extract chunks to OUTPUT, not \`aclocal.m4'.
@@ -101,6 +101,10 @@ EOF
     --o=* | --ou=* | --out=* | --outp=* | --outpu=* | --output=*)
       out=`echo $1 | sed -e 's/^--[a-z]*=//'`
       ;;
+    -n | --no-s* | --no-st* | --no-std* | --no-stdl* | \
+    --no-stdli* | --no-stdlib)
+      stdlib=false
+      ;;
     -l | --l | --li | --lis | --list)
       mode=l
       ;;
@@ -125,11 +129,16 @@ EOF
   shift
 done
 
-set \
-  "$datadir/aclocal.glob" \
-  `test -r $datadir/aclocal.site && echo "$datadir/aclocal.site"` \
-  `test -r ./aclocal.lib && echo "./aclocal.lib"` \
-  "$@"
+if $stdlib; then
+  set -- \
+    `test -r $datadir/aclocal.site && echo "$datadir/aclocal.site"` \
+    `test -r ./aclocal.lib && echo "./aclocal.lib"` \
+    "$@"
+else
+  set -- \
+    `test -r ./aclocal.lib && echo "./aclocal.lib"` \
+    "$@"
+fi
 
 # --- Now do the job ---
 
@@ -140,10 +149,15 @@ case $mode in
     ;;
 
   x)
-    t=/tmp/mkaclocal.$$
-    if mkdir -m 700 $t; then :
+    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 creat etemporary directory"
+      echo >&2 "mkaclocal: cculd not creattemporary directory"
       exit 1
     fi
     echo -NOTICE- >$t/a
@@ -168,11 +182,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