GCC with OpenMP stream-computing extension and BatchQueue algorithm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mkinstalldirs 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #! /bin/sh
  2. # mkinstalldirs --- make directory hierarchy
  3. scriptversion=2009-04-28.21; # UTC
  4. # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
  5. # Created: 1993-05-16
  6. # Public domain.
  7. #
  8. # This file is maintained in Automake, please report
  9. # bugs to <bug-automake@gnu.org> or send patches to
  10. # <automake-patches@gnu.org>.
  11. nl='
  12. '
  13. IFS=" "" $nl"
  14. errstatus=0
  15. dirmode=
  16. usage="\
  17. Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
  18. Create each directory DIR (with mode MODE, if specified), including all
  19. leading file name components.
  20. Report bugs to <bug-automake@gnu.org>."
  21. # process command line arguments
  22. while test $# -gt 0 ; do
  23. case $1 in
  24. -h | --help | --h*) # -h for help
  25. echo "$usage"
  26. exit $?
  27. ;;
  28. -m) # -m PERM arg
  29. shift
  30. test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
  31. dirmode=$1
  32. shift
  33. ;;
  34. --version)
  35. echo "$0 $scriptversion"
  36. exit $?
  37. ;;
  38. --) # stop option processing
  39. shift
  40. break
  41. ;;
  42. -*) # unknown option
  43. echo "$usage" 1>&2
  44. exit 1
  45. ;;
  46. *) # first non-opt arg
  47. break
  48. ;;
  49. esac
  50. done
  51. for file
  52. do
  53. if test -d "$file"; then
  54. shift
  55. else
  56. break
  57. fi
  58. done
  59. case $# in
  60. 0) exit 0 ;;
  61. esac
  62. # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
  63. # mkdir -p a/c at the same time, both will detect that a is missing,
  64. # one will create a, then the other will try to create a and die with
  65. # a "File exists" error. This is a problem when calling mkinstalldirs
  66. # from a parallel make. We use --version in the probe to restrict
  67. # ourselves to GNU mkdir, which is thread-safe.
  68. case $dirmode in
  69. '')
  70. if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
  71. echo "mkdir -p -- $*"
  72. exec mkdir -p -- "$@"
  73. else
  74. # On NextStep and OpenStep, the `mkdir' command does not
  75. # recognize any option. It will interpret all options as
  76. # directories to create, and then abort because `.' already
  77. # exists.
  78. test -d ./-p && rmdir ./-p
  79. test -d ./--version && rmdir ./--version
  80. fi
  81. ;;
  82. *)
  83. if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
  84. test ! -d ./--version; then
  85. echo "mkdir -m $dirmode -p -- $*"
  86. exec mkdir -m "$dirmode" -p -- "$@"
  87. else
  88. # Clean up after NextStep and OpenStep mkdir.
  89. for d in ./-m ./-p ./--version "./$dirmode";
  90. do
  91. test -d $d && rmdir $d
  92. done
  93. fi
  94. ;;
  95. esac
  96. for file
  97. do
  98. case $file in
  99. /*) pathcomp=/ ;;
  100. *) pathcomp= ;;
  101. esac
  102. oIFS=$IFS
  103. IFS=/
  104. set fnord $file
  105. shift
  106. IFS=$oIFS
  107. for d
  108. do
  109. test "x$d" = x && continue
  110. pathcomp=$pathcomp$d
  111. case $pathcomp in
  112. -*) pathcomp=./$pathcomp ;;
  113. esac
  114. if test ! -d "$pathcomp"; then
  115. echo "mkdir $pathcomp"
  116. mkdir "$pathcomp" || lasterr=$?
  117. if test ! -d "$pathcomp"; then
  118. errstatus=$lasterr
  119. else
  120. if test ! -z "$dirmode"; then
  121. echo "chmod $dirmode $pathcomp"
  122. lasterr=
  123. chmod "$dirmode" "$pathcomp" || lasterr=$?
  124. if test ! -z "$lasterr"; then
  125. errstatus=$lasterr
  126. fi
  127. fi
  128. fi
  129. fi
  130. pathcomp=$pathcomp/
  131. done
  132. done
  133. exit $errstatus
  134. # Local Variables:
  135. # mode: shell-script
  136. # sh-indentation: 2
  137. # eval: (add-hook 'write-file-hooks 'time-stamp)
  138. # time-stamp-start: "scriptversion="
  139. # time-stamp-format: "%:y-%02m-%02d.%02H"
  140. # time-stamp-time-zone: "UTC"
  141. # time-stamp-end: "; # UTC"
  142. # End: