+2000-07-03 Lars J. Aas <larsa@sim.no>
+
+ * acgeneral.m4 (AC_SHELL_MKDIR_P): New macro.
+ (_AC_OUTPUT_FILES, _AC_OUTPUT_HEADERS, _AC_OUTPUT_LINKS,
+ AC_PROG_INSTALL): Use AC_SHELL_MKDIR_P.
+ * tests/base.m4 (AC_SHELL_MKDIR_P): Test it.
+
2000-07-04 Akim Demaille <akim@epita.fr>
* acgeneral.m4 (AC_CACHE_LOAD): Be ready to read the cache even
[$ac_unset $1 || test "${$1+set}" != set || $1=$2 && export $1])
+# AC_SHELL_MKDIR_P(PATH)
+# ------------------------
+# Emulate `mkdir -p' with plain `mkdir'.
+define([AC_SHELL_MKDIR_P],
+[{ case $1 in
+ [[\\/]]* | ?:[[\\/]]* ) ac_incr_dir=;;
+ *) ac_incr_dir=.;;
+esac
+ac_dummy="$1"
+for ac_dir in `IFS=/; set X $ac_dummy; shift; echo "$[@]"`; do
+ ac_incr_dir=$ac_incr_dir/$ac_dir
+ test -d $ac_incr_dir || mkdir $ac_incr_dir
+done; }
+])# AC_SHELL_MKDIR_P
+
+
## --------------------------------------------------- ##
## Common m4/sh handling of variables (indirections). ##
## --------------------------------------------------- ##
# 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"
+ AC_SHELL_MKDIR_P("$ac_dir")
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'`
# 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"
+ AC_SHELL_MKDIR_P("$ac_dir")
fi
rm -f $ac_file
mv $tmp/config.h $ac_file
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dest_dir=`echo $ac_dest | sed 's%/[[^/][^/]]*$%%'`
if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
- # The dest file is in a subdirectory.
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
- test -d "$ac_dest_dir" || mkdir "$ac_dest_dir"
+ AC_SHELL_MKDIR_P("$ac_dest_dir")
ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dest_dir_suffix.
ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[[^/]]*%../%g'`
echo configuring in $ac_subdir
case $srcdir in
.) ;;
- *)
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
- if test -d ./$ac_subdir || mkdir ./$ac_subdir; then :;
- else
- AC_MSG_ERROR(cannot create `pwd`/$ac_subdir)
- fi
- ;;
+ *) AC_SHELL_MKDIR_P(./$ac_subdir)
+ if test -d ./$ac_subdir; then :;
+ else
+ AC_MSG_ERROR(cannot create `pwd`/$ac_subdir)
+ fi
+ ;;
esac
ac_popdir=`pwd`
[$ac_unset $1 || test "${$1+set}" != set || $1=$2 && export $1])
+# AC_SHELL_MKDIR_P(PATH)
+# ------------------------
+# Emulate `mkdir -p' with plain `mkdir'.
+define([AC_SHELL_MKDIR_P],
+[{ case $1 in
+ [[\\/]]* | ?:[[\\/]]* ) ac_incr_dir=;;
+ *) ac_incr_dir=.;;
+esac
+ac_dummy="$1"
+for ac_dir in `IFS=/; set X $ac_dummy; shift; echo "$[@]"`; do
+ ac_incr_dir=$ac_incr_dir/$ac_dir
+ test -d $ac_incr_dir || mkdir $ac_incr_dir
+done; }
+])# AC_SHELL_MKDIR_P
+
+
## --------------------------------------------------- ##
## Common m4/sh handling of variables (indirections). ##
## --------------------------------------------------- ##
# 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"
+ AC_SHELL_MKDIR_P("$ac_dir")
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'`
# 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"
+ AC_SHELL_MKDIR_P("$ac_dir")
fi
rm -f $ac_file
mv $tmp/config.h $ac_file
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dest_dir=`echo $ac_dest | sed 's%/[[^/][^/]]*$%%'`
if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
- # The dest file is in a subdirectory.
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
- test -d "$ac_dest_dir" || mkdir "$ac_dest_dir"
+ AC_SHELL_MKDIR_P("$ac_dest_dir")
ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dest_dir_suffix.
ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[[^/]]*%../%g'`
echo configuring in $ac_subdir
case $srcdir in
.) ;;
- *)
-dnl FIXME: should actually be mkinstalldirs (parents may have
-dnl to be created too).
- if test -d ./$ac_subdir || mkdir ./$ac_subdir; then :;
- else
- AC_MSG_ERROR(cannot create `pwd`/$ac_subdir)
- fi
- ;;
+ *) AC_SHELL_MKDIR_P(./$ac_subdir)
+ if test -d ./$ac_subdir; then :;
+ else
+ AC_MSG_ERROR(cannot create `pwd`/$ac_subdir)
+ fi
+ ;;
esac
ac_popdir=`pwd`
AT_CHECK([./configure], 0)
AT_CLEANUP(configure)
+
+
+# AC_SHELL_MKDIR_P
+# ----------------
+
+# Build nested dirs.
+
+AT_SETUP(AC_SHELL_MKDIR_P)
+
+AT_DATA(configure.in,
+[[AC_DIVERT_POP()
+pwd=`pwd`
+set -e
+# Absolute
+AC_SHELL_MKDIR_P($pwd/1/2/3/4/5/6)
+test -d $pwd/1/2/3/4/5/6 || exit 1
+# Relative
+AC_SHELL_MKDIR_P(a/b/c/d/e/f)
+test -d a/b/c/d/e/f || exit 1
+exit 0
+]])
+
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0, [], [])
+AT_CHECK([./configure], 0)
+
+AT_CLEANUP(configure 1)