2
# mkinstalldirs --- make directory hierarchy
6
scriptversion=2005-02-02.21
8
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
12
# This file is maintained in Automake, please report
13
# bugs to <bug-automake@gnu.org> or send patches to
14
# <automake-patches@gnu.org>.
20
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
22
Create each directory DIR (with mode MODE, if specified), including all
23
leading file name components.
25
Report bugs to <bug-automake@gnu.org>."
27
# process command line arguments
28
while test $# -gt 0 ; do
30
-h | --help | --h*) # -h for help
36
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
41
echo "$0 $scriptversion"
44
--) # stop option processing
52
*) # first non-opt arg
60
if test -d "$file"; then
71
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
72
# mkdir -p a/c at the same time, both will detect that a is missing,
73
# one will create a, then the other will try to create a and die with
74
# a "File exists" error. This is a problem when calling mkinstalldirs
75
# from a parallel make. We use --version in the probe to restrict
76
# ourselves to GNU mkdir, which is thread-safe.
79
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
83
# On NextStep and OpenStep, the `mkdir' command does not
84
# recognize any option. It will interpret all options as
85
# directories to create, and then abort because `.' already
87
test -d ./-p && rmdir ./-p
88
test -d ./--version && rmdir ./--version
92
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
93
test ! -d ./--version; then
94
echo "mkdir -m $dirmode -p -- $*"
95
exec mkdir -m "$dirmode" -p -- "$@"
97
# Clean up after NextStep and OpenStep mkdir.
98
for d in ./-m ./-p ./--version "./$dirmode";
100
test -d $d && rmdir $d
108
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
114
pathcomp="$pathcomp$d"
116
-*) pathcomp=./$pathcomp ;;
119
if test ! -d "$pathcomp"; then
120
echo "mkdir $pathcomp"
122
mkdir "$pathcomp" || lasterr=$?
124
if test ! -d "$pathcomp"; then
127
if test ! -z "$dirmode"; then
128
echo "chmod $dirmode $pathcomp"
130
chmod "$dirmode" "$pathcomp" || lasterr=$?
132
if test ! -z "$lasterr"; then
139
pathcomp="$pathcomp/"
148
# eval: (add-hook 'write-file-hooks 'time-stamp)
149
# time-stamp-start: "scriptversion="
150
# time-stamp-format: "%:y-%02m-%02d.%02H"
151
# time-stamp-end: "$"