* configure.ac, NEWS: Bump version to 1.9.2.
[automake.git] / m4 / mkdirp.m4
blob5541b03aad94c55ab4048232b929ff818e652d1c
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   # We used to keeping the `.' as first argument, in order to
43   # allow $(mkdir_p) to be used without argument.  As in
44   #   $(mkdir_p) $(somedir)
45   # where $(somedir) is conditionally defined.  However this is wrong
46   # for two reasons:
47   #  1. if the package is installed by a user who cannot write `.'
48   #     make install will fail,
49   #  2. the above comment should most certainly read
50   #     $(mkdir_p) $(DESTDIR)$(somedir)
51   #     so it does not work when $(somedir) is undefined and
52   #     $(DESTDIR) is not.
53   #  To support the latter case, we have to write
54   #     test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
55   #  so the `.' trick is pointless.
56   mkdir_p='mkdir -p --'
57 else
58   # On NextStep and OpenStep, the `mkdir' command does not
59   # recognize any option.  It will interpret all options as
60   # directories to create, and then abort because `.' already
61   # exists.
62   for d in ./-p ./--version;
63   do
64     test -d $d && rmdir $d
65   done
66   # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
67   if test -f "$ac_aux_dir/mkinstalldirs"; then
68     mkdir_p='$(mkinstalldirs)'
69   else
70     mkdir_p='$(install_sh) -d'
71   fi
73 AC_SUBST([mkdir_p])])