]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* NEWS: New macro AC_PROG__MKDIR_P. AS_MKDIR_P is now more robust.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 10 May 2006 23:05:15 +0000 (23:05 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 10 May 2006 23:05:15 +0000 (23:05 +0000)
* config/install-sh: Don't use 'path' to talk about file names,
as per GNU coding standards.  Close a race condition reported by Ralf
Wildenhues and Stepan Kasal.  There is still a race condition
on hosts that predate POSIX 1003.1-1992, but we can't help this.
Don't mishandle weird characters like space on pre-POSIX hosts.
Invoke mkdir at most once per dir arg on pre-POSIX hosts.
* doc/autoconf.texi (Programming in M4sh): Cross-reference to
AC_PROG_MKDIR_P from AS_MKDIR_P.
(Limitations of Usual Tools): Cross-reference to AC_PROG_MKDIR_P
from mkdir.  Mention that Autoconf 2.60 install-sh is safe but
earlier editions are not (including Automake 1.8.3).
Do not suggest mkinstalldirs for thread-safety.
* lib/m4sugar/m4sh.m4 (AS_MKDIR_P): Make it more robust in the
presence of special characters and race conditions.
* tests/local.at (AT_CHECK_ENV): Add mkdir_p to the list of variables
in Autoconf's name space.

* lib/autoconf/programs.m4 (AC_PROG_MKDIR_P): New macro, taken
from Automake with minor changes.
* doc/autoconf.texi (Particular Programs): Document AC_PROG_MKDIR_P.

ChangeLog
NEWS
config/install-sh
doc/autoconf.texi
lib/autoconf/programs.m4
lib/m4sugar/m4sh.m4
tests/local.at

index 0a32422616e71eddd1562e6c8c4529a80e2a8b16..40cec30a165ecb4992827ed08319e5ca9f4a7eec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,33 @@
 2006-05-10  Paul Eggert  <eggert@cs.ucla.edu>
 
-       * config/install-sh: Update to Automake CVS version, as follows:
+       * NEWS: New macro AC_PROG__MKDIR_P.  AS_MKDIR_P is now more robust.
+       * config/install-sh: Don't use 'path' to talk about file names,
+       as per GNU coding standards.  Close a race condition reported by Ralf
+        Wildenhues and Stepan Kasal.  There is still a race condition
+        on hosts that predate POSIX 1003.1-1992, but we can't help this.
+       Don't mishandle weird characters like space on pre-POSIX hosts.
+       Invoke mkdir at most once per dir arg on pre-POSIX hosts.
+       * doc/autoconf.texi (Programming in M4sh): Cross-reference to
+       AC_PROG_MKDIR_P from AS_MKDIR_P.
+       (Limitations of Usual Tools): Cross-reference to AC_PROG_MKDIR_P
+       from mkdir.  Mention that Autoconf 2.60 install-sh is safe but
+       earlier editions are not (including Automake 1.8.3).
+       Do not suggest mkinstalldirs for thread-safety.
+       * lib/m4sugar/m4sh.m4 (AS_MKDIR_P): Make it more robust in the
+       presence of special characters and race conditions.
+       * tests/local.at (AT_CHECK_ENV): Add mkdir_p to the list of variables
+       in Autoconf's name space.
+
+2006-05-10  Bruno Haible  <bruno@clisp.org>
+       and Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lib/autoconf/programs.m4 (AC_PROG_MKDIR_P): New macro, taken
+       from Automake with minor changes.
+       * doc/autoconf.texi (Particular Programs): Document AC_PROG_MKDIR_P.
 
+2006-05-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * config/install-sh: Update to Automake CVS version, as follows:
        2006-04-25  Stepan Kasal  <kasal@ucw.cz>
        * lib/install-sh: Simplify the expr implementation of dirname.
        2006-04-24  Paul Eggert  <eggert@cs.ucla.edu>
diff --git a/NEWS b/NEWS
index 37764c2eb67e53e0454f63dcb9f34a7bc74bd8f1..809fcc987045fe9e325acb9f139ef86e037e665b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,13 @@
   and ac_cv_prog_cc_c89 to 'no' as well, for backward compatibility with
   obsolete K&R tests in the Automake test suite.
 
+** AC_PROG_MKDIR_P
+  New macro.
+
+** AS_MKDIR_P
+  Now more robust with special characters in file names, or when
+  multiple processes create the same directory at the same time.
+
 * Major changes in Autoconf 2.59c
 
   Released 2006-04-12, by Ralf Wildenhues.
index 220d6647ef262e41f73c56da9257134345ea1758..db8cee16d9a60d9d550966e58406f47a6498de9c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2006-04-25.22
+scriptversion=2006-05-10.12
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -47,7 +47,8 @@ scriptversion=2006-04-25.22
 # Don't use :- since 4.3BSD and earlier shells don't like it.
 doit="${DOITPROG-}"
 
-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
 
 mvprog="${MVPROG-mv}"
 cpprog="${CPPROG-cp}"
@@ -311,9 +312,9 @@ do
       # step, checking for races as we go.
 
       case $dstdir in
-       /*) pathcomp=/ ;;
-       -*) pathcomp=./ ;;
-       *)  pathcomp= ;;
+       /*) prefix=/ ;;
+       -*) prefix=./ ;;
+       *)  prefix= ;;
       esac
 
       case $posix_glob in
@@ -333,19 +334,36 @@ do
       $posix_glob && set +f
       IFS=$oIFS
 
+      prefixes=
+
       for d
       do
-       test "x$d" = x && continue
+       test -z "$d" && continue
 
-       pathcomp=$pathcomp$d
-       if test ! -d "$pathcomp"; then
-         $mkdirprog "$pathcomp"
-         # Don't fail if two instances are running concurrently.
-         test -d "$pathcomp" || exit 1
+       prefix=$prefix$d
+       if test -d "$prefix"; then
+         prefixes=
+       else
+         if $posix_mkdir; then
+           $mkdirprog -m "$mkdir_mode" -p -- "$dstdir" && break
+           # Don't fail if two instances are running concurrently.
+           test -d "$prefix" || exit 1
+         else
+           case $prefix in
+             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+             *) qprefix=$prefix;;
+           esac
+           prefixes="$prefixes '$qprefix'"
+         fi
        fi
-       pathcomp=$pathcomp/
+       prefix=$prefix/
       done
-      obsolete_mkdir_used=true
+
+      if test -n "$prefixes"; then
+       # Don't fail if two instances are running concurrently.
+       eval "\$mkdirprog $prefixes" || test -d "$dstdir" || exit 1
+       obsolete_mkdir_used=true
+      fi
     fi
   fi
 
index 2bd46a35ffe1487749f0d16634db79c3ec644ccf..6b3588e8cbcb8e18504ae811d77fa1a95c1efa22 100644 (file)
@@ -3521,6 +3521,29 @@ not found in standard @code{install} programs, there is no reason to use
 @file{Makefile.in} files.
 @end defmac
 
+@defmac AC_PROG_MKDIR_P
+@acindex{AC_PROG_MKDIR_P}
+@ovindex mkdir_p
+Set output variable @code{mkdir_p} to a command that ensures that for
+each argument, a directory named by this argument exists, creating it
+and its parent directories if needed.  The command is checked to make
+sure that it is thread-safe (@pxref{Limitations of Usual Tools}).
+
+This macro uses the @samp{mkdir -p} command if possible.  Otherwise, it
+falls back to the @samp{install-sh -d} command, so your package should
+contain @file{install-sh} as described under @code{AC_PROG_INSTALL}.
+
+This macro is related to the @code{AS_MKDIR_P} macro (@pxref{Programming
+in M4sh}), but it sets an output variable intended for use in other
+files, whereas @code{AS_MKDIR_P} is intended for use in scripts like
+@command{configure}.  Also, @code{AS_MKDIR_P} does not accept options,
+but if you are willing to assume Posix 1003.2-1992 or later, a
+@code{mkdir_p} can use options, e.g., a makefile might invoke
+@code{$(mkdir_p) -m 0 dir}.
+@end defmac
+
+This macro differs from
+
 @defmac AC_PROG_LEX
 @acindex{PROG_LEX}
 @ovindex LEX
@@ -9726,6 +9749,9 @@ succeeds if @var{file-name} is a symbolic link to an existing directory,
 even though Posix is unclear whether @samp{mkdir -p} should
 succeed in that case.  If creation of @var{file-name} fails, exit the
 script.
+
+Also see the @code{AC_PROG_MKDIR_P} macro (@pxref{Limitations of Usual
+Tools}).
 @end defmac
 
 @defmac AS_SHELL_SANITIZE
@@ -13035,7 +13061,8 @@ found"} if there are no @samp{.c} files.
 @cindex Making directories
 None of @command{mkdir}'s options are portable to older systems.  Instead of
 @samp{mkdir -p @var{file-name}}, you should use use
-@code{AS_MKDIR_P(@var{file-name})} (@pxref{Programming in M4sh}).
+@code{AS_MKDIR_P(@var{file-name})} (@pxref{Programming in M4sh})
+or @code{AC_PROG_MKDIR_P} (@pxref{Particular Programs}).
 
 Posix does not clearly specify whether @samp{mkdir -p foo}
 should succeed when @file{foo} is a symbolic link to an already-existing
@@ -13053,9 +13080,9 @@ version 4.0c), Free@acronym{BSD} 5.0, and Net@acronym{BSD}-current are
 known to have a
 race-free @code{mkdir -p}.  This possible race is harmful in parallel
 builds when several @file{Makefile} rules call @code{mkdir -p} to
-construct directories.  You may use @command{mkinstalldirs} or
-@code{install-sh -d} as a safe replacement, provided these scripts are
-recent enough (the copies shipped with Automake 1.8.3 are OK, those from
+construct directories.  You may use
+@code{install-sh -d} as a safe replacement, provided this script is
+recent enough (the copy shipped with Autoconf 2.60 is OK, those from
 older versions are not thread-safe either).
 
 
index cfdf35dface02a4ff4155872040b92d5b2ae619d..fdf7da03924ebd783948c96dfe21d892291ff7b6 100644 (file)
@@ -2,7 +2,7 @@
 # Checking for programs.
 
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2004, 2005 Free Software Foundation, Inc.
+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -605,6 +605,65 @@ AC_SUBST(INSTALL_DATA)dnl
 ])# AC_PROG_INSTALL
 
 
+# AC_PROG_MKDIR_P
+# ---------------
+# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
+#
+# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
+# created by `make install' are always world readable, even if the
+# installer happens to have an overly restrictive umask (e.g. 077).
+# This was a mistake.  There are at least two reasons why we must not
+# use `-m 0755':
+#   - it causes special bits like SGID to be ignored,
+#   - it may be too restrictive (some setups expect 775 directories).
+#
+# Do not use -m 0755 and let people choose whatever they expect by
+# setting umask.
+#
+# We cannot accept any implementation of `mkdir' that recognizes `-p'.
+# Some implementations (such as Solaris 8's) are not thread-safe: if a
+# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
+# concurrently, both version can detect that a/ is missing, but only
+# one can create it and the other will error out.  Consequently we
+# restrict ourselves to GNU mkdir (using the --version option ensures
+# this.)
+AC_DEFUN([AC_PROG_MKDIR_P],
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+  # We used to define $(mkdir_p) as `mkdir -p .', in order to
+  # allow $(mkdir_p) to be used without argument.  As in
+  #   $(mkdir_p) $(somedir)
+  # where $(somedir) is conditionally defined.  However we don't do
+  # that anymore.
+  #  1. before we restricted the check to GNU mkdir, `mkdir -p .' was
+  #     reported to fail in read-only directories.  The system where this
+  #     happened has been forgotten.
+  #  2. in practice we call $(mkdir_p) on directories such as
+  #       $(mkdir_p) "$(DESTDIR)$(somedir)"
+  #     and we don't want to create $(DESTDIR) if $(somedir) is empty.
+  #     To support the latter case, we have to write
+  #       test -z "$(somedir)" || $(mkdir_p) "$(DESTDIR)$(somedir)"
+  #     so $(mkdir_p) always has an argument.
+  #     We will have better chances of detecting a missing test if
+  #     $(mkdir_p) complains about missing arguments.
+  #  3. $(mkdir_p) is named after `mkdir -p' and we don't expect this
+  #     to accept no argument.
+  #  4. having something like `mkdir .' in the output is unsightly.
+  mkdir_p='mkdir -p'
+else
+  # On NextStep and OpenStep, the `mkdir' command does not
+  # recognize any option.  It will interpret all options as
+  # directories to create.
+  for d in ./-p ./--version
+  do
+    test -d $d && rmdir $d
+  done
+  mkdir_p='$(install_sh) -d'
+fi
+AC_SUBST([mkdir_p])
+])# AC_PROG_MKDIR_P
+
+
 # AC_PROG_LEX
 # -----------
 # Look for flex or lex.  Set its associated library to LEXLIB.
index 3192bca645792e776df018d4de87f0d7655b36b0..59a8c158eae2d61d1bf9ccf008902ebb47e86e49 100644 (file)
@@ -901,17 +901,24 @@ $as_ln_s $1 $2
 # Emulate `mkdir -p' with plain `mkdir'.
 m4_define([AS_MKDIR_P],
 [AS_REQUIRE([_$0_PREPARE])dnl
-{ if $as_mkdir_p; then
-    test -d $1 || mkdir -p $1
-  else
-    as_dir=$1
+{ as_dir=$1
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
     as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
       as_dir=`AS_DIRNAME("$as_dir")`
+      test -d "$as_dir" && break
     done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || AS_ERROR([cannot create directory $1]); }dnl
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir]); }dnl
+  # The last "test -d" is in case some other process made the directory.
 ])# AS_MKDIR_P
 
 
index b4548e5ddb4b2a150b155c22989032f2fce7e504..ceddba6c1b32c26853051bbe573b9956fc923e6f 100644 (file)
@@ -292,7 +292,7 @@ if test -f state-env.before && test -f state-env.after; then
       [F77_DUMMY_MAIN|f77_(case|underscore)],
       [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_f)?],
       [ALLOCA|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
-      [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|RANLIB|SET_MAKE|YACC],
+      [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|mkdir_p|RANLIB|SET_MAKE|YACC],
       [GREP|[EF]GREP|SED],
       [[_@]|.[*#?$].|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS]))=' \
      $act_file 2>/dev/null |