* m4/mkdirp.m4 (AM_PROG_MKDIR_P): Append `.' to $(mkdir_p).
[platform/upstream/automake.git] / m4 / mkdirp.m4
1 # AM_PROG_MKDIR_P
2 # ---------------
3 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
4
5 # Copyright (C) 2003, 2004 Free Software Foundation, Inc.
6
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.
11
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.
16
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.
21
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).
29 #
30 # Do not use -m 0755 and let people choose whatever they expect by
31 # setting umask.
32 AC_DEFUN([AM_PROG_MKDIR_P],
33 [if mkdir -p -- . 2>/dev/null; then
34   # Keeping the `.' argument allows $(mkdir_p) to be used without
35   # argument.  Indeed, we sometimes output rules like
36   #   $(mkdir_p) $(somedir)
37   # where $(somedir) is conditionally defined.
38   # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
39   # expensive solution, as it forces Make to start a sub-shell.)
40   mkdir_p='mkdir -p -- .'
41 else
42   # On NextStep and OpenStep, the `mkdir' command does not
43   # recognize any option.  It will interpret all options as
44   # directories to create, and then abort because `.' already
45   # exists.
46   for d in ./-p ./--;
47   do
48     test -d $d && rmdir $d
49   done
50   # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
51   if test -f "$ac_aux_dir/mkinstalldirs"; then
52     mkdir_p='$(mkinstalldirs)'
53   else
54     mkdir_p='$(install_sh) -d'
55   fi
56 fi
57 AC_SUBST([mkdir_p])])