|
|
1.1.1.2 root 1: #! /bin/sh
1.1 root 2: # Install modified versions of certain ANSI-incompatible system header files
3: # which are fixed to work correctly with ANSI C
4: # and placed in a directory that GNU C will search.
5: # This works properly on a Sun in system version 3.4;
6: # for other versions, you had better check.
7:
1.1.1.3 root 8: # Directory in which to store the results.
1.1.1.11 root 9: LIB=${LIB-/usr/local/lib/gcc-include}
10:
11: # Make sure it exists.
1.1.1.12 root 12: if [ ! -d $LIB ]; then
13: mkdir $LIB || exit 1
14: fi
1.1.1.3 root 15:
1.1.1.10 root 16: # Determine whether this system has symbolic links.
17: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
18: rm -f $LIB/ShouldNotExist
19: LINKS=true
20: else
21: LINKS=false
22: fi
23:
1.1.1.9 root 24: echo 'Making directories:'
25: cd /usr/include
1.1.1.10 root 26: if $LINKS; then
27: files=`ls -LR | sed -n s/:$//p`
28: else
1.1.1.12 root 29: files=`find . -type d -print | sed '/^.$/d'`
1.1.1.10 root 30: fi
1.1.1.9 root 31: for file in $files; do
1.1.1.12 root 32: rm -rf $LIB/$file
33: if [ ! -d $LIB/$file ]
34: then mkdir $LIB/$file
35: fi
1.1.1.9 root 36: done
1.1.1.6 root 37:
1.1.1.10 root 38: # treetops gets an alternating list
39: # of old directories to copy
40: # and the new directories to copy to.
41: treetops="/usr/include ${LIB}"
42:
43: if $LINKS; then
44: echo 'Making internal symbolic directory links'
45: for file in $files; do
46: dest=`ls -ld $file | sed -n 's/.*-> //p'`
47: if [ "$dest" ]; then
1.1.1.12 root 48: cwd=`pwd`
49: # In case $dest is relative, get to $file's dir first.
50: cd /usr/include
51: cd `echo ./$file | sed -n 's&[^/]*$&&p'`
52: # Check that the target directory exists.
53: # Redirections changed to avoid bug in sh on Ultrix.
54: (cd $dest) > /dev/null 2>&1
55: if [ $? = 0 ]; then
56: cd $dest
57: # X gets the dir that the link actually leads to.
58: x=`pwd`
59: # If link leads back into /usr/include,
60: # make a similar link here.
61: if expr $x : '/usr/include/.*' > /dev/null; then
62: # Y gets the actual target dir name, relative to /usr/include.
63: y=`echo $x | sed -n 's&/usr/include/&&p'`
64: echo $file '->' $y ': Making link'
65: rm -fr ${LIB}/$file > /dev/null 2>&1
66: ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
67: else
68: # If the link is to outside /usr/include,
69: # treat this directory as if it actually contained the files.
70: # This line used to have $dest instead of $x.
71: # $dest seemed to be wrong for links found in subdirectories
72: # of /usr/include. Does this change break anything?
73: treetops="$treetops $x ${LIB}/$file"
74: fi
1.1.1.10 root 75: fi
1.1.1.12 root 76: cd $cwd
1.1.1.10 root 77: fi
78: done
79: fi
80:
81: set - $treetops
82: while [ $# != 0 ]; do
83: # $1 is an old directory to copy, and $2 is the new directory to copy to.
1.1.1.11 root 84: echo "Finding header files in $1:"
85: cd /usr/include
1.1.1.10 root 86: cd $1
1.1.1.12 root 87: files=`find . -name '*.h' -type f -print`
1.1.1.10 root 88: echo 'Checking header files:'
89: for file in $files; do
1.1.1.11 root 90: if egrep '[ ]_IO[A-Z]*\(|#define._IO|CTRL' $file > /dev/null; then
1.1.1.10 root 91: echo Fixing $file
92: if [ -r $file ]; then
93: cp $file $2/$file >/dev/null 2>&1 \
94: || echo "Can't copy $file"
95: chmod +w $2/$file
1.1.1.11 root 96: sed -e '
97: :loop
98: /\\$/ N
99: /\\$/ b loop
1.1.1.12 root 100: /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
1.1.1.11 root 101: /#define._IO/ s/'\''x'\''/x/g
1.1.1.12 root 102: /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
1.1.1.11 root 103: /#define.CTRL/ s/'\''c'\''/c/g
1.1.1.12 root 104: /#define._CTRL/ s/'\''c'\''/c/g
1.1.1.11 root 105: ' $2/$file > $2/$file.sed
106: mv $2/$file.sed $2/$file
1.1.1.10 root 107: if cmp $file $2/$file >/dev/null 2>&1; then
108: echo Deleting $2/$file\; no fixes were needed.
109: rm $2/$file
110: fi
1.1.1.8 root 111: fi
1.1.1.5 root 112: fi
1.1.1.10 root 113: done
114: shift; shift
1.1.1.2 root 115: done
116:
1.1.1.11 root 117: cd /usr/include
118:
1.1.1.5 root 119: # Fix one other error in this file: a mismatched quote not inside a C comment.
120: file=sundev/vuid_event.h
121: if [ -r $file ]; then
122: if [ ! -r ${LIB}/$file ]; then
123: cp $file ${LIB}/$file >/dev/null 2>&1 \
124: || echo "Can't copy $file"
1.1.1.3 root 125: chmod +w ${LIB}/$file
1.1.1.2 root 126: fi
1.1.1.5 root 127: fi
1.1.1.4 root 128:
1.1.1.12 root 129: if [ -r ${LIB}/$file ]; then
130: echo Fixing $file comment
131: ex ${LIB}/$file <<EOF
1.1.1.11 root 132: g/doesn't/s/doesn't/does not/
133: wq
134: EOF
1.1.1.12 root 135: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
136: echo Deleting ${LIB}/$file\; no fixes were needed.
137: rm ${LIB}/$file
138: fi
139: fi
140:
141: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
142: # structure definition.
143: file=rpcsvc/rstat.h
144: if [ -r $file ]; then
145: if [ ! -r ${LIB}/$file ]; then
146: cp $file ${LIB}/$file >/dev/null 2>&1 \
147: || echo "Can't copy $file"
148: chmod +w ${LIB}/$file
149: fi
150: fi
151:
152: if [ -r ${LIB}/$file ]; then
153: echo Fixing $file, definition of statsswtch
154: ex ${LIB}/$file <<EOF
155: g/boottime$/s//&;/
156: wq
157: EOF
1.1.1.13! root 158: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
! 159: echo Deleting ${LIB}/$file\; no fixes were needed.
! 160: rm ${LIB}/$file
! 161: fi
! 162: fi
! 163:
! 164: # Check for bad #ifdef line (in Ultrix 4.1)
! 165:
! 166: file=sys/file.h
! 167: if [ -r $file ]; then
! 168: if [ ! -r ${LIB}/$file ]; then
! 169: mkdir ${LIB}/rpcsvc 2>&-
! 170: cp $file ${LIB}/$file >/dev/null 2>&1 \
! 171: || echo "Can't copy $file"
! 172: chmod +w ${LIB}/$file
! 173: fi
! 174: fi
! 175:
! 176: if [ -r ${LIB}/$file ]; then
! 177: echo Fixing $file, bad #ifdef line
! 178: ex ${LIB}/$file <<EOF
! 179: g/^#ifdef KERNEL && !defined/
! 180: s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
! 181: wq
! 182: EOF
! 183: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
! 184: echo Deleting ${LIB}/$file\; no fixes were needed.
! 185: rm ${LIB}/$file
1.1.1.12 root 186: fi
1.1.1.11 root 187: fi
188:
189: # Deal with yet another challenge, this in X11/Xmu.h
190: file=X11/Xmu.h
191: if [ -r $file ]; then
192: if [ ! -r ${LIB}/$file ]; then
193: mkdir ${LIB}/X11 2>&-
194: cp $file ${LIB}/$file >/dev/null 2>&1 \
195: || echo "Can't copy $file"
196: chmod +w ${LIB}/$file
197: fi
198: fi
199:
200: if [ -r ${LIB}/$file ]; then
201: echo Fixing $file sprintf declaration
202: ex ${LIB}/$file <<EOF
203: /^extern char \* sprintf();$/c
204: #ifndef __STDC__
205: extern char * sprintf();
206: #endif /* !defined __STDC__ */
207: .
1.1.1.5 root 208: wq
1.1 root 209: EOF
1.1.1.12 root 210: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
211: echo Deleting ${LIB}/$file\; no fixes were needed.
212: rm ${LIB}/$file
213: fi
214: fi
215:
216: # Check for missing ';' in struct
217:
218: file=netinet/ip.h
219: if [ -r $file ]; then
220: if [ ! -r ${LIB}/$file ]; then
221: mkdir ${LIB}/netinet 2>&-
222: sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file
223: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
224: fi
225: fi
226:
227: # Fix the CAT macro in memvar.h.
228:
229: file=pixrect/memvar.h
230: if [ -r $file ]; then
231: if [ ! -r ${LIB}/$file ]; then
232: mkdir ${LIB}/pixrect 2>&-
233: sed -e '/^#define.CAT(a,b)/ s/IDENT(a)b/a##b/g' $file > ${LIB}/$file
234: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
235: fi
236: fi
237:
238: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
239:
240: file=rpcsvc/rusers.h
241: if [ -r $file ]; then
242: if [ ! -r ${LIB}/$file ]; then
243: mkdir ${LIB}/rpcsvc 2>&-
244: sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
245: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
246: fi
247: fi
248:
249: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
250:
251: file=rpcsvc/rusers.h
252: if [ -r $file ]; then
253: if [ ! -r ${LIB}/$file ]; then
254: mkdir ${LIB}/rpcsvc 2>&-
255: sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
256: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
257: fi
1.1.1.8 root 258: fi
1.1.1.10 root 259:
260: echo 'Removing unneeded directories:'
261: cd $LIB
262: files=`find . -type d -print | sort -r`
263: for file in $files; do
264: rmdir $LIB/$file > /dev/null 2>&1
265: done
266:
1.1.1.11 root 267: if $LINKS; then
268: echo 'Making internal symbolic non-directory links'
269: cd /usr/include
270: files=`find . -type l -print`
271: for file in $files; do
272: dest=`ls -ld $file | sed -n 's/.*-> //p'`
273: if expr "$dest" : '[^/].*' > /dev/null; then
274: target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
275: if [ -f $target ]; then
276: ln -s $dest ${LIB}/$file >/dev/null 2>&1
277: fi
278: fi
279: done
280: fi
281:
282: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.