This patch is based on what I did for an autoconf freeze 2000-01-13, and
acgeneral.m4 had changed somewhat since then.  Hopefully I added the
code at the correct positions ;)  Patch only tested for the 2000-01-13
autoconf (but I'm fairly sure the changes are the same).

I don't know the policy on using IFS like I've done, and maybe you want to
reverse a couple of tests to avoid using "test ! ...".  (that's one of the
changes I noticed between 2000-01-13 and cvs HEAD.

Also, it's sad that this functionality obfuscates the script somewhat...

  Lars J


ChangeLog entry:

2000-06-27  Lars J. Aas  <[EMAIL PROTECTED]>

        * acgeneral.m4: create subdirs, including parent directories that
        don't exist already.

Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.497
diff -u -r1.497 acgeneral.m4
--- acgeneral.m4        2000/06/26 10:57:46     1.497
+++ acgeneral.m4        2000/06/27 18:18:39
@@ -4488,10 +4488,19 @@
   # Remove last slash and all that follows it.  Not all systems have dirname.
   ac_dir=`echo "$ac_file" | sed 's%/[[^/][^/]]*$%%'`
   if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-    # The file is in a subdirectory.
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
-    test -d "$ac_dir" || mkdir "$ac_dir"
+    # The file is in a subdirectory.  Create subdir, including parents.
+    if test ! -d "$ac_dir"; then
+      save_IFS=$IFS
+      IFS="/"
+      set $ac_dir
+      IFS=$save_IFS
+      ac_workdir="$1"
+      while test $# -gt 0; do
+        test ! -d "$ac_workdir" && mkdir "$ac_workdir"
+        shift
+        ac_workdir="$ac_workdir/$1"
+      done
+    fi
     ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
     # A "../" for each directory in $ac_dir_suffix.
     ac_dots=`echo "$ac_dir_suffix" | sed 's%/[[^/]]*%../%g'`
@@ -4758,10 +4767,19 @@
     # Remove last slash and all that follows it.  Not all systems have dirname.
     ac_dir=`echo "$ac_file" | sed 's%/[[^/][^/]]*$%%'`
     if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-      # The file is in a subdirectory.
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
-      test -d "$ac_dir" || mkdir "$ac_dir"
+      # The file is in a subdirectory.  Create subdir, including parents.
+      if test ! -d "$ac_dir"; then
+        save_IFS=$IFS
+        IFS="/"
+        set $ac_dir
+        IFS=$save_IFS
+        ac_workdir="$1"
+        while test $# -gt 0; do
+          test ! -d "$ac_workdir" && mkdir "$ac_workdir"
+          shift
+          ac_workdir="$ac_workdir/$1"
+        done
+      fi
     fi
     rm -f $ac_file
     mv $tmp/config.h $ac_file

Reply via email to