2 # $MirOS: contrib/code/jupp/mkinstalldirs,v 1.8 2008/05/13 16:13:39 tg Exp $
3 # $miros: contrib/gnu/aux/mkinstalldirs,v 1.9 2008/05/02 23:01:38 tg Exp $
5 # mkinstalldirs --- make directory hierarchy
7 scriptversion=2006-05-11.19
9 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
13 # This file is maintained in Automake, please report
14 # bugs to <bug-automake@gnu.org> or send patches to
15 # <automake-patches@gnu.org>.
24 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
26 Create each directory DIR (with mode MODE, if specified), including all
27 leading file name components.
29 Report bugs to <bug-automake@gnu.org>."
31 # process command line arguments
32 while test $# -gt 0 ; do
34 -h | --help | --h*) # -h for help
40 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
45 echo "$0 $scriptversion"
48 --) # stop option processing
56 *) # first non-opt arg
64 if test -d "$file"; then
75 # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
76 # mkdir -p a/c at the same time, both will detect that a is missing,
77 # one will create a, then the other will try to create a and die with
78 # a "File exists" error. This is a problem when calling mkinstalldirs
79 # from a parallel make. We use --version in the probe to restrict
80 # ourselves to GNU mkdir, which is thread-safe.
83 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
87 # On NextStep and OpenStep, the `mkdir' command does not
88 # recognize any option. It will interpret all options as
89 # directories to create, and then abort because `.' already
91 test -d ./-p && rmdir ./-p
92 test -d ./--version && rmdir ./--version
96 if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
97 test ! -d ./--version; then
98 echo "mkdir -m $dirmode -p -- $*"
99 exec mkdir -m "$dirmode" -p -- "$@"
101 # Clean up after NextStep and OpenStep mkdir.
102 for d in ./-m ./-p ./--version "./$dirmode";
104 test -d $d && rmdir $d
124 test "x$d" = x && continue
128 -*) pathcomp=./$pathcomp ;;
131 if test ! -d "$pathcomp"; then
132 echo "mkdir $pathcomp"
134 mkdir "$pathcomp" || lasterr=$?
136 if test ! -d "$pathcomp"; then
139 if test ! -z "$dirmode"; then
140 echo "chmod $dirmode $pathcomp"
142 chmod "$dirmode" "$pathcomp" || lasterr=$?
144 if test ! -z "$lasterr"; then
160 # eval: (add-hook 'write-file-hooks 'time-stamp)
161 # time-stamp-start: "scriptversion="
162 # time-stamp-format: "%:y-%02m-%02d.%02H"
163 # time-stamp-end: "$"