]>
Commit | Line | Data |
---|---|---|
c61a25b1 DM |
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 | ||
6 | # See README-fixinc for more information. | |
7 | ||
b7b62369 RS |
8 | # Directory where gcc sources (and sometimes special include files) live. |
9 | # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make | |
10 | # sure somebody doesn't try to use arg3 for something incompatible. -- gumby | |
11 | SRCDIR=${3-${SRCDIR-.}} | |
12 | ||
c61a25b1 DM |
13 | # Directory containing the original header files. |
14 | # (This was named INCLUDES, but that conflicts with a name in Makefile.in.) | |
15 | INPUT=${2-${INPUT-/usr/include}} | |
16 | ||
17 | # This prevents /bin/ex from failing if the current terminal type is | |
18 | # unrecognizable. | |
19 | TERM=unknown | |
20 | export TERM | |
3911abb2 RS |
21 | # This prevents two problems: |
22 | # Either ex might find a .exrc file and get confused, | |
23 | # or ex might complain if the EXINIT variable is invalid. | |
24 | # We know there is no .exrc in the GCC source. | |
3e398742 RS |
25 | # `set' is a no-op ex command. |
26 | EXINIT=set | |
04b5ab57 | 27 | export EXINIT |
c61a25b1 | 28 | |
4ed15f9d RS |
29 | # Define PWDCMD as a command to use to get the working dir |
30 | # in the form that we want. | |
31 | PWDCMD=pwd | |
32 | case "`pwd`" in | |
33 | //*) | |
34 | # On an Apollo, discard everything before `/usr'. | |
d45ceebe | 35 | PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'" |
4ed15f9d RS |
36 | ;; |
37 | esac | |
38 | ||
c61a25b1 | 39 | # Directory in which to store the results. |
4eb6de22 | 40 | LIB=${1?"fixincludes: output directory not specified"} |
c61a25b1 DM |
41 | |
42 | # Make sure it exists. | |
43 | if [ ! -d $LIB ]; then | |
44 | mkdir $LIB || exit 1 | |
45 | fi | |
46 | ||
47 | # Make LIB absolute. | |
4ed15f9d | 48 | cd $LIB; LIB=`${PWDCMD}` |
c61a25b1 DM |
49 | |
50 | # Fail if no arg to specify a directory for the output. | |
51 | if [ x$1 = x ] | |
52 | then echo fixincludes: no output directory specified | |
53 | exit 1 | |
54 | fi | |
55 | ||
1ac7d389 | 56 | echo Building fixed headers in ${LIB} |
c61a25b1 DM |
57 | |
58 | # Determine whether this system has symbolic links. | |
59 | if ln -s X $LIB/ShouldNotExist 2>/dev/null; then | |
60 | rm -f $LIB/ShouldNotExist | |
61 | LINKS=true | |
62 | else | |
63 | LINKS=false | |
64 | fi | |
65 | ||
1ac7d389 | 66 | echo Finding directories and links to directories |
c61a25b1 | 67 | cd ${INPUT} |
3308e40a | 68 | # Find all directories and all symlinks that point to directories. |
f1f1ae8e RS |
69 | # Put the list in $files. |
70 | # Each time we find a symlink, add it to newdirs | |
71 | # so that we do another find within the dir the link points to. | |
72 | # Note that $files may have duplicates in it; | |
73 | # later parts of this file are supposed to ignore them. | |
74 | dirs="." | |
fd297e33 RS |
75 | levels=2 |
76 | while [ -n "$dirs" ] && [ $levels -gt 0 ] | |
f1f1ae8e | 77 | do |
fd297e33 | 78 | levels=`expr $levels - 1` |
f1f1ae8e | 79 | newdirs= |
fd297e33 | 80 | for d in $dirs |
f1f1ae8e | 81 | do |
1ac7d389 | 82 | echo " Searching $INPUT/$d" |
f1f1ae8e RS |
83 | if [ "$d" != . ] |
84 | then | |
85 | d=$d/. | |
86 | fi | |
87 | ||
fd297e33 | 88 | # Find all directories under $d, relative to $d, excluding $d itself. |
165b3941 RS |
89 | files="$files `find $d -type d -print | \ |
90 | sed -e '/\/\.$/d' -e '/^\.$/d'`" | |
91 | # Find all links to directories. | |
92 | # Using `-exec test -d' in find fails on some systems, | |
93 | # and trying to run test via sh fails on others, | |
94 | # so this is the simplest alternative left. | |
95 | # First find all the links, then test each one. | |
96 | theselinks= | |
f1f1ae8e | 97 | $LINKS && \ |
165b3941 RS |
98 | theselinks=`find $d -type l -print` |
99 | for d1 in $theselinks --dummy-- | |
100 | do | |
1ac7d389 RS |
101 | # If the link points to a directory, |
102 | # add that dir to $newdirs | |
165b3941 RS |
103 | if [ -d $d1 ] |
104 | then | |
105 | newdirs="$newdirs $d1" | |
106 | fi | |
107 | done | |
f1f1ae8e RS |
108 | done |
109 | ||
89ccb80f | 110 | files="$files $newdirs" |
f1f1ae8e | 111 | dirs="$newdirs" |
f1f1ae8e RS |
112 | done |
113 | ||
114 | dirs= | |
1ac7d389 | 115 | echo "All directories (including links to directories):" |
f1f1ae8e RS |
116 | echo $files |
117 | ||
c61a25b1 DM |
118 | for file in $files; do |
119 | rm -rf $LIB/$file | |
120 | if [ ! -d $LIB/$file ] | |
121 | then mkdir $LIB/$file | |
122 | fi | |
123 | done | |
1ac7d389 | 124 | mkdir $LIB/root |
c61a25b1 DM |
125 | |
126 | # treetops gets an alternating list | |
127 | # of old directories to copy | |
128 | # and the new directories to copy to. | |
129 | treetops="${INPUT} ${LIB}" | |
130 | ||
131 | if $LINKS; then | |
1ac7d389 | 132 | echo 'Making symbolic directory links' |
c61a25b1 DM |
133 | for file in $files; do |
134 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
135 | if [ "$dest" ]; then | |
4ed15f9d | 136 | cwd=`${PWDCMD}` |
c61a25b1 DM |
137 | # In case $dest is relative, get to $file's dir first. |
138 | cd ${INPUT} | |
139 | cd `echo ./$file | sed -n 's&[^/]*$&&p'` | |
140 | # Check that the target directory exists. | |
141 | # Redirections changed to avoid bug in sh on Ultrix. | |
142 | (cd $dest) > /dev/null 2>&1 | |
143 | if [ $? = 0 ]; then | |
144 | cd $dest | |
145 | # X gets the dir that the link actually leads to. | |
4ed15f9d | 146 | x=`${PWDCMD}` |
1ac7d389 RS |
147 | # If a link points to ., make a similar link to . |
148 | if [ $x = $INPUT ]; then | |
149 | echo $file '->' . ': Making link' | |
150 | rm -fr ${LIB}/$file > /dev/null 2>&1 | |
151 | ln -s . ${LIB}/$file > /dev/null 2>&1 | |
c61a25b1 DM |
152 | # If link leads back into ${INPUT}, |
153 | # make a similar link here. | |
1ac7d389 | 154 | elif expr $x : "${INPUT}/.*" > /dev/null; then |
c61a25b1 DM |
155 | # Y gets the actual target dir name, relative to ${INPUT}. |
156 | y=`echo $x | sed -n "s&${INPUT}/&&p"` | |
157 | echo $file '->' $y ': Making link' | |
158 | rm -fr ${LIB}/$file > /dev/null 2>&1 | |
159 | ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1 | |
160 | else | |
1ac7d389 RS |
161 | # If the link is to a dir $target outside ${INPUT}, |
162 | # repoint the link at ${INPUT}/root$target | |
163 | # and process $target into ${INPUT}/root$target | |
c61a25b1 | 164 | # treat this directory as if it actually contained the files. |
1ac7d389 RS |
165 | echo $file '->' root$x ': Making link' |
166 | if [ -d $LIB/root$x ] | |
167 | then true | |
168 | else | |
169 | dirname=root$x/ | |
170 | dirmade=. | |
171 | cd $LIB | |
172 | while [ x$dirname != x ]; do | |
173 | component=`echo $dirname | sed -e 's|/.*$||'` | |
174 | mkdir $component >/dev/null 2>&1 | |
175 | cd $component | |
176 | dirmade=$dirmade/$component | |
177 | dirname=`echo $dirname | sed -e 's|[^/]*/||'` | |
178 | done | |
179 | fi | |
180 | rm -fr ${LIB}/$file > /dev/null 2>&1 | |
181 | ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1 | |
182 | treetops="$treetops $x ${LIB}/root$x" | |
c61a25b1 DM |
183 | fi |
184 | fi | |
185 | cd $cwd | |
186 | fi | |
187 | done | |
188 | fi | |
189 | ||
190 | set - $treetops | |
191 | while [ $# != 0 ]; do | |
192 | # $1 is an old directory to copy, and $2 is the new directory to copy to. | |
c61a25b1 DM |
193 | cd ${INPUT} |
194 | cd $1 | |
1ac7d389 RS |
195 | # The same dir can appear more than once in treetops. |
196 | # There's no need to scan it more than once. | |
197 | if [ -f $2/DONE ] | |
198 | then | |
199 | files= | |
200 | else | |
201 | touch $2/DONE | |
202 | echo Fixing directory $1 into $2 | |
8c31e6b6 RS |
203 | # Check .h files which are symlinks as well as those which are files. |
204 | # A link to a header file will not be processed by anything but this. | |
73bdfabc RS |
205 | if $LINKS; then |
206 | files=`find . -name '*.h' \( -type f -o -type l \) -print` | |
207 | else | |
208 | files=`find . -name '*.h' -type f -print` | |
209 | fi | |
1ac7d389 RS |
210 | echo Checking header files |
211 | fi | |
c61a25b1 DM |
212 | # Note that BSD43_* are used on recent MIPS systems. |
213 | for file in $files; do | |
214 | # This call to egrep is essential, since checking a file with egrep | |
215 | # is much faster than actually trying to fix it. | |
3308e40a RS |
216 | # It is also essential that most files *not* match! |
217 | # Thus, matching every #endif is unacceptable. | |
c61a25b1 DM |
218 | # But the argument to egrep must be kept small, or many versions of egrep |
219 | # won't be able to handle it. | |
75251fe0 | 220 | # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail. |
ab94876e | 221 | if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then |
c61a25b1 DM |
222 | echo Fixing $file |
223 | if [ -r $file ]; then | |
224 | cp $file $2/$file >/dev/null 2>&1 \ | |
225 | || echo "Can't copy $file" | |
226 | chmod +w $2/$file | |
2e4cd151 | 227 | chmod a+r $2/$file |
75251fe0 DM |
228 | # Following two lines removed. |
229 | # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */% | |
230 | # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */% | |
231 | ||
c61a25b1 DM |
232 | sed -e ' |
233 | :loop | |
234 | /\\$/ N | |
235 | /\\$/ b loop | |
ab94876e | 236 | /\/\// s|//\(.*\)$|/*\1*/| |
c61a25b1 DM |
237 | /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ |
238 | /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ | |
e029fa05 | 239 | /#define._IO/ s/'\''x'\''/x/g |
c61a25b1 | 240 | /#define.BSD43__IO/ s/'\''x'\''/x/g |
e029fa05 | 241 | /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ |
c61a25b1 DM |
242 | /#define.CTRL/ s/'\''c'\''/c/g |
243 | /#define._CTRL/ s/'\''c'\''/c/g | |
244 | /#define.BSD43_CTRL/ s/'\''c'\''/c/g | |
e029fa05 | 245 | /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g |
c61a25b1 | 246 | /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g |
e029fa05 | 247 | /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g |
c61a25b1 DM |
248 | /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g |
249 | /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g | |
250 | /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g | |
251 | /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g | |
252 | /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g | |
253 | /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g | |
254 | /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g | |
255 | /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g | |
45b33951 | 256 | /^#define.NULL[ ]/ i\ |
c61a25b1 DM |
257 | #undef NULL |
258 | ' $2/$file > $2/$file.sed | |
259 | mv $2/$file.sed $2/$file | |
260 | if cmp $file $2/$file >/dev/null 2>&1; then | |
261 | echo Deleting $2/$file\; no fixes were needed. | |
262 | rm $2/$file | |
263 | fi | |
264 | fi | |
265 | fi | |
266 | done | |
267 | shift; shift | |
268 | done | |
269 | ||
270 | cd ${INPUT} | |
271 | ||
272 | # Fix one other error in this file: a mismatched quote not inside a C comment. | |
273 | file=sundev/vuid_event.h | |
274 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
275 | mkdir ${LIB}/sundev 2>/dev/null | |
276 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
277 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 278 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
279 | fi |
280 | ||
281 | if [ -r ${LIB}/$file ]; then | |
282 | echo Fixing $file comment | |
283 | ex ${LIB}/$file <<EOF | |
284 | g/doesn't/s/doesn't/does not/ | |
285 | wq | |
286 | EOF | |
287 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
288 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
289 | rm ${LIB}/$file | |
290 | fi | |
291 | fi | |
292 | ||
4ba0ff2d JW |
293 | # Fix these Sun OS files to avoid an invalid identifier in an #ifdef. |
294 | file=sunwindow/win_cursor.h | |
295 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
296 | # mkdir ${LIB}/sunwindow 2>/dev/null | |
297 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
298 | chmod +w ${LIB}/$file 2>/dev/null | |
299 | fi | |
300 | if [ -r ${LIB}/$file ]; then | |
301 | echo Fixing $file | |
302 | sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed | |
303 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
304 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
305 | rm ${LIB}/$file | |
306 | fi | |
307 | fi | |
308 | file=sunwindow/win_lock.h | |
309 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
310 | # mkdir ${LIB}/sunwindow 2>/dev/null | |
311 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
312 | chmod +w ${LIB}/$file 2>/dev/null | |
313 | fi | |
314 | if [ -r ${LIB}/$file ]; then | |
315 | echo Fixing $file | |
316 | sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed | |
317 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
318 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
319 | rm ${LIB}/$file | |
320 | fi | |
321 | fi | |
322 | ||
6dc42e49 | 323 | # Fix this Sun file to avoid interfering with stddef.h. |
c61a25b1 DM |
324 | file=sys/stdtypes.h |
325 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
326 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
327 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 328 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
329 | fi |
330 | ||
331 | if [ -r ${LIB}/$file ]; then | |
332 | echo Fixing $file | |
333 | ex ${LIB}/$file <<EOF | |
334 | /size_t.*;/ | |
335 | i | |
3308e40a RS |
336 | #ifndef _GCC_SIZE_T |
337 | #define _GCC_SIZE_T | |
c61a25b1 DM |
338 | . |
339 | /size_t/+1 | |
340 | i | |
341 | #endif | |
342 | . | |
343 | /ptrdiff_t.*;/ | |
344 | i | |
3308e40a RS |
345 | #ifndef _GCC_PTRDIFF_T |
346 | #define _GCC_PTRDIFF_T | |
c61a25b1 DM |
347 | . |
348 | /ptrdiff_t/+1 | |
349 | i | |
350 | #endif | |
351 | . | |
352 | /wchar_t.*;/ | |
353 | i | |
3308e40a RS |
354 | #ifndef _GCC_WCHAR_T |
355 | #define _GCC_WCHAR_T | |
c61a25b1 DM |
356 | . |
357 | /wchar_t/+1 | |
358 | i | |
359 | #endif | |
360 | . | |
361 | wq | |
362 | EOF | |
363 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
364 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
365 | rm ${LIB}/$file | |
366 | fi | |
367 | fi | |
368 | ||
fd9287ae JW |
369 | # Fix this file to avoid interfering with stddef.h, but don't mistakenly |
370 | # match e.g. ssize_t present in AIX for the ps/2. | |
c61a25b1 DM |
371 | file=sys/types.h |
372 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
373 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
374 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 375 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
376 | fi |
377 | ||
378 | if [ -r ${LIB}/$file ]; then | |
379 | echo Fixing $file | |
380 | ex ${LIB}/$file <<EOF | |
fd9287ae | 381 | /typedef.*[ ]size_t.*;/ |
c61a25b1 | 382 | i |
3308e40a RS |
383 | #ifndef _GCC_SIZE_T |
384 | #define _GCC_SIZE_T | |
c61a25b1 DM |
385 | . |
386 | /size_t/+1 | |
387 | i | |
388 | #endif | |
389 | . | |
390 | wq | |
391 | EOF | |
392 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
393 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
394 | rm ${LIB}/$file | |
395 | fi | |
396 | fi | |
397 | ||
08455880 TW |
398 | # Fix an error in this file: the #if says _cplusplus, not the double |
399 | # underscore __cplusplus that it should be | |
400 | file=tinfo.h | |
401 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
402 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
403 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
404 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 405 | chmod a+r ${LIB}/$file 2>/dev/null |
08455880 TW |
406 | fi |
407 | ||
408 | if [ -r ${LIB}/$file ]; then | |
409 | echo Fixing $file, __cplusplus macro | |
410 | sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed | |
411 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
412 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
413 | rm ${LIB}/$file | |
414 | fi | |
415 | fi | |
416 | ||
c61a25b1 DM |
417 | # Fix an error in this file: a missing semi-colon at the end of the statsswtch |
418 | # structure definition. | |
419 | file=rpcsvc/rstat.h | |
420 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
421 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
422 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
423 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 424 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
425 | fi |
426 | ||
427 | if [ -r ${LIB}/$file ]; then | |
428 | echo Fixing $file, definition of statsswtch | |
429 | ex ${LIB}/$file <<EOF | |
430 | g/boottime$/s//&;/ | |
431 | wq | |
432 | EOF | |
433 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
434 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
435 | rm ${LIB}/$file | |
436 | fi | |
437 | fi | |
438 | ||
439 | # Fix an error in this file: a missing semi-colon at the end of the nodeent | |
440 | # structure definition. | |
441 | file=netdnet/dnetdb.h | |
442 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
443 | mkdir ${LIB}/netdnet 2>/dev/null | |
444 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
445 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 446 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
447 | fi |
448 | ||
449 | if [ -r ${LIB}/$file ]; then | |
450 | echo Fixing $file, definition of nodeent | |
451 | ex ${LIB}/$file <<EOF | |
45b33951 | 452 | g/char.*na_addr *$/s//&;/ |
c61a25b1 DM |
453 | wq |
454 | EOF | |
455 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
456 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
457 | rm ${LIB}/$file | |
458 | fi | |
459 | fi | |
460 | ||
461 | # Check for bad #ifdef line (in Ultrix 4.1) | |
462 | file=sys/file.h | |
463 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
464 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
465 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 466 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
467 | fi |
468 | ||
469 | if [ -r ${LIB}/$file ]; then | |
470 | echo Fixing $file, bad \#ifdef line | |
471 | ex ${LIB}/$file <<EOF | |
472 | g/^#ifdef KERNEL && !defined/ | |
473 | s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/ | |
474 | wq | |
475 | EOF | |
476 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
477 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
478 | rm ${LIB}/$file | |
479 | fi | |
480 | fi | |
481 | ||
75251fe0 DM |
482 | # Remove nested comments created by #endifs in a comment (Ultrix 4.1) |
483 | # Only needed if commenting out junk after #endif. | |
484 | #file=signal.h | |
485 | #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
486 | # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
487 | # chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 488 | # chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
489 | #fi |
490 | # | |
491 | #if [ -r ${LIB}/$file ]; then | |
492 | # echo Fixing $file, nested comments | |
493 | # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed | |
494 | # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
495 | # if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
496 | # echo Deleting ${LIB}/$file\; no fixes were needed. | |
497 | # rm -f ${LIB}/$file | |
498 | # fi | |
499 | #fi | |
500 | ||
c61a25b1 DM |
501 | # Check for superfluous `static' (in Ultrix 4.2) |
502 | file=machine/cpu.h | |
503 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
504 | mkdir ${LIB}/machine 2>/dev/null | |
505 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
506 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 507 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
508 | fi |
509 | ||
510 | if [ -r ${LIB}/$file ]; then | |
511 | echo Fixing $file, superfluous static | |
512 | ex ${LIB}/$file <<EOF | |
513 | g/^static struct tlb_pid_state/ | |
514 | s/static// | |
515 | wq | |
516 | EOF | |
517 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
518 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
519 | rm ${LIB}/$file | |
520 | else | |
521 | # This file has an alternative name, mips/cpu.h. Fix that name, too. | |
522 | if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then | |
523 | mkdir ${LIB}/mips 2>&- | |
524 | ln ${LIB}/$file ${LIB}/mips/cpu.h | |
525 | fi | |
526 | fi | |
527 | fi | |
528 | ||
75251fe0 | 529 | # Incorrect sprintf declaration in X11/Xmu.h |
c61a25b1 DM |
530 | file=X11/Xmu.h |
531 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
532 | mkdir ${LIB}/X11 2>/dev/null | |
533 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
534 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 535 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
536 | fi |
537 | ||
538 | if [ -r ${LIB}/$file ]; then | |
539 | echo Fixing $file sprintf declaration | |
540 | ex ${LIB}/$file <<EOF | |
541 | /^extern char \* sprintf();$/c | |
542 | #ifndef __STDC__ | |
543 | extern char * sprintf(); | |
544 | #endif /* !defined __STDC__ */ | |
545 | . | |
546 | wq | |
547 | EOF | |
548 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
549 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
550 | rm ${LIB}/$file | |
551 | fi | |
552 | fi | |
553 | ||
3a6aca8e RS |
554 | # Incorrect sprintf declaration in X11/Xmu/Xmu.h |
555 | # (It's not clear whether the right file name is this or X11/Xmu.h.) | |
556 | file=X11/Xmu/Xmu.h | |
557 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
558 | mkdir ${LIB}/X11/Xmu 2>/dev/null | |
559 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
560 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 561 | chmod a+r ${LIB}/$file 2>/dev/null |
3a6aca8e RS |
562 | fi |
563 | ||
564 | if [ -r ${LIB}/$file ]; then | |
565 | echo Fixing $file sprintf declaration | |
566 | ex ${LIB}/$file <<EOF | |
567 | /^extern char \* sprintf();$/c | |
568 | #ifndef __STDC__ | |
569 | extern char * sprintf(); | |
570 | #endif /* !defined __STDC__ */ | |
571 | . | |
572 | wq | |
573 | EOF | |
574 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
575 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
576 | rm ${LIB}/$file | |
577 | fi | |
578 | fi | |
579 | ||
c61a25b1 DM |
580 | # Check for missing ';' in struct |
581 | file=netinet/ip.h | |
582 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
583 | mkdir ${LIB}/netinet 2>/dev/null | |
584 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
585 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 586 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
587 | fi |
588 | ||
589 | if [ -r ${LIB}/$file ]; then | |
590 | echo Fixing $file | |
591 | sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed | |
592 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
593 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
594 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
595 | rm -f ${LIB}/$file | |
596 | fi | |
597 | fi | |
598 | ||
75251fe0 | 599 | # Fix the CAT macro in SunOS memvar.h. |
c61a25b1 DM |
600 | file=pixrect/memvar.h |
601 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
602 | mkdir ${LIB}/pixrect 2>/dev/null | |
603 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
604 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 605 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
606 | fi |
607 | ||
608 | if [ -r ${LIB}/$file ]; then | |
609 | echo Fixing $file | |
610 | sed -e '/^#define.CAT(a,b)/ i\ | |
611 | #ifdef __STDC__ \ | |
612 | #define CAT(a,b) a##b\ | |
613 | #else | |
614 | /^#define.CAT(a,b)/ a\ | |
615 | #endif | |
616 | ' ${LIB}/$file > ${LIB}/${file}.sed | |
617 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
618 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
619 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
620 | rm -f ${LIB}/$file | |
621 | fi | |
622 | fi | |
623 | ||
624 | # Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
625 | file=rpcsvc/rusers.h | |
626 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
627 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
628 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
629 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 630 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
631 | fi |
632 | ||
633 | if [ -r ${LIB}/$file ]; then | |
634 | echo Fixing $file | |
635 | sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed | |
636 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
637 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
638 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
639 | rm -f ${LIB}/$file | |
640 | fi | |
641 | fi | |
642 | ||
643 | # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1. | |
644 | file=stdlib.h | |
645 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
646 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
647 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 648 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
649 | fi |
650 | ||
651 | if [ -r ${LIB}/$file ]; then | |
652 | echo Fixing $file | |
653 | sed -e 's/int abort/void abort/g' \ | |
25f75d8a RS |
654 | -e 's/int free/void free/g' \ |
655 | -e 's/char \* calloc/void \* calloc/g' \ | |
656 | -e 's/char \* malloc/void \* malloc/g' \ | |
657 | -e 's/char \* realloc/void \* realloc/g' \ | |
c61a25b1 DM |
658 | -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed |
659 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
660 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
661 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
662 | rm -f ${LIB}/$file | |
663 | fi | |
664 | fi | |
665 | ||
460d7c18 TG |
666 | # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. |
667 | file=malloc.h | |
668 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
669 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
670 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 671 | chmod a+r ${LIB}/$file 2>/dev/null |
460d7c18 TG |
672 | fi |
673 | ||
674 | if [ -r ${LIB}/$file ]; then | |
675 | echo Fixing $file | |
350027ec | 676 | sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \ |
12fe670b | 677 | -e 's/int[ ][ ]*free/void free/g' \ |
460d7c18 TG |
678 | ${LIB}/$file > ${LIB}/${file}.sed |
679 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
680 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
681 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
682 | rm -f ${LIB}/$file | |
683 | fi | |
684 | fi | |
685 | ||
686 | ||
c61a25b1 DM |
687 | # Fix bogus comment in <locale.h> on SunOS 4.1. |
688 | file=locale.h | |
689 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
690 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
691 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 692 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
693 | fi |
694 | ||
695 | if [ -r ${LIB}/$file ]; then | |
696 | echo Fixing $file | |
697 | sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed | |
698 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
699 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
700 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
701 | rm -f ${LIB}/$file | |
702 | fi | |
703 | fi | |
704 | ||
705 | # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1. | |
706 | file=hsfs/hsfs_spec.h | |
707 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
708 | mkdir ${LIB}/hsfs 2>/dev/null | |
709 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
710 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 711 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
712 | fi |
713 | ||
714 | if [ -r ${LIB}/$file ]; then | |
715 | echo Fixing $file | |
716 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
717 | ${LIB}/$file > ${LIB}/${file}.sed | |
718 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
719 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
720 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
721 | rm -f ${LIB}/$file | |
722 | fi | |
723 | fi | |
724 | ||
725 | # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1. | |
726 | file=hsfs/hsnode.h | |
727 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
728 | mkdir ${LIB}/hsfs 2>/dev/null | |
729 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
730 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 731 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
732 | fi |
733 | ||
734 | if [ -r ${LIB}/$file ]; then | |
735 | echo Fixing $file | |
736 | sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \ | |
737 | ${LIB}/$file > ${LIB}/${file}.sed | |
738 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
739 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
740 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
741 | rm -f ${LIB}/$file | |
742 | fi | |
743 | fi | |
744 | ||
745 | # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1. | |
746 | file=hsfs/iso_spec.h | |
747 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
748 | mkdir ${LIB}/hsfs 2>/dev/null | |
749 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
750 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 751 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
752 | fi |
753 | ||
754 | if [ -r ${LIB}/$file ]; then | |
755 | echo Fixing $file | |
756 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
757 | ${LIB}/$file > ${LIB}/${file}.sed | |
758 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
759 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
760 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
761 | rm -f ${LIB}/$file | |
762 | fi | |
763 | fi | |
764 | ||
75251fe0 DM |
765 | # Incorrect #include in Sony News-OS 3.2. |
766 | file=machine/machparam.h | |
767 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
768 | mkdir ${LIB}/machine 2>/dev/null | |
769 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
770 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 771 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
772 | fi |
773 | ||
774 | if [ -r ${LIB}/$file ]; then | |
775 | echo Fixing $file, incorrect \#include | |
776 | sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \ | |
777 | ${LIB}/$file > ${LIB}/${file}.sed | |
778 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
779 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
780 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
781 | rm -f ${LIB}/$file | |
782 | fi | |
783 | fi | |
784 | ||
785 | # Multiline comment after typedef on IRIX 4.0.1. | |
786 | file=sys/types.h | |
787 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
788 | mkdir ${LIB}/sys 2>/dev/null | |
789 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
790 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 791 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
792 | fi |
793 | ||
794 | if [ -r ${LIB}/$file ]; then | |
795 | echo Fixing $file, comment in the middle of \#ifdef | |
796 | sed -e 's@type of the result@type of the result */@' \ | |
797 | -e 's@of the sizeof@/* of the sizeof@' \ | |
798 | ${LIB}/$file > ${LIB}/${file}.sed | |
799 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
800 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
801 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
802 | rm -f ${LIB}/$file | |
803 | fi | |
804 | fi | |
805 | ||
4d449554 JW |
806 | # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin |
807 | # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
808 | # many other systems have similar text but correct versions of the file. | |
809 | # To ensure only Sun's is fixed, we grep for a likely unique string. | |
810 | file=memory.h | |
8c31e6b6 | 811 | if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then |
4d449554 JW |
812 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
813 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
814 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 815 | chmod a+r ${LIB}/$file 2>/dev/null |
4d449554 JW |
816 | fi |
817 | if [ -r ${LIB}/$file ]; then | |
818 | echo Replacing $file | |
819 | cat > ${LIB}/$file << EOF | |
820 | /* This file was generated by fixincludes */ | |
821 | #ifndef __memory_h__ | |
822 | #define __memory_h__ | |
823 | ||
824 | #ifdef __STDC__ | |
825 | extern void *memccpy(); | |
826 | extern void *memchr(); | |
827 | extern void *memcpy(); | |
828 | extern void *memset(); | |
829 | #else | |
830 | extern char *memccpy(); | |
831 | extern char *memchr(); | |
832 | extern char *memcpy(); | |
833 | extern char *memset(); | |
834 | #endif /* __STDC__ */ | |
835 | ||
836 | extern int memcmp(); | |
837 | ||
838 | #endif __memory_h__ | |
839 | EOF | |
840 | fi | |
841 | fi | |
842 | ||
7d349561 JW |
843 | # parameters not const on DECstation Ultrix V4.0. |
844 | file=stdio.h | |
845 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
846 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
847 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 848 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
849 | fi |
850 | ||
851 | if [ -r ${LIB}/$file ]; then | |
852 | echo Fixing $file, non-const arg | |
853 | sed -e 's@perror( char \*__s );@perror( const char *__s );@' \ | |
854 | -e 's@fputs( char \*__s,@fputs( const char *__s,@' \ | |
855 | -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \ | |
856 | -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \ | |
857 | -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \ | |
858 | -e 's@scanf( char \*__format,@scanf( const char *__format,@' \ | |
859 | -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \ | |
860 | ${LIB}/$file > ${LIB}/${file}.sed | |
861 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
862 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
863 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
864 | rm -f ${LIB}/$file | |
865 | fi | |
866 | fi | |
867 | ||
1ac7d389 RS |
868 | # Don't use or define the name va_list in stdio.h. |
869 | # This is for ANSI and also to interoperate properly with gvarargs.h. | |
870 | file=stdio.h | |
871 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
872 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
873 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 874 | chmod a+r ${LIB}/$file 2>/dev/null |
1ac7d389 RS |
875 | fi |
876 | ||
877 | if [ -r ${LIB}/$file ]; then | |
878 | echo Fixing $file, use of va_list | |
879 | # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list | |
880 | (echo "#define __need___va_list" | |
881 | echo "#include <stdarg.h>") > ${LIB}/${file}.sed | |
882 | # Use __gnuc_va_list in arg types in place of va_list. | |
883 | # Define __va_list__ (something harmless and unused) instead of va_list. | |
884 | # Don't claim to have defined va_list. | |
885 | sed -e 's@ va_list @ __gnuc_va_list @' \ | |
886 | -e 's@ va_list@ __va_list__@' \ | |
be71bebd | 887 | -e 's@\*va_list@*__va_list__@' \ |
1ac7d389 RS |
888 | -e 's@VA_LIST@DUMMY_VA_LIST@' \ |
889 | ${LIB}/$file >> ${LIB}/${file}.sed | |
890 | ||
891 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
892 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
893 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
894 | rm -f ${LIB}/$file | |
895 | fi | |
896 | fi | |
897 | ||
e63c1d35 RS |
898 | # Cancel out ansi_compat.h on Ultrix. Replace it with empty file. |
899 | file=ansi_compat.h | |
900 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
901 | if grep -s ULTRIX $file; then | |
902 | echo "/* This file intentionally left blank. */" > $LIB/$file | |
903 | fi | |
904 | fi | |
905 | ||
7d349561 | 906 | # parameter to atof not const on DECstation Ultrix V4.0. |
28bbe06b | 907 | # also get rid of bogus inline definitions in HP-UX 8.0 |
7d349561 JW |
908 | file=math.h |
909 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
910 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
911 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 912 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
913 | fi |
914 | ||
915 | if [ -r ${LIB}/$file ]; then | |
916 | echo Fixing $file, non-const arg | |
917 | sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \ | |
28bbe06b RS |
918 | -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \ |
919 | -e 's@inline double abs(double d) { return fabs(d); }@@' \ | |
7d349561 JW |
920 | ${LIB}/$file > ${LIB}/${file}.sed |
921 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
922 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
923 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
924 | rm -f ${LIB}/$file | |
925 | fi | |
926 | fi | |
927 | ||
5959a6cd RS |
928 | # These two files on SunOS 4 are included by other files |
929 | # in the same directory, using "...". So we must make sure they exist | |
cd10f7b6 RS |
930 | # in the same directory as the other fixed files. |
931 | if [ -r ${INPUT}/multimedia/audio_errno.h ] | |
5959a6cd | 932 | then |
cd10f7b6 | 933 | ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null |
5959a6cd | 934 | fi |
cd10f7b6 | 935 | if [ -r ${INPUT}/multimedia/audio_hdr.h ] |
5959a6cd | 936 | then |
cd10f7b6 | 937 | ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null |
5959a6cd RS |
938 | fi |
939 | ||
c61a25b1 DM |
940 | echo 'Removing unneeded directories:' |
941 | cd $LIB | |
942 | files=`find . -type d -print | sort -r` | |
943 | for file in $files; do | |
944 | rmdir $LIB/$file > /dev/null 2>&1 | |
945 | done | |
946 | ||
947 | if $LINKS; then | |
948 | echo 'Making internal symbolic non-directory links' | |
949 | cd ${INPUT} | |
950 | files=`find . -type l -print` | |
951 | for file in $files; do | |
952 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
953 | if expr "$dest" : '[^/].*' > /dev/null; then | |
954 | target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` | |
955 | if [ -f $target ]; then | |
956 | ln -s $dest ${LIB}/$file >/dev/null 2>&1 | |
957 | fi | |
958 | fi | |
959 | done | |
960 | fi | |
961 | ||
962 | exit 0 |