bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

moving $(mkdir_p) from automake to autoconf


From: Bruno Haible
Subject: moving $(mkdir_p) from automake to autoconf
Date: Tue, 18 Apr 2006 14:43:42 +0200
User-agent: KMail/1.5

Automake now has a good way for creating installation directories:
it is multiprocess-safe, and uses GNU mkdir on GNU and Linux platforms,
while using the portable install-sh as a safe fallback.

Basically every package that does not use automake and that wants to
install _anything_ in public directories needs this functionality.

The install-sh is already in the autoconf package, and AC_PROG_INSTALL
requires it.

Therefore I propose to move the AM_PROG_MKDIR_P that defines an @mkdir_p@
variable to autoconf. The sooner, the better.

Find attached a raw sketch.


2006-04-17  Bruno Haible  <address@hidden>

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

*** lib/autoconf/programs.m4.bak        2006-03-18 12:35:32.000000000 +0100
--- lib/autoconf/programs.m4    2006-04-17 23:59:35.000000000 +0200
***************
*** 2,8 ****
  # Checking for programs.
  
  # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
! # 2002, 2004, 2005 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
--- 2,8 ----
  # Checking for programs.
  
  # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
! # 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,610 ****
--- 605,674 ----
  ])# 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
+ AC_REQUIRE_AUX_FILE([install-sh])dnl
+ # Use the full pathname of the install-sh script, to avoid the need for
+ # a directory-dependent substitution value, as for the INSTALL variable.
+ install_sh=`cd $ac_aux_dir && pwd`/install-sh
+ AC_SUBST([install_sh])
+ 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_LEX
  # -----------
  # Look for flex or lex.  Set its associated library to LEXLIB.
*** doc/autoconf.texi.bak       2006-04-14 00:14:55.000000000 +0200
--- doc/autoconf.texi   2006-04-18 00:02:20.000000000 +0200
***************
*** 3511,3516 ****
--- 3511,3531 ----
  @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.
+ 
+ This macro uses the @samp{mkdir} command if possible.  It may also fall
+ back to the @samp{install-sh -d} command.
+ 
+ Autoconf comes with a copy of @file{install-sh} that you can use.  If
+ you use @code{AC_PROG_MKDIR_P}, you must include @file{install-sh} in
+ your distribution.
+ @end defmac
+ 
  @defmac AC_PROG_LEX
  @acindex{PROG_LEX}
  @ovindex LEX





reply via email to

[Prev in Thread] Current Thread [Next in Thread]