2 # mkinstalldirs --- make directory hierarchy
4 scriptversion
=2024-12-03.03
; # UTC
6 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
10 # This file is maintained in Automake, please report
11 # bugs to <bug-automake@gnu.org> or send patches to
12 # <automake-patches@gnu.org>.
21 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
23 Create each directory DIR (with mode MODE, if specified), including all
24 leading file name components.
26 Report bugs to <bug-automake@gnu.org>.
27 GNU Automake home page: <https://www.gnu.org/software/automake/>.
28 General help using GNU software: <https://www.gnu.org/gethelp/>."
30 # process command line arguments
31 while test $# -gt 0 ; do
33 -h |
--help |
--h*) # -h for help
39 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
44 echo "$0 (GNU Automake) $scriptversion"
47 --) # stop option processing
55 *) # first non-opt arg
63 if test -d "$file"; then
74 # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
75 # mkdir -p a/c at the same time, both will detect that a is missing,
76 # one will create a, then the other will try to create a and die with
77 # a "File exists" error. This is a problem when calling mkinstalldirs
78 # from a parallel make. We use --version in the probe to restrict
79 # ourselves to GNU mkdir, which is thread-safe.
82 if mkdir
-p --version .
>/dev
/null
2>&1 && test ! -d .
/--version; then
86 # On NextStep and OpenStep, the 'mkdir' command does not
87 # recognize any option. It will interpret all options as
88 # directories to create, and then abort because '.' already
90 test -d .
/-p && rmdir .
/-p
91 test -d .
/--version && rmdir .
/--version
95 if mkdir
-m "$dirmode" -p --version .
>/dev
/null
2>&1 &&
96 test ! -d .
/--version; then
99 echo "mkdir -m $dirmode -p -- $*"
100 exec mkdir
-m "$dirmode" -p -- "$@"
102 # Clean up after NextStep and OpenStep mkdir.
103 for d
in .
/-m .
/-p .
/--version "./$dirmode";
105 test -d $d && rmdir $d
128 test "x$d" = x
&& continue
132 -*) pathcomp
=.
/$pathcomp ;;
135 if test ! -d "$pathcomp"; then
136 echo "mkdir $pathcomp"
138 mkdir
"$pathcomp" || lasterr
=$?
140 if test ! -d "$pathcomp"; then
148 if test ! -z "$dirmode"; then
149 echo "chmod $dirmode $file"
150 chmod "$dirmode" "$file" || errstatus
=$?
159 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
160 # time-stamp-start: "scriptversion="
161 # time-stamp-format: "%:y-%02m-%02d.%02H"
162 # time-stamp-time-zone: "UTC0"
163 # time-stamp-end: "; # UTC"