* configure.in, NEWS: Bump version to 1.8.3.
[automake.git] / m4 / mkdirp.m4
blob361d20cfd6366d3a36a62bc0f7186bf9e1301a18
1 # AM_PROG_MKDIR_P
2 # ---------------
3 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
5 # Copyright (C) 2003, 2004 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA.
22 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
23 # created by `make install' are always world readable, even if the
24 # installer happens to have an overly restrictive umask (e.g. 077).
25 # This was a mistake.  There are at least two reasons why we must not
26 # use `-m 0755':
27 #   - it causes special bits like SGID to be ignored,
28 #   - it may be too restrictive (some setups expect 775 directories).
30 # Do not use -m 0755 and let people choose whatever they expect by
31 # setting umask.
33 # We cannot accept any implementation of `mkdir' that recognizes `-p'.
34 # Some implementations (such as Solaris 8's) are not thread-safe: if a
35 # parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
36 # concurrently, both version can detect that a/ is missing, but only
37 # one can create it and the other will error out.  Consequently we
38 # restrict ourselves to GNU make (using the --version option ensures
39 # this.)
40 AC_DEFUN([AM_PROG_MKDIR_P],
41 [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
42   # Keeping the `.' argument allows $(mkdir_p) to be used without
43   # argument.  Indeed, we sometimes output rules like
44   #   $(mkdir_p) $(somedir)
45   # where $(somedir) is conditionally defined.
46   # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
47   # expensive solution, as it forces Make to start a sub-shell.)
48   mkdir_p='mkdir -p -- .'
49 else
50   # On NextStep and OpenStep, the `mkdir' command does not
51   # recognize any option.  It will interpret all options as
52   # directories to create, and then abort because `.' already
53   # exists.
54   for d in ./-p ./--version;
55   do
56     test -d $d && rmdir $d
57   done
58   # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
59   if test -f "$ac_aux_dir/mkinstalldirs"; then
60     mkdir_p='$(mkinstalldirs)'
61   else
62     mkdir_p='$(install_sh) -d'
63   fi
65 AC_SUBST([mkdir_p])])