(all output patterns): Use new capabilities of arm_print_operand to
[official-gcc.git] / gcc / fixincludes
blobab4a73ca732bc13bb84927fd8d7d9afe32538fc0
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.
6 # See README-fixinc for more information.
8 # Directory containing the original header files.
9 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
10 INPUT=${2-${INPUT-/usr/include}}
12 # Directory in which to store the results.
13 LIB=${1?"fixincludes: output directory not specified"}
15 # Define PWDCMD as a command to use to get the working dir
16 # in the form that we want.
17 PWDCMD=pwd
18 case "`pwd`" in
19 //*)
20 # On an Apollo, discard everything before `/usr'.
21 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
23 esac
25 # Original directory.
26 ORIGDIR=`${PWDCMD}`
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
30 mkdir $LIB || exit 1
33 # Make LIB absolute only if needed to avoid problems with the amd.
34 case $LIB in
35 /*)
38 cd $LIB; LIB=`${PWDCMD}`
40 esac
42 # Fail if no arg to specify a directory for the output.
43 if [ x$1 = x ]
44 then echo fixincludes: no output directory specified
45 exit 1
48 echo Building fixed headers in ${LIB}
50 # Determine whether this system has symbolic links.
51 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
52 rm -f $LIB/ShouldNotExist
53 LINKS=true
54 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
55 rm -f /tmp/ShouldNotExist
56 LINKS=true
57 else
58 LINKS=false
61 echo Finding directories and links to directories
62 cd ${INPUT}
63 # Find all directories and all symlinks that point to directories.
64 # Put the list in $files.
65 # Each time we find a symlink, add it to newdirs
66 # so that we do another find within the dir the link points to.
67 # Note that $files may have duplicates in it;
68 # later parts of this file are supposed to ignore them.
69 dirs="."
70 levels=2
71 while [ -n "$dirs" ] && [ $levels -gt 0 ]
73 levels=`expr $levels - 1`
74 newdirs=
75 for d in $dirs
77 echo " Searching $INPUT/$d"
78 if [ "$d" != . ]
79 then
80 d=$d/.
83 # Find all directories under $d, relative to $d, excluding $d itself.
84 files="$files `find $d -type d -print | \
85 sed -e '/\/\.$/d' -e '/^\.$/d'`"
86 # Find all links to directories.
87 # Using `-exec test -d' in find fails on some systems,
88 # and trying to run test via sh fails on others,
89 # so this is the simplest alternative left.
90 # First find all the links, then test each one.
91 theselinks=
92 $LINKS && \
93 theselinks=`find $d -type l -print`
94 for d1 in $theselinks --dummy--
96 # If the link points to a directory,
97 # add that dir to $newdirs
98 if [ -d $d1 ]
99 then
100 files="$files $d1"
101 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
102 then
103 newdirs="$newdirs $d1"
106 done
107 done
109 dirs="$newdirs"
110 done
112 dirs=
113 echo "All directories (including links to directories):"
114 echo $files
116 for file in $files; do
117 rm -rf $LIB/$file
118 if [ ! -d $LIB/$file ]
119 then mkdir $LIB/$file
121 done
122 mkdir $LIB/root
124 # treetops gets an alternating list
125 # of old directories to copy
126 # and the new directories to copy to.
127 treetops="${INPUT} ${LIB}"
129 if $LINKS; then
130 echo 'Making symbolic directory links'
131 for file in $files; do
132 dest=`ls -ld $file | sed -n 's/.*-> //p'`
133 if [ "$dest" ]; then
134 cwd=`${PWDCMD}`
135 # In case $dest is relative, get to $file's dir first.
136 cd ${INPUT}
137 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
138 # Check that the target directory exists.
139 # Redirections changed to avoid bug in sh on Ultrix.
140 (cd $dest) > /dev/null 2>&1
141 if [ $? = 0 ]; then
142 cd $dest
143 # X gets the dir that the link actually leads to.
144 x=`${PWDCMD}`
145 # If a link points to ., make a similar link to .
146 if [ $x = $INPUT ]; then
147 echo $file '->' . ': Making link'
148 rm -fr ${LIB}/$file > /dev/null 2>&1
149 ln -s . ${LIB}/$file > /dev/null 2>&1
150 # If link leads back into ${INPUT},
151 # make a similar link here.
152 elif expr $x : "${INPUT}/.*" > /dev/null; then
153 # Y gets the actual target dir name, relative to ${INPUT}.
154 y=`echo $x | sed -n "s&${INPUT}/&&p"`
155 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
156 dots=`echo "$file" |
157 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
158 echo $file '->' $dots$y ': Making link'
159 rm -fr ${LIB}/$file > /dev/null 2>&1
160 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
161 else
162 # If the link is to a dir $target outside ${INPUT},
163 # repoint the link at ${INPUT}/root$target
164 # and process $target into ${INPUT}/root$target
165 # treat this directory as if it actually contained the files.
166 echo $file '->' root$x ': Making link'
167 if [ -d $LIB/root$x ]
168 then true
169 else
170 dirname=root$x/
171 dirmade=.
172 cd $LIB
173 while [ x$dirname != x ]; do
174 component=`echo $dirname | sed -e 's|/.*$||'`
175 mkdir $component >/dev/null 2>&1
176 cd $component
177 dirmade=$dirmade/$component
178 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
179 done
181 # Duplicate directory structure created in ${LIB}/$file in new
182 # root area.
183 for file2 in $files; do
184 case $file2 in
185 $file/./*)
186 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
187 echo "Duplicating ${file}'s ${dupdir}"
188 if [ -d ${dupdir} ]
189 then true
190 else
191 mkdir ${dupdir}
196 esac
197 done
198 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
199 dots=`echo "$file" |
200 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
201 rm -fr ${LIB}/$file > /dev/null 2>&1
202 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
203 treetops="$treetops $x ${LIB}/root$x"
206 cd $cwd
208 done
211 required=
212 set x $treetops
213 shift
214 while [ $# != 0 ]; do
215 # $1 is an old directory to copy, and $2 is the new directory to copy to.
216 cd ${INPUT}
217 cd $1
218 # The same dir can appear more than once in treetops.
219 # There's no need to scan it more than once.
220 if [ -f $2/DONE ]
221 then
222 files=
223 else
224 touch $2/DONE
225 echo Fixing directory $1 into $2
226 # Check .h files which are symlinks as well as those which are files.
227 # A link to a header file will not be processed by anything but this.
228 if $LINKS; then
229 files=`find . -name '*.h' \( -type f -o -type l \) -print`
230 else
231 files=`find . -name '*.h' -type f -print`
233 echo Checking header files
235 # Note that BSD43_* are used on recent MIPS systems.
236 for file in $files; do
237 # This call to egrep is essential, since checking a file with egrep
238 # is much faster than actually trying to fix it.
239 # It is also essential that most files *not* match!
240 # Thus, matching every #endif is unacceptable.
241 # But the argument to egrep must be kept small, or many versions of egrep
242 # won't be able to handle it.
244 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
245 # following #else or #endif because some buggy egreps think [^/] matches
246 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
248 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
249 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
250 # in this pattern lacks `d' and `l'; this means we don't worry about
251 # identifiers starting with `d' or `l'. This is OK, since none of the
252 # identifiers below start with `d' or `l'. It also greatly improves
253 # performance, since many files contain lines of the form `#if ... defined ...'
254 # or `#if lint'.
255 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
256 if [ -r $file ]; then
257 cp $file $2/$file >/dev/null 2>&1 \
258 || echo "Can't copy $file"
259 chmod +w $2/$file
260 chmod a+r $2/$file
261 # Here is how the sed commands in braces work.
262 # (It doesn't work to put the comments inside the sed commands.)
263 # Surround each word with spaces, to simplify matching below.
264 # ANSIfy each pre-ANSI machine-dependent symbol
265 # by surrounding it with __ __.
266 # Remove the spaces that we inserted around each word.
267 sed -e '
268 :loop
269 /\\$/ N
270 /\\$/ b loop
271 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
272 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
273 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
274 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
275 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
276 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
277 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
278 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
279 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
280 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
281 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
282 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
283 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
284 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
285 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
286 /#[el]*if/{
287 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
289 s/ bsd4\([0-9]\) / __bsd4\1__ /g
290 s/ _*host_mips / __host_mips__ /g
291 s/ _*i386 / __i386__ /g
292 s/ M32 / __M32__ /g
293 s/ is68k / __is68k__ /g
294 s/ m68k / __m68k__ /g
295 s/ mc680\([0-9]\)0 / __mc680\10__ /g
296 s/ m88k / __m88k__ /g
297 s/ _*mips / __mips__ /g
298 s/ news\([0-9]*\) / __news\1__ /g
299 s/ ns32000 / __ns32000__ /g
300 s/ pdp11 / __pdp11__ /g
301 s/ pyr / __pyr__ /g
302 s/ sony_news / __sony_news__ /g
303 s/ sparc / __sparc__ /g
304 s/ sun\([a-z0-9]*\) / __sun\1__ /g
305 s/ tower\([_0-9]*\) / __tower\1__ /g
306 s/ u370 / __u370__ /g
307 s/ u3b\([0-9]*\) / __u3b\1__ /g
308 s/ unix / __unix__ /g
309 s/ vax / __vax__ /g
310 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
311 s/ _*R\([34]\)000 / __R\1000__ /g
312 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
314 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
316 /^#define.NULL[ ]/ i\
317 #undef NULL
318 ' $2/$file > $2/$file.
319 mv $2/$file. $2/$file
320 if cmp $file $2/$file >/dev/null 2>&1; then
321 rm $2/$file
322 else
323 echo Fixed $file
324 # Find any include directives that use "file".
325 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
326 dir=`echo $file | sed -e s'|/[^/]*$||'`
327 required="$required $1 $dir/$include $2/$dir/$include"
328 done
332 done
333 shift; shift
334 done
336 cd ${INPUT}
338 # Install the proper definition of the three standard types in header files
339 # that they come from.
340 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
341 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
342 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
343 chmod +w ${LIB}/$file 2>/dev/null
344 chmod a+r ${LIB}/$file 2>/dev/null
347 if [ -r ${LIB}/$file ]; then
348 echo Fixing size_t, ptrdiff_t and wchar_t in $file
349 sed \
350 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
351 #ifndef __SIZE_TYPE__\
352 #define __SIZE_TYPE__ long unsigned int\
353 #endif
355 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
356 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
357 #ifndef __PTRDIFF_TYPE__\
358 #define __PTRDIFF_TYPE__ long int\
359 #endif
361 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
362 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
363 #ifndef __WCHAR_TYPE__\
364 #define __WCHAR_TYPE__ int\
365 #endif
367 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
368 ${LIB}/$file > ${LIB}/${file}.sed
369 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
370 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
371 rm ${LIB}/$file
374 done
376 # Fix one other error in this file: a mismatched quote not inside a C comment.
377 file=sundev/vuid_event.h
378 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
379 mkdir ${LIB}/sundev 2>/dev/null
380 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
381 chmod +w ${LIB}/$file 2>/dev/null
382 chmod a+r ${LIB}/$file 2>/dev/null
385 if [ -r ${LIB}/$file ]; then
386 echo Fixing $file comment
387 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
388 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
389 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
390 rm ${LIB}/$file
394 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
395 file=sunwindow/win_cursor.h
396 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
397 # mkdir ${LIB}/sunwindow 2>/dev/null
398 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
399 chmod +w ${LIB}/$file 2>/dev/null
401 if [ -r ${LIB}/$file ]; then
402 echo Fixing $file
403 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
404 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
405 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
406 rm ${LIB}/$file
409 file=sunwindow/win_lock.h
410 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
411 # mkdir ${LIB}/sunwindow 2>/dev/null
412 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
413 chmod +w ${LIB}/$file 2>/dev/null
415 if [ -r ${LIB}/$file ]; then
416 echo Fixing $file
417 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
418 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
419 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
420 rm ${LIB}/$file
424 # Fix this Sun file to avoid interfering with stddef.h.
425 file=sys/stdtypes.h
426 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
427 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
428 chmod +w ${LIB}/$file 2>/dev/null
429 chmod a+r ${LIB}/$file 2>/dev/null
432 if [ -r ${LIB}/$file ]; then
433 echo Fixing $file
434 sed -e '/[ ]size_t.*;/i\
435 #ifndef _GCC_SIZE_T\
436 #define _GCC_SIZE_T
438 -e '/[ ]size_t.*;/a\
439 #endif
441 -e '/[ ]ptrdiff_t.*;/i\
442 #ifndef _GCC_PTRDIFF_T\
443 #define _GCC_PTRDIFF_T
445 -e '/[ ]ptrdiff_t.*;/a\
446 #endif
448 -e '/[ ]wchar_t.*;/i\
449 #ifndef _GCC_WCHAR_T\
450 #define _GCC_WCHAR_T
452 -e '/[ ]wchar_t.*;/a\
453 #endif
454 ' ${LIB}/$file > ${LIB}/${file}.sed
455 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
456 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
457 rm ${LIB}/$file
461 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
462 # in cc1plus.
463 file=stdlib.h
464 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
465 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
466 chmod +w ${LIB}/$file 2>/dev/null
467 chmod a+r ${LIB}/$file 2>/dev/null
470 if [ -r ${LIB}/$file ]; then
471 echo Fixing $file
472 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
473 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
474 ${LIB}/$file > ${LIB}/${file}.sed
475 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
476 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
477 rm ${LIB}/$file
481 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
482 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
483 # set) size_t.
484 file=sys/types.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
488 chmod a+r ${LIB}/$file 2>/dev/null
491 if [ -r ${LIB}/$file ]; then
492 echo Fixing $file
493 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
494 #ifndef _GCC_SIZE_T\
495 #define _GCC_SIZE_T
497 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
498 #endif
499 ' ${LIB}/$file > ${LIB}/${file}.sed
500 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
501 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
502 rm ${LIB}/$file
506 # Fix HP's use of ../machine/inline.h to refer to
507 # /usr/include/machine/inline.h
508 file=sys/spinlock.h
509 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
510 cp $file ${LIB}/$file
512 if [ -r ${LIB}/$file ] ; then
513 echo Fixing $file
514 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
515 -e 's,"../machine/psl.h",<machine/psl.h>,' \
516 ${LIB}/$file > ${LIB}/${file}.sed
517 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
518 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
519 rm ${LIB}/$file
523 # Fix an error in this file: the #if says _cplusplus, not the double
524 # underscore __cplusplus that it should be
525 file=tinfo.h
526 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
527 mkdir ${LIB}/rpcsvc 2>/dev/null
528 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
529 chmod +w ${LIB}/$file 2>/dev/null
530 chmod a+r ${LIB}/$file 2>/dev/null
533 if [ -r ${LIB}/$file ]; then
534 echo Fixing $file, __cplusplus macro
535 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
536 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
537 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
538 rm ${LIB}/$file
542 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
543 # structure definition.
544 file=rpcsvc/rstat.h
545 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
546 mkdir ${LIB}/rpcsvc 2>/dev/null
547 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
548 chmod +w ${LIB}/$file 2>/dev/null
549 chmod a+r ${LIB}/$file 2>/dev/null
552 if [ -r ${LIB}/$file ]; then
553 echo Fixing $file, definition of statsswtch
554 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
555 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
556 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
557 rm ${LIB}/$file
561 # Fix an error in this file: a missing semi-colon at the end of the nodeent
562 # structure definition.
563 file=netdnet/dnetdb.h
564 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
565 mkdir ${LIB}/netdnet 2>/dev/null
566 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
567 chmod +w ${LIB}/$file 2>/dev/null
568 chmod a+r ${LIB}/$file 2>/dev/null
571 if [ -r ${LIB}/$file ]; then
572 echo Fixing $file, definition of nodeent
573 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
574 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
575 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
576 rm ${LIB}/$file
580 # Check for bad #ifdef line (in Ultrix 4.1)
581 file=sys/file.h
582 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
583 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
584 chmod +w ${LIB}/$file 2>/dev/null
585 chmod a+r ${LIB}/$file 2>/dev/null
588 if [ -r ${LIB}/$file ]; then
589 echo Fixing $file, bad \#ifdef line
590 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
591 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
592 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
593 rm ${LIB}/$file
597 # Check for superfluous `static' (in Ultrix 4.2)
598 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
599 file=machine/cpu.h
600 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
601 mkdir ${LIB}/machine 2>/dev/null
602 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
603 chmod +w ${LIB}/$file 2>/dev/null
604 chmod a+r ${LIB}/$file 2>/dev/null
607 if [ -r ${LIB}/$file ]; then
608 echo Fixing $file, superfluous static and broken includes of other files.
609 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
610 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
611 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
612 ${LIB}/$file > ${LIB}/${file}.sed
613 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
614 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
615 rm ${LIB}/$file
616 else
617 # This file has an alternative name, mips/cpu.h. Fix that name, too.
618 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
619 mkdir ${LIB}/mips 2>&-
620 # Don't remove the file first, they may be the same file!
621 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
626 # Incorrect sprintf declaration in X11/Xmu.h
627 file=X11/Xmu.h
628 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
629 mkdir ${LIB}/X11 2>/dev/null
630 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
631 chmod +w ${LIB}/$file 2>/dev/null
632 chmod a+r ${LIB}/$file 2>/dev/null
635 if [ -r ${LIB}/$file ]; then
636 echo Fixing $file sprintf declaration
637 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
638 extern char * sprintf();\
639 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
640 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
641 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
642 rm ${LIB}/$file
646 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
647 # (It's not clear whether the right file name is this or X11/Xmu.h.)
648 file=X11/Xmu/Xmu.h
649 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
650 mkdir ${LIB}/X11/Xmu 2>/dev/null
651 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
652 chmod +w ${LIB}/$file 2>/dev/null
653 chmod a+r ${LIB}/$file 2>/dev/null
656 if [ -r ${LIB}/$file ]; then
657 echo Fixing $file sprintf declaration
658 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
659 extern char * sprintf();\
660 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
661 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
662 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
663 rm ${LIB}/$file
667 # Check for missing ';' in struct
668 file=netinet/ip.h
669 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
670 mkdir ${LIB}/netinet 2>/dev/null
671 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
672 chmod +w ${LIB}/$file 2>/dev/null
673 chmod a+r ${LIB}/$file 2>/dev/null
676 if [ -r ${LIB}/$file ]; then
677 echo Fixing $file
678 sed -e '/^struct/,/^};/s/}$/};/' ${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 rm -f ${LIB}/$file
685 # Fix the CAT macro in SunOS memvar.h.
686 file=pixrect/memvar.h
687 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
688 mkdir ${LIB}/pixrect 2>/dev/null
689 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
690 chmod +w ${LIB}/$file 2>/dev/null
691 chmod a+r ${LIB}/$file 2>/dev/null
694 if [ -r ${LIB}/$file ]; then
695 echo Fixing $file
696 sed -e '/^#define.CAT(a,b)/ i\
697 #ifdef __STDC__ \
698 #define CAT(a,b) a##b\
699 #else
700 /^#define.CAT(a,b)/ a\
701 #endif
702 ' ${LIB}/$file > ${LIB}/${file}.sed
703 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
704 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
705 rm -f ${LIB}/$file
709 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
710 file=rpcsvc/rusers.h
711 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
712 mkdir ${LIB}/rpcsvc 2>/dev/null
713 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
714 chmod +w ${LIB}/$file 2>/dev/null
715 chmod a+r ${LIB}/$file 2>/dev/null
718 if [ -r ${LIB}/$file ]; then
719 echo Fixing $file
720 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
721 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
722 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
723 rm -f ${LIB}/$file
727 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
728 # Also wrap protection around size_t for m88k-sysv3 systems.
729 file=stdlib.h
730 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
731 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
732 chmod +w ${LIB}/$file 2>/dev/null
733 chmod a+r ${LIB}/$file 2>/dev/null
736 if [ -r ${LIB}/$file ]; then
737 echo Fixing $file
738 sed -e 's/int abort/void abort/g' \
739 -e 's/int free/void free/g' \
740 -e 's/char \* calloc/void \* calloc/g' \
741 -e 's/char \* malloc/void \* malloc/g' \
742 -e 's/char \* realloc/void \* realloc/g' \
743 -e 's/int exit/void exit/g' \
744 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
745 #ifndef _GCC_SIZE_T\
746 #define _GCC_SIZE_T
748 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
749 #endif
751 ${LIB}/$file > ${LIB}/${file}.sed
752 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
753 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
754 rm -f ${LIB}/$file
758 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
759 file=malloc.h
760 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
761 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
762 chmod +w ${LIB}/$file 2>/dev/null
763 chmod a+r ${LIB}/$file 2>/dev/null
766 if [ -r ${LIB}/$file ]; then
767 echo Fixing $file
768 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
769 -e 's/int[ ][ ]*free/void free/g' \
770 ${LIB}/$file > ${LIB}/${file}.sed
771 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
772 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
773 rm -f ${LIB}/$file
777 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
778 file=hsfs/hsfs_spec.h
779 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
780 mkdir ${LIB}/hsfs 2>/dev/null
781 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
782 chmod +w ${LIB}/$file 2>/dev/null
783 chmod a+r ${LIB}/$file 2>/dev/null
786 if [ -r ${LIB}/$file ]; then
787 echo Fixing $file
788 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
789 ${LIB}/$file > ${LIB}/${file}.
790 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
791 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
792 rm -f ${LIB}/$file
796 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
797 file=hsfs/hsnode.h
798 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
799 mkdir ${LIB}/hsfs 2>/dev/null
800 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
801 chmod +w ${LIB}/$file 2>/dev/null
802 chmod a+r ${LIB}/$file 2>/dev/null
805 if [ -r ${LIB}/$file ]; then
806 echo Fixing $file
807 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
808 ${LIB}/$file > ${LIB}/${file}.sed
809 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
810 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
811 rm -f ${LIB}/$file
815 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
816 file=hsfs/iso_spec.h
817 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
818 mkdir ${LIB}/hsfs 2>/dev/null
819 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
820 chmod +w ${LIB}/$file 2>/dev/null
821 chmod a+r ${LIB}/$file 2>/dev/null
824 if [ -r ${LIB}/$file ]; then
825 echo Fixing $file
826 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
827 ${LIB}/$file > ${LIB}/${file}.sed
828 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
829 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
830 rm -f ${LIB}/$file
834 # Incorrect #include in Sony News-OS 3.2.
835 file=machine/machparam.h
836 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
837 mkdir ${LIB}/machine 2>/dev/null
838 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
839 chmod +w ${LIB}/$file 2>/dev/null
840 chmod a+r ${LIB}/$file 2>/dev/null
843 if [ -r ${LIB}/$file ]; then
844 echo Fixing $file, incorrect \#include
845 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
846 ${LIB}/$file > ${LIB}/${file}.
847 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
848 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
849 rm -f ${LIB}/$file
853 # Multiline comment after typedef on IRIX 4.0.1.
854 file=sys/types.h
855 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
856 mkdir ${LIB}/sys 2>/dev/null
857 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
858 chmod +w ${LIB}/$file 2>/dev/null
859 chmod a+r ${LIB}/$file 2>/dev/null
862 if [ -r ${LIB}/$file ]; then
863 echo Fixing $file, comment in the middle of \#ifdef
864 sed -e 's@type of the result@type of the result */@' \
865 -e 's@of the sizeof@/* of the sizeof@' \
866 ${LIB}/$file > ${LIB}/${file}.sed
867 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
868 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
869 rm -f ${LIB}/$file
873 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
874 # header file, which embeds // comments inside multi-line /* */
875 # comments. If this looks like the IRIX header file, we refix it by
876 # just throwing away the // comments.
877 file=fam.h
878 if [ -r ${LIB}/$file ]; then
879 if egrep indigo.esd ${LIB}/$file > /dev/null; then
880 echo Fixing $file, overeager sed script
881 rm ${LIB}/$file
882 sed -e 's|//.*$||g' $file > ${LIB}/$file
883 chmod +w ${LIB}/$file 2>/dev/null
884 chmod a+r ${LIB}/$file 2>/dev/null
888 # Some IRIX header files contains the string "//"
889 for file in elf_abi.h elf.h; do
890 if [ -r ${LIB}/$file ]; then
891 echo Fixing $file, overeager sed script
892 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
893 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
894 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
895 rm -f ${LIB}/$file
898 done
900 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
901 # previous definition.
902 file=rpc/auth.h
903 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
904 mkdir ${LIB}/rpc 2>/dev/null
905 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
906 chmod +w ${LIB}/$file 2>/dev/null
907 chmod a+r ${LIB}/$file 2>/dev/null
910 if [ -r ${LIB}/$file ]; then
911 echo Fixing $file, undefined type
912 sed -e '/authdes_create.*struct sockaddr/i\
913 struct sockaddr;
915 ${LIB}/$file > ${LIB}/$file.sed
916 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
917 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
918 rm -f ${LIB}/$file
922 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
923 # definition.
924 file=rpc/xdr.h
925 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
926 mkdir ${LIB}/rpc 2>/dev/null
927 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
928 chmod +w ${LIB}/$file 2>/dev/null
929 chmod a+r ${LIB}/$file 2>/dev/null
932 if [ -r ${LIB}/$file ]; then
933 echo Fixing $file, undefined type
934 sed -e '/xdrstdio_create.*struct __file_s/i\
935 struct __file_s;
937 ${LIB}/$file > ${LIB}/$file.sed
938 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
939 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
940 rm -f ${LIB}/$file
944 # Same problem with a file from SunOS 4.1.3 : a header file containing
945 # the string "//" embedded in "/**/"
946 file=sbusdev/audiovar.h
947 if [ -r ${LIB}/$file ]; then
948 echo Fixing $file, overeager sed script
949 rm ${LIB}/$file
950 sed -e 's|//.*$||g' $file > ${LIB}/$file
951 chmod +w ${LIB}/$file 2>/dev/null
952 chmod a+r ${LIB}/$file 2>/dev/null
955 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
956 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
957 # many other systems have similar text but correct versions of the file.
958 # To ensure only Sun's is fixed, we grep for a likely unique string.
959 file=memory.h
960 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
961 if [ ! -r ${LIB}/$file ]; then
962 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
963 chmod +w ${LIB}/$file 2>/dev/null
964 chmod a+r ${LIB}/$file 2>/dev/null
966 if [ -r ${LIB}/$file ]; then
967 echo Replacing $file
968 cat > ${LIB}/$file << EOF
969 /* This file was generated by fixincludes */
970 #ifndef __memory_h__
971 #define __memory_h__
973 #ifdef __STDC__
974 extern void *memccpy();
975 extern void *memchr();
976 extern void *memcpy();
977 extern void *memset();
978 #else
979 extern char *memccpy();
980 extern char *memchr();
981 extern char *memcpy();
982 extern char *memset();
983 #endif /* __STDC__ */
985 extern int memcmp();
987 #endif /* __memory_h__ */
992 # parameters not const on DECstation Ultrix V4.0.
993 file=stdio.h
994 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
995 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
996 chmod +w ${LIB}/$file 2>/dev/null
997 chmod a+r ${LIB}/$file 2>/dev/null
1000 if [ -r ${LIB}/$file ]; then
1001 echo Fixing $file, non-const arg
1002 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1003 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1004 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1005 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1006 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1007 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1008 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1009 ${LIB}/$file > ${LIB}/${file}.sed
1010 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1011 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1012 rm -f ${LIB}/$file
1016 # parameters conflict with C++ new on rs/6000
1017 for file in stdio.h unistd.h ; do
1018 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1019 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1020 chmod +w ${LIB}/$file 2>/dev/null
1023 if [ -r ${LIB}/$file ]; then
1024 echo Fixing $file, parameter name conflicts
1025 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1026 ${LIB}/$file > ${LIB}/${file}.sed
1027 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1028 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1029 rm -f ${LIB}/$file
1032 done
1034 # function class(double x) conflicts with C++ keyword on rs/6000
1035 file=math.h
1036 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1037 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1038 chmod +w ${LIB}/$file 2>/dev/null
1039 chmod a+r ${LIB}/$file 2>/dev/null
1042 if [ -r ${LIB}/$file ]; then
1043 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1044 echo Fixing $file
1045 sed -e '/class[(]/i\
1046 #ifndef __cplusplus
1048 -e '/class[(]/a\
1049 #endif
1050 ' ${LIB}/$file > ${LIB}/${file}.sed
1051 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1052 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1053 rm ${LIB}/$file
1058 # Wrong fchmod prototype on RS/6000.
1059 file=sys/stat.h
1060 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1061 mkdir ${LIB}/sys 2>/dev/null
1062 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1063 chmod +w ${LIB}/$file 2>/dev/null
1064 chmod a+r ${LIB}/$file 2>/dev/null
1067 if [ -r ${LIB}/$file ]; then
1068 echo Fixing $file, fchmod prototype
1069 sed -e 's/fchmod(char \*/fchmod(int/' \
1070 ${LIB}/$file > ${LIB}/$file.sed
1071 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1072 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1073 rm -f ${LIB}/$file
1077 # There are several name conflicts with C++ reserved words in X11
1078 # header files. These are fixed in some versions, so don't do the
1079 # fixes if we find __cplusplus in the file. These were found on the
1080 # RS/6000.
1082 # class in X11/ShellP.h
1083 file=X11/ShellP.h
1084 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1085 mkdir ${LIB}/sys 2>/dev/null
1086 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1087 chmod +w ${LIB}/$file 2>/dev/null
1088 chmod a+r ${LIB}/$file 2>/dev/null
1091 if [ -r ${LIB}/$file ]; then
1092 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1093 true;
1094 else
1095 echo Fixing $file, field class
1096 sed -e '/char [*]class;/i\
1097 #ifdef __cplusplus\
1098 char *c_class;\
1099 #else
1101 -e '/char [*]class;/a\
1102 #endif
1103 ' ${LIB}/$file > ${LIB}/${file}.sed
1104 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1106 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1107 rm -f ${LIB}/$file
1110 # new in Xm/Traversal.h
1111 file=Xm/Traversal.h
1112 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1113 mkdir ${LIB}/sys 2>/dev/null
1114 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1115 chmod +w ${LIB}/$file 2>/dev/null
1116 chmod a+r ${LIB}/$file 2>/dev/null
1119 if [ -r ${LIB}/$file ]; then
1120 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1121 true;
1122 else
1123 echo Fixing $file, uses of new
1124 sed -e '/Widget old, new;/i\
1125 #ifdef __cplusplus\
1126 Widget old, c_new;\
1127 #else
1129 -e '/Widget old, new;/a\
1130 #endif
1132 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1133 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1135 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1136 rm -f ${LIB}/$file
1139 # class in Xm/BaseClassI.h
1140 file=Xm/BaseClassI.h
1141 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1142 mkdir ${LIB}/sys 2>/dev/null
1143 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1144 chmod +w ${LIB}/$file 2>/dev/null
1145 chmod a+r ${LIB}/$file 2>/dev/null
1148 if [ -r ${LIB}/$file ]; then
1149 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1150 true;
1151 else
1152 echo Fixing $file, prototype parameter name
1153 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1154 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1156 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1157 rm -f ${LIB}/$file
1162 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1163 # Note that version 3 of the NeXT system has wait.h in a different directory,
1164 # so that this code won't do anything. But wait.h in version 3 has a
1165 # conditional, so it doesn't need this fix. So everything is okay.
1166 file=sys/wait.h
1167 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1168 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1169 chmod +w ${LIB}/$file 2>/dev/null
1172 if [ -r ${LIB}/$file ] \
1173 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1174 echo Fixing $file, bad wait formal
1175 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1176 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1177 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1178 rm -f ${LIB}/$file
1182 # Don't use or define the name va_list in stdio.h.
1183 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1184 file=stdio.h
1185 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1186 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1187 chmod +w ${LIB}/$file 2>/dev/null
1188 chmod a+r ${LIB}/$file 2>/dev/null
1191 if [ -r ${LIB}/$file ]; then
1192 echo Fixing $file, use of va_list
1193 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1194 (echo "#define __need___va_list"
1195 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1196 # Use __gnuc_va_list in arg types in place of va_list.
1197 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1198 # trailing parentheses and semicolon save all other systems from this.
1199 # Define __va_list__ (something harmless and unused) instead of va_list.
1200 # Don't claim to have defined va_list.
1201 sed -e 's@ va_list @ __gnuc_va_list @' \
1202 -e 's@ va_list)@ __gnuc_va_list)@' \
1203 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1204 -e 's@ va_list@ __va_list__@' \
1205 -e 's@\*va_list@*__va_list__@' \
1206 -e 's@ __va_list)@ __gnuc_va_list)@' \
1207 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1208 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1209 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1210 ${LIB}/$file >> ${LIB}/${file}.sed
1212 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1213 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1214 rm -f ${LIB}/$file
1218 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1219 file=ansi_compat.h
1220 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1221 if grep -s ULTRIX $file; then
1222 echo "/* This file intentionally left blank. */" > $LIB/$file
1226 # parameter to atof not const on DECstation Ultrix V4.0.
1227 # also get rid of bogus inline definitions in HP-UX 8.0
1228 file=math.h
1229 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1230 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1231 chmod +w ${LIB}/$file 2>/dev/null
1232 chmod a+r ${LIB}/$file 2>/dev/null
1235 if [ -r ${LIB}/$file ]; then
1236 echo Fixing $file, non-const arg
1237 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1238 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1239 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1240 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1241 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1242 ${LIB}/$file > ${LIB}/${file}.sed
1243 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1244 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1245 rm -f ${LIB}/$file
1249 # Avoid nested comments on Ultrix 4.3.
1250 file=rpc/svc.h
1251 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1252 mkdir ${LIB}/rpc 2>/dev/null
1253 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1254 chmod +w ${LIB}/$file 2>/dev/null
1255 chmod a+r ${LIB}/$file 2>/dev/null
1258 if [ -r ${LIB}/$file ]; then
1259 echo Fixing $file, nested comment
1260 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1261 ${LIB}/$file > ${LIB}/$file.sed
1262 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1263 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1264 rm -f ${LIB}/$file
1268 # This file in RISC/os uses /**/ to concatenate two tokens.
1269 file=bsd43/bsd43_.h
1270 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1271 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1272 chmod +w ${LIB}/$file 2>/dev/null
1273 chmod a+r ${LIB}/$file 2>/dev/null
1275 if [ -r ${LIB}/$file ]; then
1276 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1277 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1278 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1279 rm -f ${LIB}/$file
1283 file=rpc/rpc.h
1284 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1285 mkdir ${LIB}/rpc 2>/dev/null
1286 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1287 chmod +w ${LIB}/$file 2>/dev/null
1288 chmod a+r ${LIB}/$file 2>/dev/null
1291 if [ -r ${LIB}/$file ]; then
1292 echo Fixing $file, nested comment
1293 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1294 ${LIB}/$file > ${LIB}/$file.sed
1295 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1296 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1297 rm -f ${LIB}/$file
1301 # In limits.h, put #ifndefs around things that are supposed to be defined
1302 # in float.h to avoid redefinition errors if float.h is included first.
1303 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1304 # multi line comments and the inserted #endif winds up inside the
1305 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1306 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1307 # are there, and we do not add them ourselves.
1308 for file in limits.h sys/limits.h; do
1309 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1310 mkdir ${LIB}/sys 2>/dev/null
1311 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1312 chmod +w ${LIB}/$file 2>/dev/null
1313 chmod a+r ${LIB}/$file 2>/dev/null
1316 if [ -r ${LIB}/$file ]; then
1317 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1318 true
1319 else
1320 echo Fixing $file
1321 sed -e '/[ ]FLT_MIN[ ]/i\
1322 #ifndef FLT_MIN
1324 -e '/[ ]FLT_MIN[ ]/a\
1325 #endif
1327 -e '/[ ]FLT_MAX[ ]/i\
1328 #ifndef FLT_MAX
1330 -e '/[ ]FLT_MAX[ ]/a\
1331 #endif
1333 -e '/[ ]FLT_DIG[ ]/i\
1334 #ifndef FLT_DIG
1336 -e '/[ ]FLT_DIG[ ]/a\
1337 #endif
1339 -e '/[ ]DBL_MIN[ ]/i\
1340 #ifndef DBL_MIN
1342 -e '/[ ]DBL_MIN[ ]/a\
1343 #endif
1345 -e '/[ ]DBL_MAX[ ]/i\
1346 #ifndef DBL_MAX
1348 -e '/[ ]DBL_MAX[ ]/a\
1349 #endif
1351 -e '/[ ]DBL_DIG[ ]/i\
1352 #ifndef DBL_DIG
1354 -e '/[ ]DBL_DIG[ ]/a\
1355 #endif
1357 ${LIB}/$file > ${LIB}/${file}.sed
1358 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1360 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1361 echo Deleting ${LIB}/$file\; no fixes were needed.
1362 rm -f ${LIB}/$file
1365 done
1367 # In math.h, put #ifndefs around things that might be defined in a gcc
1368 # specific math-*.h file.
1369 file=math.h
1370 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1371 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1372 chmod +w ${LIB}/$file 2>/dev/null
1373 chmod a+r ${LIB}/$file 2>/dev/null
1376 if [ -r ${LIB}/$file ]; then
1377 echo Fixing $file
1378 sed -e '/define[ ]HUGE_VAL[ ]/i\
1379 #ifndef HUGE_VAL
1381 -e '/define[ ]HUGE_VAL[ ]/a\
1382 #endif
1384 ${LIB}/$file > ${LIB}/${file}.sed
1385 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1387 # In addition, copy the definition of DBL_MAX from float.h
1388 # if math.h requires one. The Lynx math.h requires it.
1389 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1390 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1391 true;
1392 else
1393 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1394 if [ "$dbl_max_def" != "" ]; then
1395 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1396 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1397 ${LIB}/$file > ${LIB}/${file}.sed
1401 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1402 echo Deleting ${LIB}/$file\; no fixes were needed.
1403 rm -f ${LIB}/$file
1407 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1408 file=sym.h
1409 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1410 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1411 chmod +w ${LIB}/$file 2>/dev/null
1412 chmod a+r ${LIB}/$file 2>/dev/null
1415 if [ -r ${LIB}/$file ]; then
1416 echo Fixing $file
1417 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1418 ${LIB}/$file > ${LIB}/${file}.sed
1419 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1420 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1421 rm -f ${LIB}/$file
1425 # Correct the return type for strlen in string.h on Lynx.
1426 file=string.h
1427 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1428 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1429 chmod +w ${LIB}/$file 2>/dev/null
1430 chmod a+r ${LIB}/$file 2>/dev/null
1433 if [ -r ${LIB}/$file ]; then
1434 echo Fixing $file
1435 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1436 ${LIB}/$file > ${LIB}/${file}.sed
1437 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1438 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1439 rm -f ${LIB}/$file
1443 # Delete the '#define void int' line from curses.h on Lynx
1444 file=curses.h
1445 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1446 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1447 chmod +w ${LIB}/$file 2>/dev/null
1448 chmod a+r ${LIB}/$file 2>/dev/null
1451 if [ -r ${LIB}/$file ]; then
1452 echo Fixing $file
1453 sed -e '/#define[ ][ ]*void[ ]int/d' \
1454 ${LIB}/$file > ${LIB}/${file}.sed
1455 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1456 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1457 rm -f ${LIB}/$file
1461 # For C++, avoid any typedef or macro definition of bool, and use the
1462 # built in type instead.
1463 for files in curses.h; do
1464 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1465 if [ ! -r ${LIB}/$file ]; then
1466 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1467 chmod +w ${LIB}/$file 2>/dev/null
1468 chmod a+r ${LIB}/$file 2>/dev/null
1471 echo Fixing $file
1472 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1473 #ifndef __cplusplus'\
1474 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1475 #endif'\
1476 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/i\
1477 #ifndef __cplusplus'\
1478 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/a\
1479 #endif'\
1480 ${LIB}/$file > ${LIB}/${file}.sed
1481 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1482 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1483 rm -f ${LIB}/$file
1486 done
1488 # Fix incorrect S_IF* definitions on m88k-sysv3.
1489 file=sys/stat.h
1490 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1491 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1492 chmod +w ${LIB}/$file 2>/dev/null
1493 chmod a+r ${LIB}/$file 2>/dev/null
1496 if [ -r ${LIB}/$file ]; then
1497 echo Fixing $file
1498 sed -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1499 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1500 ${LIB}/$file > ${LIB}/${file}.sed
1501 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1502 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1503 rm -f ${LIB}/$file
1507 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1508 for file in stdio.h stdlib.h; do
1509 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1510 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1511 chmod +w ${LIB}/$file 2>/dev/null
1512 chmod a+r ${LIB}/$file 2>/dev/null
1515 if [ -r ${LIB}/$file ]; then
1516 echo Fixing $file, getopt declaration
1517 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
1518 ${LIB}/$file > ${LIB}/${file}.sed
1519 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1520 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1521 rm -f ${LIB}/$file
1524 done
1526 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1527 # need to fix some additional files. This is the same test for ISC that
1528 # Autoconf uses.
1529 if test -d /etc/conf/kconfig.d \
1530 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1531 echo "Fixing ISC __STDC__ goof in several files..."
1532 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1533 echo $name
1534 if test -r ${LIB}/$name; then
1535 file=${LIB}/$name
1536 else
1537 file=${INPUT}/$name
1539 # On Interactive 2.2, certain traditional Unix definitions
1540 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1541 # defined, not just if _POSIX_SOURCE is defined. This makes it
1542 # impossible to compile any nontrivial program except with -posix.
1543 sed \
1544 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1545 < $file > ${LIB}/$name.
1546 mv ${LIB}/$name. ${LIB}/$name
1547 done
1549 echo "Fixing ISC fmod declaration"
1550 # This one's already been fixed for other things.
1551 file=${LIB}/math.h
1552 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1553 mv $file. $file
1555 echo "Fixing nested comments in ISC <sys/limits.h>"
1556 file=sys/limits.h
1557 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1558 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1561 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1562 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1563 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1564 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1566 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1567 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1568 chmod +w ${LIB}/$file 2>/dev/null
1569 chmod a+r ${LIB}/$file 2>/dev/null
1572 if [ -r ${LIB}/$file ]; then
1573 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1574 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1575 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1576 rm -f ${LIB}/$file
1579 done
1581 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1582 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1583 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1585 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1586 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1587 chmod +w ${LIB}/$file 2>/dev/null
1588 chmod a+r ${LIB}/$file 2>/dev/null
1591 if [ -r ${LIB}/$file ]; then
1592 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1593 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1594 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1595 rm -f ${LIB}/$file
1598 done
1600 # math.h on SunOS 4 puts the declaration of matherr before the definition
1601 # of struct exception, so the prototype (added by fixproto) causes havoc.
1602 file=math.h
1603 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1604 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1605 chmod +w ${LIB}/$file 2>/dev/null
1606 chmod a+r ${LIB}/$file 2>/dev/null
1609 if [ -r ${LIB}/$file ]; then
1610 echo Fixing $file, matherr declaration
1611 sed -e '/^struct exception/,$b' \
1612 -e '/matherr/i\
1613 struct exception;
1615 ${LIB}/$file > ${LIB}/${file}.sed
1616 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1617 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1618 rm -f ${LIB}/$file
1622 # This file on SunOS 4 has a very large macro. When the sed loop
1623 # tries pull it in, it overflows the pattern space size of the SunOS
1624 # sed (GNU sed does not have this problem). Since the file does not
1625 # require fixing, we remove it from the fixed directory.
1626 file=sundev/ipi_error.h
1627 if [ -r ${LIB}/$file ]; then
1628 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1629 rm -f ${LIB}/$file
1632 echo 'Removing unneeded directories:'
1633 cd $LIB
1634 files=`find . -type d -print | sort -r`
1635 for file in $files; do
1636 rmdir $LIB/$file > /dev/null 2>&1
1637 done
1639 if $LINKS; then
1640 echo 'Making internal symbolic non-directory links'
1641 cd ${INPUT}
1642 files=`find . -type l -print`
1643 for file in $files; do
1644 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1645 if expr "$dest" : '[^/].*' > /dev/null; then
1646 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1647 if [ -f $target ]; then
1648 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1651 done
1654 # Make sure that any include files referenced using double quotes
1655 # exist in the fixed directory. This comes last since otherwise
1656 # we might end up deleting some of these files "because they don't
1657 # need any change."
1658 while [ -n "$required" ]; do
1659 newreq=
1660 set x $required
1661 shift
1662 while [ $# != 0 ]; do
1663 # $1 is the directory to copy from, $2 is the unfixed file,
1664 # $3 is the fixed file name.
1665 cd ${INPUT}
1666 cd $1
1667 if [ -r $2 ] && [ ! -r $3 ]; then
1668 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1669 chmod +w $3 2>/dev/null
1670 chmod a+r $3 2>/dev/null
1671 echo Copied $2
1672 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1673 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1674 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1675 newreq="$newreq $1 $dir/$include $dir2/$include"
1676 done
1678 shift; shift; shift
1679 done
1680 required=$newreq
1681 done
1683 echo 'Cleaning up DONE files.'
1684 cd $LIB
1685 find . -name DONE -exec rm -f '{}' ';'
1687 exit 0