~mirabilos/jupp/trunk

77 by tg
regenerate
1
#! /bin/sh
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 by tg
bring up to our standards, add strlfun.c from old repo
4
#-
77 by tg
regenerate
5
# mkinstalldirs --- make directory hierarchy
6
7
scriptversion=2006-05-11.19
8
9
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
10
# Created: 1993-05-16
11
# Public domain.
12
#
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>.
16
17
nl='
18
'
19
IFS=" ""	$nl"
20
errstatus=0
21
dirmode=
22
23
usage="\
24
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
25
26
Create each directory DIR (with mode MODE, if specified), including all
27
leading file name components.
28
29
Report bugs to <bug-automake@gnu.org>."
30
31
# process command line arguments
32
while test $# -gt 0 ; do
33
  case $1 in
34
    -h | --help | --h*)         # -h for help
35
      echo "$usage"
36
      exit $?
37
      ;;
38
    -m)                         # -m PERM arg
39
      shift
40
      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
41
      dirmode=$1
42
      shift
43
      ;;
44
    --version)
45
      echo "$0 $scriptversion"
46
      exit $?
47
      ;;
48
    --)                         # stop option processing
49
      shift
50
      break
51
      ;;
52
    -*)                         # unknown option
53
      echo "$usage" 1>&2
54
      exit 1
55
      ;;
56
    *)                          # first non-opt arg
57
      break
58
      ;;
59
  esac
60
done
61
62
for file
63
do
64
  if test -d "$file"; then
65
    shift
66
  else
67
    break
68
  fi
69
done
70
71
case $# in
72
  0) exit 0 ;;
73
esac
74
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.
81
case $dirmode in
82
  '')
83
    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
84
      echo "mkdir -p -- $*"
85
      exec mkdir -p -- "$@"
86
    else
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
90
      # exists.
91
      test -d ./-p && rmdir ./-p
92
      test -d ./--version && rmdir ./--version
93
    fi
94
    ;;
95
  *)
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 -- "$@"
100
    else
101
      # Clean up after NextStep and OpenStep mkdir.
102
      for d in ./-m ./-p ./--version "./$dirmode";
103
      do
104
        test -d $d && rmdir $d
105
      done
106
    fi
107
    ;;
108
esac
109
110
for file
111
do
112
  case $file in
113
    /*) pathcomp=/ ;;
114
    *)  pathcomp= ;;
115
  esac
116
  oIFS=$IFS
117
  IFS=/
118
  set fnord $file
119
  shift
120
  IFS=$oIFS
121
122
  for d
123
  do
124
    test "x$d" = x && continue
125
126
    pathcomp=$pathcomp$d
127
    case $pathcomp in
128
      -*) pathcomp=./$pathcomp ;;
129
    esac
130
131
    if test ! -d "$pathcomp"; then
132
      echo "mkdir $pathcomp"
133
134
      mkdir "$pathcomp" || lasterr=$?
135
136
      if test ! -d "$pathcomp"; then
137
	errstatus=$lasterr
138
      else
139
	if test ! -z "$dirmode"; then
140
	  echo "chmod $dirmode $pathcomp"
141
	  lasterr=
142
	  chmod "$dirmode" "$pathcomp" || lasterr=$?
143
144
	  if test ! -z "$lasterr"; then
145
	    errstatus=$lasterr
146
	  fi
147
	fi
148
      fi
149
    fi
150
151
    pathcomp=$pathcomp/
152
  done
153
done
154
155
exit $errstatus
156
157
# Local Variables:
158
# mode: shell-script
159
# sh-indentation: 2
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: "$"
164
# End: