|
|
1.1 root 1: #! /bin/sh
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:
8: # Directory in which to store the results.
9: LIB=${LIB-/usr/local/lib/gcc-include}
10:
11: # Make sure it exists.
12: if [ ! -d $LIB ]; then
13: mkdir $LIB || exit 1
14: fi
15:
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:
24: echo 'Making directories:'
25: cd /usr/include
26: if $LINKS; then
27: files=`ls -LR | sed -n s/:$//p`
28: else
29: files=`find . -type d -print | sed '/^.$/d'`
30: fi
31: for file in $files; do
32: rm -rf $LIB/$file
33: if [ ! -d $LIB/$file ]
34: then mkdir $LIB/$file
35: fi
36: done
37:
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
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
75: fi
76: cd $cwd
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.
84: echo "Finding header files in $1:"
85: cd /usr/include
86: cd $1
87: files=`find . -name '*.h' -type f -print`
88: echo 'Checking header files:'
89: for file in $files; do
90: if egrep '[ ]_IO[A-Z]*\(|#define._IO|CTRL|#machine|#lint' $file > /dev/null; then
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
96: sed -e '
97: :loop
98: /\\$/ N
99: /\\$/ b loop
100: /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
101: /#define._IO/ s/'\''x'\''/x/g
102: /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
103: /#define.CTRL/ s/'\''c'\''/c/g
104: /#define._CTRL/ s/'\''c'\''/c/g
105: /^[ ]*#[ ]*if/ s/#machine/defined/g
106: /^[ ]*#[ ]*elif/ s/#machine/defined/g
107: /^[ ]*#[ ]*if/ s/#lint *(on)/defined(lint)/g
108: /^[ ]*#[ ]*elif/ s/#lint *(on)/defined(lint)/g
109: ' $2/$file > $2/$file.sed
110: mv $2/$file.sed $2/$file
111: if cmp $file $2/$file >/dev/null 2>&1; then
112: echo Deleting $2/$file\; no fixes were needed.
113: rm $2/$file
114: fi
115: fi
116: fi
117: done
118: shift; shift
119: done
120:
121: cd /usr/include
122:
123: # Fix one other error in this file: a mismatched quote not inside a C comment.
124: file=sundev/vuid_event.h
125: if [ -r $file ]; then
126: if [ ! -r ${LIB}/$file ]; then
127: cp $file ${LIB}/$file >/dev/null 2>&1 \
128: || echo "Can't copy $file"
129: chmod +w ${LIB}/$file
130: fi
131: fi
132:
133: if [ -r ${LIB}/$file ]; then
134: echo Fixing $file comment
135: ex ${LIB}/$file <<EOF
136: g/doesn't/s/doesn't/does not/
137: wq
138: EOF
139: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
140: echo Deleting ${LIB}/$file\; no fixes were needed.
141: rm ${LIB}/$file
142: fi
143: fi
144:
145: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
146: # structure definition.
147: file=rpcsvc/rstat.h
148: if [ -r $file ]; then
149: if [ ! -r ${LIB}/$file ]; then
150: cp $file ${LIB}/$file >/dev/null 2>&1 \
151: || echo "Can't copy $file"
152: chmod +w ${LIB}/$file
153: fi
154: fi
155:
156: if [ -r ${LIB}/$file ]; then
157: echo Fixing $file, definition of statsswtch
158: ex ${LIB}/$file <<EOF
159: g/boottime$/s//&;/
160: wq
161: EOF
162: if cmp $file $2/$file >/dev/null 2>&1; then
163: echo Deleting $2/$file\; no fixes were needed.
164: rm $2/$file
165: fi
166: fi
167:
168: # Deal with yet another challenge, this in X11/Xmu.h
169: file=X11/Xmu.h
170: if [ -r $file ]; then
171: if [ ! -r ${LIB}/$file ]; then
172: mkdir ${LIB}/X11 2>&-
173: cp $file ${LIB}/$file >/dev/null 2>&1 \
174: || echo "Can't copy $file"
175: chmod +w ${LIB}/$file
176: fi
177: fi
178:
179: if [ -r ${LIB}/$file ]; then
180: echo Fixing $file sprintf declaration
181: ex ${LIB}/$file <<EOF
182: /^extern char \* sprintf();$/c
183: #ifndef __STDC__
184: extern char * sprintf();
185: #endif /* !defined __STDC__ */
186: .
187: wq
188: EOF
189: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
190: echo Deleting ${LIB}/$file\; no fixes were needed.
191: rm ${LIB}/$file
192: fi
193: fi
194:
195: # Check for missing ';' in struct
196:
197: file=netinet/ip.h
198: if [ -r $file ]; then
199: if [ ! -r ${LIB}/$file ]; then
200: mkdir ${LIB}/netinet 2>&-
201: sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file
202: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
203: fi
204: fi
205:
206: # Fix the CAT macro in memvar.h.
207:
208: file=pixrect/memvar.h
209: if [ -r $file ]; then
210: if [ ! -r ${LIB}/$file ]; then
211: mkdir ${LIB}/pixrect 2>&-
212: sed -e '/^#define.CAT(a,b)/ s/IDENT(a)b/a##b/g' $file > ${LIB}/$file
213: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
214: fi
215: fi
216:
217: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
218:
219: file=rpcsvc/rusers.h
220: if [ -r $file ]; then
221: if [ ! -r ${LIB}/$file ]; then
222: mkdir ${LIB}/rpcsvc 2>&-
223: sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
224: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
225: fi
226: fi
227:
228: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
229:
230: file=rpcsvc/rusers.h
231: if [ -r $file ]; then
232: if [ ! -r ${LIB}/$file ]; then
233: mkdir ${LIB}/rpcsvc 2>&-
234: sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
235: cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
236: fi
237: fi
238:
239: echo 'Removing unneeded directories:'
240: cd $LIB
241: files=`find . -type d -print | sort -r`
242: for file in $files; do
243: rmdir $LIB/$file > /dev/null 2>&1
244: done
245:
246: if $LINKS; then
247: echo 'Making internal symbolic non-directory links'
248: cd /usr/include
249: files=`find . -type l -print`
250: for file in $files; do
251: dest=`ls -ld $file | sed -n 's/.*-> //p'`
252: if expr "$dest" : '[^/].*' > /dev/null; then
253: target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
254: if [ -f $target ]; then
255: ln -s $dest ${LIB}/$file >/dev/null 2>&1
256: fi
257: fi
258: done
259: fi
260:
261: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.