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.
20 # On an Apollo, discard everything before `/usr'.
21 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
33 # Make LIB absolute only if needed to avoid problems with the amd.
38 cd $LIB; LIB=`${PWDCMD}`
42 # Fail if no arg to specify a directory for the output.
44 then echo fixincludes: no output directory specified
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
54 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
55 rm -f /tmp/ShouldNotExist
61 echo Finding directories and links to directories
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.
71 while [ -n "$dirs" ] && [ $levels -gt 0 ]
73 levels=`expr $levels - 1`
77 echo " Searching $INPUT/$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.
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
101 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
103 newdirs="$newdirs $d1"
113 echo "All directories (including links to directories):"
116 for file in $files; do
118 if [ ! -d $LIB/$file ]
119 then mkdir $LIB/$file
124 # treetops gets an alternating list
125 # of old directories to copy
126 # and the new directories to copy to.
127 treetops="${INPUT} ${LIB}"
130 echo 'Making symbolic directory links'
131 for file in $files; do
132 dest=`ls -ld $file | sed -n 's/.*-> //p'`
135 # In case $dest is relative, get to $file's dir first.
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
143 # X gets the dir that the link actually leads to.
145 # Canonicalize ${INPUT} now to minimize the time an
146 # automounter has to change the result of ${PWDCMD}.
147 cinput=`cd ${INPUT}; ${PWDCMD}`
148 # If a link points to ., make a similar link to .
149 if [ $x = ${cinput} ]; then
150 echo $file '->' . ': Making link'
151 rm -fr ${LIB}/$file > /dev/null 2>&1
152 ln -s . ${LIB}/$file > /dev/null 2>&1
153 # If link leads back into ${INPUT},
154 # make a similar link here.
155 elif expr $x : "${cinput}/.*" > /dev/null; then
156 # Y gets the actual target dir name, relative to ${INPUT}.
157 y=`echo $x | sed -n "s&${cinput}/&&p"`
158 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
160 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
161 echo $file '->' $dots$y ': Making link'
162 rm -fr ${LIB}/$file > /dev/null 2>&1
163 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
165 # If the link is to a dir $target outside ${INPUT},
166 # repoint the link at ${INPUT}/root$target
167 # and process $target into ${INPUT}/root$target
168 # treat this directory as if it actually contained the files.
169 echo $file '->' root$x ': Making link'
170 if [ -d $LIB/root$x ]
176 while [ x$dirname != x ]; do
177 component=`echo $dirname | sed -e 's|/.*$||'`
178 mkdir $component >/dev/null 2>&1
180 dirmade=$dirmade/$component
181 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
184 # Duplicate directory structure created in ${LIB}/$file in new
186 for file2 in $files; do
189 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
190 echo "Duplicating ${file}'s ${dupdir}"
201 # Get the path from ${LIB} to $file, accounting for symlinks.
202 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
203 libabs=`cd ${LIB}; ${PWDCMD}`
204 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
205 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
206 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
207 rm -fr ${LIB}/$file > /dev/null 2>&1
208 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
209 treetops="$treetops $x ${LIB}/root$x"
220 while [ $# != 0 ]; do
221 # $1 is an old directory to copy, and $2 is the new directory to copy to.
224 # The same dir can appear more than once in treetops.
225 # There's no need to scan it more than once.
231 echo Fixing directory $1 into $2
232 # Check .h files which are symlinks as well as those which are files.
233 # A link to a header file will not be processed by anything but this.
235 files=`find . -name '*.h' \( -type f -o -type l \) -print`
237 files=`find . -name '*.h' -type f -print`
239 echo Checking header files
241 # Note that BSD43_* are used on recent MIPS systems.
242 for file in $files; do
243 # This call to egrep is essential, since checking a file with egrep
244 # is much faster than actually trying to fix it.
245 # It is also essential that most files *not* match!
246 # Thus, matching every #endif is unacceptable.
247 # But the argument to egrep must be kept small, or many versions of egrep
248 # won't be able to handle it.
250 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
251 # following #else or #endif because some buggy egreps think [^/] matches
252 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
254 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
255 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
256 # in this pattern lacks `d' and `l'; this means we don't worry about
257 # identifiers starting with `d' or `l'. This is OK, since none of the
258 # identifiers below start with `d' or `l'. It also greatly improves
259 # performance, since many files contain lines of the form `#if ... defined ...'
261 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
262 if [ -r $file ]; then
263 cp $file $2/$file >/dev/null 2>&1 \
264 || echo "Can't copy $file"
267 # Here is how the sed commands in braces work.
268 # (It doesn't work to put the comments inside the sed commands.)
269 # Surround each word with spaces, to simplify matching below.
270 # ANSIfy each pre-ANSI machine-dependent symbol
271 # by surrounding it with __ __.
272 # Remove the spaces that we inserted around each word.
277 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
278 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
279 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
280 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
281 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
282 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
283 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
284 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
285 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
286 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
287 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
288 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
289 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
290 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
291 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
293 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
295 s/ bsd4\([0-9]\) / __bsd4\1__ /g
296 s/ _*host_mips / __host_mips__ /g
297 s/ _*i386 / __i386__ /g
299 s/ is68k / __is68k__ /g
300 s/ m68k / __m68k__ /g
301 s/ mc680\([0-9]\)0 / __mc680\10__ /g
302 s/ m88k / __m88k__ /g
303 s/ _*mips / __mips__ /g
304 s/ news\([0-9]*\) / __news\1__ /g
305 s/ ns32000 / __ns32000__ /g
306 s/ pdp11 / __pdp11__ /g
309 s/ sony_news / __sony_news__ /g
310 s/ sparc / __sparc__ /g
311 s/ sun\([a-z0-9]*\) / __sun\1__ /g
312 s/ tahoe / __tahoe__ /g
313 s/ tower\([_0-9]*\) / __tower\1__ /g
314 s/ u370 / __u370__ /g
315 s/ u3b\([0-9]*\) / __u3b\1__ /g
316 s/ unix / __unix__ /g
318 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
319 s/ _*\([Rr][34]\)000 / __\1000__ /g
320 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
322 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
324 /^#define.NULL[ ]/ i\
326 ' $2/$file > $2/$file.
327 mv $2/$file. $2/$file
328 if cmp $file $2/$file >/dev/null 2>&1 \
329 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
333 # Find any include directives that use "file".
334 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
335 dir=`echo $file | sed -e s'|/[^/]*$||'`
336 required="$required $1 $dir/$include $2/$dir/$include"
347 # Install the proper definition of the three standard types in header files
348 # that they come from.
349 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
350 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
351 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
352 chmod +w ${LIB}/$file 2>/dev/null
353 chmod a+r ${LIB}/$file 2>/dev/null
356 if [ -r ${LIB}/$file ]; then
357 echo Fixing size_t, ptrdiff_t and wchar_t in $file
359 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
360 #ifndef __SIZE_TYPE__\
361 #define __SIZE_TYPE__ long unsigned int\
364 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
365 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
366 #ifndef __PTRDIFF_TYPE__\
367 #define __PTRDIFF_TYPE__ long int\
370 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
371 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
372 #ifndef __WCHAR_TYPE__\
373 #define __WCHAR_TYPE__ int\
376 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
377 ${LIB}/$file > ${LIB}/${file}.sed
378 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
379 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
382 # Find any include directives that use "file".
383 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
384 dir=`echo $file | sed -e s'|/[^/]*$||'`
385 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
391 # Fix one other error in this file: a mismatched quote not inside a C comment.
392 file=sundev/vuid_event.h
393 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
394 mkdir ${LIB}/sundev 2>/dev/null
395 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
396 chmod +w ${LIB}/$file 2>/dev/null
397 chmod a+r ${LIB}/$file 2>/dev/null
400 if [ -r ${LIB}/$file ]; then
401 echo Fixing $file comment
402 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
403 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
404 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
407 # Find any include directives that use "file".
408 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
409 dir=`echo $file | sed -e s'|/[^/]*$||'`
410 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
415 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
416 file=sunwindow/win_cursor.h
417 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
418 # mkdir ${LIB}/sunwindow 2>/dev/null
419 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
420 chmod +w ${LIB}/$file 2>/dev/null
422 if [ -r ${LIB}/$file ]; then
424 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
425 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
426 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
429 # Find any include directives that use "file".
430 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
431 dir=`echo $file | sed -e s'|/[^/]*$||'`
432 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
436 file=sunwindow/win_lock.h
437 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
438 # mkdir ${LIB}/sunwindow 2>/dev/null
439 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
440 chmod +w ${LIB}/$file 2>/dev/null
442 if [ -r ${LIB}/$file ]; then
444 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
445 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
446 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
449 # Find any include directives that use "file".
450 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
451 dir=`echo $file | sed -e s'|/[^/]*$||'`
452 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
457 # Fix this Sun file to avoid interfering with stddef.h.
459 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
460 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
461 chmod +w ${LIB}/$file 2>/dev/null
462 chmod a+r ${LIB}/$file 2>/dev/null
465 if [ -r ${LIB}/$file ]; then
467 sed -e '/[ ]size_t.*;/i\
474 -e '/[ ]ptrdiff_t.*;/i\
475 #ifndef _GCC_PTRDIFF_T\
476 #define _GCC_PTRDIFF_T
478 -e '/[ ]ptrdiff_t.*;/a\
481 -e '/[ ]wchar_t.*;/i\
482 #ifndef _GCC_WCHAR_T\
485 -e '/[ ]wchar_t.*;/a\
487 ' ${LIB}/$file > ${LIB}/${file}.sed
488 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
489 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
492 # Find any include directives that use "file".
493 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
494 dir=`echo $file | sed -e s'|/[^/]*$||'`
495 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
500 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
503 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
504 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
505 chmod +w ${LIB}/$file 2>/dev/null
506 chmod a+r ${LIB}/$file 2>/dev/null
509 if [ -r ${LIB}/$file ]; then
511 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
512 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
513 ${LIB}/$file > ${LIB}/${file}.sed
514 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
515 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
518 # Find any include directives that use "file".
519 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
520 dir=`echo $file | sed -e s'|/[^/]*$||'`
521 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
526 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
527 # the Norcroft compiler.
529 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
530 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
531 chmod +w ${LIB}/$file 2>/dev/null
532 chmod a+r ${LIB}/$file 2>/dev/null
535 if [ -r ${LIB}/$file ]; then
537 sed -e "s/___type p_type/p_type/" \
538 ${LIB}/$file > ${LIB}/${file}.sed
539 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
540 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
543 # Find any include directives that use "file".
544 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
545 dir=`echo $file | sed -e s'|/[^/]*$||'`
546 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
551 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
552 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
555 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
556 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
557 chmod +w ${LIB}/$file 2>/dev/null
558 chmod a+r ${LIB}/$file 2>/dev/null
561 if [ -r ${LIB}/$file ]; then
563 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
567 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
569 ' ${LIB}/$file > ${LIB}/${file}.sed
570 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
571 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
574 # Find any include directives that use "file".
575 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
576 dir=`echo $file | sed -e s'|/[^/]*$||'`
577 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
582 # Fix HP's use of ../machine/inline.h to refer to
583 # /usr/include/machine/inline.h
585 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
586 cp $file ${LIB}/$file
588 if [ -r ${LIB}/$file ] ; then
590 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
591 -e 's,"../machine/psl.h",<machine/psl.h>,' \
592 ${LIB}/$file > ${LIB}/${file}.sed
593 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
594 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
597 # Find any include directives that use "file".
598 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
599 dir=`echo $file | sed -e s'|/[^/]*$||'`
600 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
605 # Fix an error in this file: the #if says _cplusplus, not the double
606 # underscore __cplusplus that it should be
608 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
609 mkdir ${LIB}/rpcsvc 2>/dev/null
610 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
611 chmod +w ${LIB}/$file 2>/dev/null
612 chmod a+r ${LIB}/$file 2>/dev/null
615 if [ -r ${LIB}/$file ]; then
616 echo Fixing $file, __cplusplus macro
617 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
618 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
619 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
622 # Find any include directives that use "file".
623 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
624 dir=`echo $file | sed -e s'|/[^/]*$||'`
625 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
630 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
631 # structure definition.
633 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
634 mkdir ${LIB}/rpcsvc 2>/dev/null
635 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
636 chmod +w ${LIB}/$file 2>/dev/null
637 chmod a+r ${LIB}/$file 2>/dev/null
640 if [ -r ${LIB}/$file ]; then
641 echo Fixing $file, definition of statsswtch
642 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
643 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
644 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
647 # Find any include directives that use "file".
648 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
649 dir=`echo $file | sed -e s'|/[^/]*$||'`
650 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
655 # Fix an error in this file: a missing semi-colon at the end of the nodeent
656 # structure definition.
657 file=netdnet/dnetdb.h
658 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
659 mkdir ${LIB}/netdnet 2>/dev/null
660 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
661 chmod +w ${LIB}/$file 2>/dev/null
662 chmod a+r ${LIB}/$file 2>/dev/null
665 if [ -r ${LIB}/$file ]; then
666 echo Fixing $file, definition of nodeent
667 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
668 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
669 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
672 # Find any include directives that use "file".
673 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
674 dir=`echo $file | sed -e s'|/[^/]*$||'`
675 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
680 # Check for bad #ifdef line (in Ultrix 4.1)
682 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
683 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
684 chmod +w ${LIB}/$file 2>/dev/null
685 chmod a+r ${LIB}/$file 2>/dev/null
688 if [ -r ${LIB}/$file ]; then
689 echo Fixing $file, bad \#ifdef line
690 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
691 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
692 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
695 # Find any include directives that use "file".
696 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
697 dir=`echo $file | sed -e s'|/[^/]*$||'`
698 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
703 # Check for superfluous `static' (in Ultrix 4.2)
704 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
706 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
707 mkdir ${LIB}/machine 2>/dev/null
708 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
709 chmod +w ${LIB}/$file 2>/dev/null
710 chmod a+r ${LIB}/$file 2>/dev/null
713 if [ -r ${LIB}/$file ]; then
714 echo Fixing $file, superfluous static and broken includes of other files.
715 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
716 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
717 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
718 ${LIB}/$file > ${LIB}/${file}.sed
719 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
720 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
723 # Find any include directives that use "file".
724 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
725 dir=`echo $file | sed -e s'|/[^/]*$||'`
726 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
728 # This file has an alternative name, mips/cpu.h. Fix that name, too.
729 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
730 mkdir ${LIB}/mips 2>&-
731 # Don't remove the file first, they may be the same file!
732 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
737 # Incorrect sprintf declaration in X11/Xmu.h
739 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
740 mkdir ${LIB}/X11 2>/dev/null
741 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
742 chmod +w ${LIB}/$file 2>/dev/null
743 chmod a+r ${LIB}/$file 2>/dev/null
746 if [ -r ${LIB}/$file ]; then
747 echo Fixing $file sprintf declaration
748 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
749 extern char * sprintf();\
750 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
751 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
752 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
755 # Find any include directives that use "file".
756 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
757 dir=`echo $file | sed -e s'|/[^/]*$||'`
758 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
763 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
764 # (It's not clear whether the right file name is this or X11/Xmu.h.)
766 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
767 mkdir ${LIB}/X11/Xmu 2>/dev/null
768 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
769 chmod +w ${LIB}/$file 2>/dev/null
770 chmod a+r ${LIB}/$file 2>/dev/null
773 if [ -r ${LIB}/$file ]; then
774 echo Fixing $file sprintf declaration
775 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
776 extern char * sprintf();\
777 #endif /* !defined __STDC__ */,' ${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
782 # Find any include directives that use "file".
783 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
784 dir=`echo $file | sed -e s'|/[^/]*$||'`
785 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
790 # Check for missing ';' in struct
792 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
793 mkdir ${LIB}/netinet 2>/dev/null
794 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
795 chmod +w ${LIB}/$file 2>/dev/null
796 chmod a+r ${LIB}/$file 2>/dev/null
799 if [ -r ${LIB}/$file ]; then
801 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
802 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
803 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
806 # Find any include directives that use "file".
807 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
808 dir=`echo $file | sed -e s'|/[^/]*$||'`
809 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
814 # Fix the CAT macro in SunOS memvar.h.
815 file=pixrect/memvar.h
816 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
817 mkdir ${LIB}/pixrect 2>/dev/null
818 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
819 chmod +w ${LIB}/$file 2>/dev/null
820 chmod a+r ${LIB}/$file 2>/dev/null
823 if [ -r ${LIB}/$file ]; then
825 sed -e '/^#define.CAT(a,b)/ i\
827 #define CAT(a,b) a##b\
829 /^#define.CAT(a,b)/ a\
831 ' ${LIB}/$file > ${LIB}/${file}.sed
832 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
833 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
836 # Find any include directives that use "file".
837 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
838 dir=`echo $file | sed -e s'|/[^/]*$||'`
839 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
844 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
846 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
847 mkdir ${LIB}/rpcsvc 2>/dev/null
848 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
849 chmod +w ${LIB}/$file 2>/dev/null
850 chmod a+r ${LIB}/$file 2>/dev/null
853 if [ -r ${LIB}/$file ]; then
855 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
856 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
857 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
860 # Find any include directives that use "file".
861 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
862 dir=`echo $file | sed -e s'|/[^/]*$||'`
863 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
868 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
869 # Also wrap protection around size_t for m88k-sysv3 systems.
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
874 chmod a+r ${LIB}/$file 2>/dev/null
877 if [ -r ${LIB}/$file ]; then
879 sed -e 's/int abort/void abort/g' \
880 -e 's/int free/void free/g' \
881 -e 's/char \* calloc/void \* calloc/g' \
882 -e 's/char \* malloc/void \* malloc/g' \
883 -e 's/char \* realloc/void \* realloc/g' \
884 -e 's/int exit/void exit/g' \
885 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
889 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
892 ${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
897 # Find any include directives that use "file".
898 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
899 dir=`echo $file | sed -e s'|/[^/]*$||'`
900 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
905 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
907 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
908 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
909 chmod +w ${LIB}/$file 2>/dev/null
910 chmod a+r ${LIB}/$file 2>/dev/null
913 if [ -r ${LIB}/$file ]; then
915 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
916 -e 's/int[ ][ ]*free/void free/g' \
917 ${LIB}/$file > ${LIB}/${file}.sed
918 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
919 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
922 # Find any include directives that use "file".
923 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
924 dir=`echo $file | sed -e s'|/[^/]*$||'`
925 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
930 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
931 file=hsfs/hsfs_spec.h
932 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
933 mkdir ${LIB}/hsfs 2>/dev/null
934 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
935 chmod +w ${LIB}/$file 2>/dev/null
936 chmod a+r ${LIB}/$file 2>/dev/null
939 if [ -r ${LIB}/$file ]; then
941 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
942 ${LIB}/$file > ${LIB}/${file}.
943 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
944 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
947 # Find any include directives that use "file".
948 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
949 dir=`echo $file | sed -e s'|/[^/]*$||'`
950 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
955 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
957 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
958 mkdir ${LIB}/hsfs 2>/dev/null
959 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
960 chmod +w ${LIB}/$file 2>/dev/null
961 chmod a+r ${LIB}/$file 2>/dev/null
964 if [ -r ${LIB}/$file ]; then
966 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
967 ${LIB}/$file > ${LIB}/${file}.sed
968 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
969 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
972 # Find any include directives that use "file".
973 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
974 dir=`echo $file | sed -e s'|/[^/]*$||'`
975 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
980 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
982 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
983 mkdir ${LIB}/hsfs 2>/dev/null
984 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
985 chmod +w ${LIB}/$file 2>/dev/null
986 chmod a+r ${LIB}/$file 2>/dev/null
989 if [ -r ${LIB}/$file ]; then
991 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
992 ${LIB}/$file > ${LIB}/${file}.sed
993 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
994 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
997 # Find any include directives that use "file".
998 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
999 dir=`echo $file | sed -e s'|/[^/]*$||'`
1000 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1005 # Incorrect #include in Sony News-OS 3.2.
1006 file=machine/machparam.h
1007 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1008 mkdir ${LIB}/machine 2>/dev/null
1009 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1010 chmod +w ${LIB}/$file 2>/dev/null
1011 chmod a+r ${LIB}/$file 2>/dev/null
1014 if [ -r ${LIB}/$file ]; then
1015 echo Fixing $file, incorrect \#include
1016 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1017 ${LIB}/$file > ${LIB}/${file}.
1018 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1019 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1022 # Find any include directives that use "file".
1023 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1024 dir=`echo $file | sed -e s'|/[^/]*$||'`
1025 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1030 # Multiline comment after typedef on IRIX 4.0.1.
1032 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1033 mkdir ${LIB}/sys 2>/dev/null
1034 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1035 chmod +w ${LIB}/$file 2>/dev/null
1036 chmod a+r ${LIB}/$file 2>/dev/null
1039 if [ -r ${LIB}/$file ]; then
1040 echo Fixing $file, comment in the middle of \#ifdef
1041 sed -e 's@type of the result@type of the result */@' \
1042 -e 's@of the sizeof@/* of the sizeof@' \
1043 ${LIB}/$file > ${LIB}/${file}.sed
1044 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1045 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1048 # Find any include directives that use "file".
1049 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1050 dir=`echo $file | sed -e s'|/[^/]*$||'`
1051 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1056 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1057 # header file, which embeds // comments inside multi-line /* */
1058 # comments. If this looks like the IRIX header file, we refix it by
1059 # just throwing away the // comments.
1061 if [ -r ${LIB}/$file ]; then
1062 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1063 echo Fixing $file, overeager sed script
1065 sed -e 's|//.*$||g' $file > ${LIB}/$file
1066 chmod +w ${LIB}/$file 2>/dev/null
1067 chmod a+r ${LIB}/$file 2>/dev/null
1071 # Some IRIX header files contains the string "//"
1072 for file in elf_abi.h elf.h; do
1073 if [ -r ${LIB}/$file ]; then
1074 echo Fixing $file, overeager sed script
1075 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1076 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1077 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1080 # Find any include directives that use "file".
1081 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1082 dir=`echo $file | sed -e s'|/[^/]*$||'`
1083 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1089 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1090 # previous definition.
1092 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1093 mkdir ${LIB}/rpc 2>/dev/null
1094 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1095 chmod +w ${LIB}/$file 2>/dev/null
1096 chmod a+r ${LIB}/$file 2>/dev/null
1099 if [ -r ${LIB}/$file ]; then
1100 echo Fixing $file, undefined type
1101 sed -e '/authdes_create.*struct sockaddr/i\
1104 ${LIB}/$file > ${LIB}/$file.sed
1105 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1106 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1109 # Find any include directives that use "file".
1110 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1111 dir=`echo $file | sed -e s'|/[^/]*$||'`
1112 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1117 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1120 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1121 mkdir ${LIB}/rpc 2>/dev/null
1122 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1123 chmod +w ${LIB}/$file 2>/dev/null
1124 chmod a+r ${LIB}/$file 2>/dev/null
1127 if [ -r ${LIB}/$file ]; then
1128 echo Fixing $file, undefined type
1129 sed -e '/xdrstdio_create.*struct __file_s/i\
1132 ${LIB}/$file > ${LIB}/$file.sed
1133 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1134 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1137 # Find any include directives that use "file".
1138 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1139 dir=`echo $file | sed -e s'|/[^/]*$||'`
1140 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1145 # Same problem with a file from SunOS 4.1.3 : a header file containing
1146 # the string "//" embedded in "/**/"
1147 file=sbusdev/audiovar.h
1148 if [ -r ${LIB}/$file ]; then
1149 echo Fixing $file, overeager sed script
1151 sed -e 's|//.*$||g' $file > ${LIB}/$file
1152 chmod +w ${LIB}/$file 2>/dev/null
1153 chmod a+r ${LIB}/$file 2>/dev/null
1156 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1157 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1158 # many other systems have similar text but correct versions of the file.
1159 # To ensure only Sun's is fixed, we grep for a likely unique string.
1161 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
1162 if [ ! -r ${LIB}/$file ]; then
1163 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1164 chmod +w ${LIB}/$file 2>/dev/null
1165 chmod a+r ${LIB}/$file 2>/dev/null
1167 if [ -r ${LIB}/$file ]; then
1168 echo Replacing $file
1169 cat > ${LIB}/$file << EOF
1170 /* This file was generated by fixincludes */
1171 #ifndef __memory_h__
1172 #define __memory_h__
1175 extern void *memccpy();
1176 extern void *memchr();
1177 extern void *memcpy();
1178 extern void *memset();
1180 extern char *memccpy();
1181 extern char *memchr();
1182 extern char *memcpy();
1183 extern char *memset();
1184 #endif /* __STDC__ */
1186 extern int memcmp();
1188 #endif /* __memory_h__ */
1193 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1195 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1196 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1197 chmod +w ${LIB}/$file 2>/dev/null
1198 chmod a+r ${LIB}/$file 2>/dev/null
1201 if [ -r ${LIB}/$file ]; then
1202 echo Fixing $file, non-const arg
1203 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1204 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1205 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1206 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1207 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1208 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1209 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1210 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1211 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1212 ${LIB}/$file > ${LIB}/${file}.sed
1213 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1214 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1217 # Find any include directives that use "file".
1218 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1219 dir=`echo $file | sed -e s'|/[^/]*$||'`
1220 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1225 # parameters conflict with C++ new on rs/6000
1226 for file in stdio.h unistd.h ; do
1227 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1228 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1229 chmod +w ${LIB}/$file 2>/dev/null
1232 if [ -r ${LIB}/$file ]; then
1233 echo Fixing $file, parameter name conflicts
1234 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1235 ${LIB}/$file > ${LIB}/${file}.sed
1236 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1237 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1240 # Find any include directives that use "file".
1241 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1242 dir=`echo $file | sed -e s'|/[^/]*$||'`
1243 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1249 # function class(double x) conflicts with C++ keyword on rs/6000
1251 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1252 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1253 chmod +w ${LIB}/$file 2>/dev/null
1254 chmod a+r ${LIB}/$file 2>/dev/null
1257 if [ -r ${LIB}/$file ]; then
1258 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1260 sed -e '/class[(]/i\
1265 ' ${LIB}/$file > ${LIB}/${file}.sed
1266 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1267 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1270 # Find any include directives that use "file".
1271 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1272 dir=`echo $file | sed -e s'|/[^/]*$||'`
1273 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1279 # Wrong fchmod prototype on RS/6000.
1281 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1282 mkdir ${LIB}/sys 2>/dev/null
1283 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1284 chmod +w ${LIB}/$file 2>/dev/null
1285 chmod a+r ${LIB}/$file 2>/dev/null
1288 if [ -r ${LIB}/$file ]; then
1289 echo Fixing $file, fchmod prototype
1290 sed -e 's/fchmod(char \*/fchmod(int/' \
1291 ${LIB}/$file > ${LIB}/$file.sed
1292 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1293 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1296 # Find any include directives that use "file".
1297 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1298 dir=`echo $file | sed -e s'|/[^/]*$||'`
1299 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1304 # There are several name conflicts with C++ reserved words in X11
1305 # header files. These are fixed in some versions, so don't do the
1306 # fixes if we find __cplusplus in the file. These were found on the
1309 # class in X11/ShellP.h
1311 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1312 mkdir ${LIB}/sys 2>/dev/null
1313 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1314 chmod +w ${LIB}/$file 2>/dev/null
1315 chmod a+r ${LIB}/$file 2>/dev/null
1318 if [ -r ${LIB}/$file ]; then
1319 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1322 echo Fixing $file, field class
1323 sed -e '/char [*]class;/i\
1328 -e '/char [*]class;/a\
1330 ' ${LIB}/$file > ${LIB}/${file}.sed
1331 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1333 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1336 # Find any include directives that use "file".
1337 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1338 dir=`echo $file | sed -e s'|/[^/]*$||'`
1339 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1343 # new in Xm/Traversal.h
1345 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1346 mkdir ${LIB}/sys 2>/dev/null
1347 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1348 chmod +w ${LIB}/$file 2>/dev/null
1349 chmod a+r ${LIB}/$file 2>/dev/null
1352 if [ -r ${LIB}/$file ]; then
1353 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1356 echo Fixing $file, uses of new
1357 sed -e '/Widget old, new;/i\
1362 -e '/Widget old, new;/a\
1365 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1366 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1368 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1371 # Find any include directives that use "file".
1372 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1373 dir=`echo $file | sed -e s'|/[^/]*$||'`
1374 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1378 # class in Xm/BaseClassI.h
1379 file=Xm/BaseClassI.h
1380 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1381 mkdir ${LIB}/sys 2>/dev/null
1382 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1383 chmod +w ${LIB}/$file 2>/dev/null
1384 chmod a+r ${LIB}/$file 2>/dev/null
1387 if [ -r ${LIB}/$file ]; then
1388 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1391 echo Fixing $file, prototype parameter name
1392 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1393 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1395 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1398 # Find any include directives that use "file".
1399 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1400 dir=`echo $file | sed -e s'|/[^/]*$||'`
1401 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1406 # NeXT 3.2 adds const prefix to some math functions. These conflict
1407 # with the built-in functions.
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
1413 if [ -r ${LIB}/$file ]; then
1415 sed -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1416 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1417 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1418 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1421 # Find any include directives that use "file".
1422 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1423 dir=`echo $file | sed -e s'|/[^/]*$||'`
1424 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1429 # NeXT 3.2 uses the word "template" as a parameter for some
1430 # functions. GCC reports an invalid use of a reserved key word
1431 # with the built-in functions. NeXT 3.2 includes the keyword
1432 # volatile in the prototype for abort(). This conflicts with
1433 # the built-in definition.
1435 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1436 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1437 chmod +w ${LIB}/$file 2>/dev/null
1439 if [ -r ${LIB}/$file ]; then
1441 sed -e '/\(.*template\)/s/template//' \
1442 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1443 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1444 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1447 # Find any include directives that use "file".
1448 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1449 dir=`echo $file | sed -e s'|/[^/]*$||'`
1450 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1455 # NeXT 3.2 includes the keyword volatile in the abort() and
1456 # exit() function prototypes. That conflicts with the
1457 # built-in functions.
1459 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1460 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1461 chmod +w ${LIB}/$file 2>/dev/null
1463 if [ -r ${LIB}/$file ]; then
1465 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1466 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1467 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1468 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1471 # Find any include directives that use "file".
1472 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1473 dir=`echo $file | sed -e s'|/[^/]*$||'`
1474 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1479 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1480 # Note that version 3 of the NeXT system has wait.h in a different directory,
1481 # so that this code won't do anything. But wait.h in version 3 has a
1482 # conditional, so it doesn't need this fix. So everything is okay.
1484 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1485 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1486 chmod +w ${LIB}/$file 2>/dev/null
1489 if [ -r ${LIB}/$file ] \
1490 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1491 echo Fixing $file, bad wait formal
1492 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1493 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1494 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1497 # Find any include directives that use "file".
1498 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1499 dir=`echo $file | sed -e s'|/[^/]*$||'`
1500 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1505 # Don't use or define the name va_list in stdio.h.
1506 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1508 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1509 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1510 chmod +w ${LIB}/$file 2>/dev/null
1511 chmod a+r ${LIB}/$file 2>/dev/null
1514 if [ -r ${LIB}/$file ]; then
1515 echo Fixing $file, use of va_list
1516 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1517 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1518 touch ${LIB}/${file}.sed
1520 (echo "#define __need___va_list"
1521 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1523 # Use __gnuc_va_list in arg types in place of va_list.
1524 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1525 # trailing parentheses and semicolon save all other systems from this.
1526 # Define __va_list__ (something harmless and unused) instead of va_list.
1527 # Don't claim to have defined va_list.
1528 sed -e 's@ va_list @ __gnuc_va_list @' \
1529 -e 's@ va_list)@ __gnuc_va_list)@' \
1530 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1531 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1532 -e 's@ va_list@ __va_list__@' \
1533 -e 's@\*va_list@*__va_list__@' \
1534 -e 's@ __va_list)@ __gnuc_va_list)@' \
1535 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1536 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1537 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1538 -e 's@_Va_LIST@_VA_LIST@' \
1539 ${LIB}/$file >> ${LIB}/${file}.sed
1541 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1542 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1545 # Find any include directives that use "file".
1546 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1547 dir=`echo $file | sed -e s'|/[^/]*$||'`
1548 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1553 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1555 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1556 if grep -s ULTRIX $file; then
1557 echo "/* This file intentionally left blank. */" > $LIB/$file
1561 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1562 # also get rid of bogus inline definitions in HP-UX 8.0
1564 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1565 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1566 chmod +w ${LIB}/$file 2>/dev/null
1567 chmod a+r ${LIB}/$file 2>/dev/null
1570 if [ -r ${LIB}/$file ]; then
1571 echo Fixing $file, non-const arg
1572 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1573 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1574 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1575 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1576 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1577 ${LIB}/$file > ${LIB}/${file}.sed
1578 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1579 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1582 # Find any include directives that use "file".
1583 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1584 dir=`echo $file | sed -e s'|/[^/]*$||'`
1585 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1590 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1592 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1593 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1594 chmod +w ${LIB}/$file 2>/dev/null
1595 chmod a+r ${LIB}/$file 2>/dev/null
1598 if [ -r ${LIB}/$file ]; then
1599 echo Fixing $file, recursive inclusion
1600 sed -e '/^#include <stdlib.h>/i\
1603 -e '/^#include <stdlib.h>/a\
1606 ${LIB}/$file > ${LIB}/${file}.sed
1607 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1608 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1611 # Find any include directives that use "file".
1612 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1613 dir=`echo $file | sed -e s'|/[^/]*$||'`
1614 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1619 # Avoid nested comments on Ultrix 4.3.
1621 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1622 mkdir ${LIB}/rpc 2>/dev/null
1623 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1624 chmod +w ${LIB}/$file 2>/dev/null
1625 chmod a+r ${LIB}/$file 2>/dev/null
1628 if [ -r ${LIB}/$file ]; then
1629 echo Fixing $file, nested comment
1630 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1631 ${LIB}/$file > ${LIB}/$file.sed
1632 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1633 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1636 # Find any include directives that use "file".
1637 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1638 dir=`echo $file | sed -e s'|/[^/]*$||'`
1639 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1644 # This file in RISC/os uses /**/ to concatenate two tokens.
1646 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1647 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1648 chmod +w ${LIB}/$file 2>/dev/null
1649 chmod a+r ${LIB}/$file 2>/dev/null
1651 if [ -r ${LIB}/$file ]; then
1652 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1653 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1654 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1657 # Find any include directives that use "file".
1658 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1659 dir=`echo $file | sed -e s'|/[^/]*$||'`
1660 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1666 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1667 mkdir ${LIB}/rpc 2>/dev/null
1668 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1669 chmod +w ${LIB}/$file 2>/dev/null
1670 chmod a+r ${LIB}/$file 2>/dev/null
1673 if [ -r ${LIB}/$file ]; then
1674 echo Fixing $file, nested comment
1675 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1676 ${LIB}/$file > ${LIB}/$file.sed
1677 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1678 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1681 # Find any include directives that use "file".
1682 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1683 dir=`echo $file | sed -e s'|/[^/]*$||'`
1684 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1689 # In limits.h, put #ifndefs around things that are supposed to be defined
1690 # in float.h to avoid redefinition errors if float.h is included first.
1691 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1692 # multi line comments and the inserted #endif winds up inside the
1693 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1694 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1695 # are there, and we do not add them ourselves.
1696 for file in limits.h sys/limits.h; do
1697 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1698 mkdir ${LIB}/sys 2>/dev/null
1699 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1700 chmod +w ${LIB}/$file 2>/dev/null
1701 chmod a+r ${LIB}/$file 2>/dev/null
1704 if [ -r ${LIB}/$file ]; then
1705 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1709 sed -e '/[ ]FLT_MIN[ ]/i\
1712 -e '/[ ]FLT_MIN[ ]/a\
1715 -e '/[ ]FLT_MAX[ ]/i\
1718 -e '/[ ]FLT_MAX[ ]/a\
1721 -e '/[ ]FLT_DIG[ ]/i\
1724 -e '/[ ]FLT_DIG[ ]/a\
1727 -e '/[ ]DBL_MIN[ ]/i\
1730 -e '/[ ]DBL_MIN[ ]/a\
1733 -e '/[ ]DBL_MAX[ ]/i\
1736 -e '/[ ]DBL_MAX[ ]/a\
1739 -e '/[ ]DBL_DIG[ ]/i\
1742 -e '/[ ]DBL_DIG[ ]/a\
1745 ${LIB}/$file > ${LIB}/${file}.sed
1746 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1748 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1749 echo Deleting ${LIB}/$file\; no fixes were needed.
1752 # Find any include directives that use "file".
1753 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1754 dir=`echo $file | sed -e s'|/[^/]*$||'`
1755 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1761 # In math.h, put #ifndefs around things that might be defined in a gcc
1762 # specific math-*.h file.
1764 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1765 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1766 chmod +w ${LIB}/$file 2>/dev/null
1767 chmod a+r ${LIB}/$file 2>/dev/null
1770 if [ -r ${LIB}/$file ]; then
1772 sed -e '/define[ ]HUGE_VAL[ ]/i\
1775 -e '/define[ ]HUGE_VAL[ ]/a\
1778 ${LIB}/$file > ${LIB}/${file}.sed
1779 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1781 # In addition, copy the definition of DBL_MAX from float.h
1782 # if math.h requires one. The Lynx math.h requires it.
1783 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1784 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1787 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1788 if [ "$dbl_max_def" != "" ]; then
1789 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1790 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1791 ${LIB}/$file > ${LIB}/${file}.sed
1792 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1797 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1798 echo Deleting ${LIB}/$file\; no fixes were needed.
1801 # Find any include directives that use "file".
1802 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1803 dir=`echo $file | sed -e s'|/[^/]*$||'`
1804 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1809 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1811 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1812 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1813 chmod +w ${LIB}/$file 2>/dev/null
1814 chmod a+r ${LIB}/$file 2>/dev/null
1817 if [ -r ${LIB}/$file ]; then
1819 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1820 ${LIB}/$file > ${LIB}/${file}.sed
1821 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1822 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1825 # Find any include directives that use "file".
1826 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1827 dir=`echo $file | sed -e s'|/[^/]*$||'`
1828 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1833 # Correct the return type for strlen in string.h on Lynx.
1834 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1835 # Add missing const for strdup on OSF/1 V3.0.
1837 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1838 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1839 chmod +w ${LIB}/$file 2>/dev/null
1840 chmod a+r ${LIB}/$file 2>/dev/null
1843 if [ -r ${LIB}/$file ]; then
1845 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1846 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1847 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
1848 ${LIB}/$file > ${LIB}/${file}.sed
1849 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1850 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1853 # Find any include directives that use "file".
1854 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1855 dir=`echo $file | sed -e s'|/[^/]*$||'`
1856 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1861 # Correct the return type for strlen in strings.h in SunOS 4.
1863 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1864 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1865 chmod +w ${LIB}/$file 2>/dev/null
1866 chmod a+r ${LIB}/$file 2>/dev/null
1869 if [ -r ${LIB}/$file ]; then
1871 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
1872 ${LIB}/$file > ${LIB}/${file}.sed
1873 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1874 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1877 # Find any include directives that use "file".
1878 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1879 dir=`echo $file | sed -e s'|/[^/]*$||'`
1880 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1885 # Delete the '#define void int' line from curses.h on Lynx
1887 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1888 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1889 chmod +w ${LIB}/$file 2>/dev/null
1890 chmod a+r ${LIB}/$file 2>/dev/null
1893 if [ -r ${LIB}/$file ]; then
1895 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
1896 ${LIB}/$file > ${LIB}/${file}.sed
1897 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1898 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1901 # Find any include directives that use "file".
1902 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1903 dir=`echo $file | sed -e s'|/[^/]*$||'`
1904 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1909 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1911 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1912 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1913 chmod +w ${LIB}/$file 2>/dev/null
1914 chmod a+r ${LIB}/$file 2>/dev/null
1917 if [ -r ${LIB}/$file ]; then
1919 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
1920 ${LIB}/$file > ${LIB}/${file}.sed
1921 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1922 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1925 # Find any include directives that use "file".
1926 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1927 dir=`echo $file | sed -e s'|/[^/]*$||'`
1928 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1933 # For C++, avoid any typedef or macro definition of bool, and use the
1934 # built in type instead.
1935 for files in curses.h; do
1936 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1937 if [ ! -r ${LIB}/$file ]; then
1938 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1939 chmod +w ${LIB}/$file 2>/dev/null
1940 chmod a+r ${LIB}/$file 2>/dev/null
1944 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1945 #ifndef __cplusplus'\
1946 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1948 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;[ ]*$/i\
1949 #ifndef __cplusplus'\
1950 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;[ ]*$/a\
1952 ${LIB}/$file > ${LIB}/${file}.sed
1953 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1954 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1957 # Find any include directives that use "file".
1958 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1959 dir=`echo $file | sed -e s'|/[^/]*$||'`
1960 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1966 # Fix incorrect S_IF* definitions on m88k-sysv3.
1968 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1969 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1970 chmod +w ${LIB}/$file 2>/dev/null
1971 chmod a+r ${LIB}/$file 2>/dev/null
1974 if [ -r ${LIB}/$file ]; then
1976 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)/' \
1977 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1978 ${LIB}/$file > ${LIB}/${file}.sed
1979 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1980 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1983 # Find any include directives that use "file".
1984 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1985 dir=`echo $file | sed -e s'|/[^/]*$||'`
1986 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1991 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1992 for file in stdio.h stdlib.h; do
1993 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1994 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1995 chmod +w ${LIB}/$file 2>/dev/null
1996 chmod a+r ${LIB}/$file 2>/dev/null
1999 if [ -r ${LIB}/$file ]; then
2000 echo Fixing $file, getopt declaration
2001 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2002 ${LIB}/$file > ${LIB}/${file}.sed
2003 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2004 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2007 # Find any include directives that use "file".
2008 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2009 dir=`echo $file | sed -e s'|/[^/]*$||'`
2010 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2016 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2017 # need to fix some additional files. This is the same test for ISC that
2019 if test -d /etc/conf/kconfig.d \
2020 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2021 echo "Fixing ISC __STDC__ goof in several files..."
2022 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2024 if test -r ${LIB}/$name; then
2029 # On Interactive 2.2, certain traditional Unix definitions
2030 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2031 # defined, not just if _POSIX_SOURCE is defined. This makes it
2032 # impossible to compile any nontrivial program except with -posix.
2034 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2035 < $file > ${LIB}/$name.
2036 mv ${LIB}/$name. ${LIB}/$name
2039 echo "Fixing ISC fmod declaration"
2040 # This one's already been fixed for other things.
2042 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2045 echo "Fixing nested comments in ISC <sys/limits.h>"
2047 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2048 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2051 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2052 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2053 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2054 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2056 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2057 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2058 chmod +w ${LIB}/$file 2>/dev/null
2059 chmod a+r ${LIB}/$file 2>/dev/null
2062 if [ -r ${LIB}/$file ]; then
2063 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2064 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2065 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2068 # Find any include directives that use "file".
2069 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2070 dir=`echo $file | sed -e s'|/[^/]*$||'`
2071 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2077 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2078 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2079 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
2081 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2082 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2083 chmod +w ${LIB}/$file 2>/dev/null
2084 chmod a+r ${LIB}/$file 2>/dev/null
2087 if [ -r ${LIB}/$file ]; then
2088 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2089 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2090 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2093 # Find any include directives that use "file".
2094 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2095 dir=`echo $file | sed -e s'|/[^/]*$||'`
2096 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2102 # math.h on SunOS 4 puts the declaration of matherr before the definition
2103 # of struct exception, so the prototype (added by fixproto) causes havoc.
2105 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2106 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2107 chmod +w ${LIB}/$file 2>/dev/null
2108 chmod a+r ${LIB}/$file 2>/dev/null
2111 if [ -r ${LIB}/$file ]; then
2112 echo Fixing $file, matherr declaration
2113 sed -e '/^struct exception/,$b' \
2117 ${LIB}/$file > ${LIB}/${file}.sed
2118 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2119 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2122 # Find any include directives that use "file".
2123 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2124 dir=`echo $file | sed -e s'|/[^/]*$||'`
2125 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2130 # assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
2131 # is defined on HP/UX.
2133 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2134 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2135 chmod +w ${LIB}/$file 2>/dev/null
2136 chmod a+r ${LIB}/$file 2>/dev/null
2139 if [ -r ${LIB}/$file ]; then
2140 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2141 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2145 echo '#ifdef __cplusplus
2147 #endif' > ${LIB}/${file}.sed
2148 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2149 echo '#ifdef __cplusplus
2151 #endif' >> ${LIB}/${file}.sed
2152 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2153 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2156 # Find any include directives that use "file".
2157 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2158 dir=`echo $file | sed -e s'|/[^/]*$||'`
2159 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2165 # check for broken assert.h that needs stdio.h or stdlib.h
2167 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2168 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2169 chmod +w ${LIB}/$file 2>/dev/null
2170 chmod a+r ${LIB}/$file 2>/dev/null
2173 if [ -r ${LIB}/$file ]; then
2174 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
2175 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2178 echo "Fixing $file (needs stdio.h)"
2179 echo '#ifdef __cplusplus
2181 #endif' >>${LIB}/$file
2184 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
2185 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
2186 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2189 echo "Fixing $file (needs stdlib.h)"
2190 echo '#ifdef __cplusplus
2192 #endif' >>${LIB}/$file
2195 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2198 # Find any include directives that use "file".
2199 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2200 dir=`echo $file | sed -e s'|/[^/]*$||'`
2201 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2206 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2208 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2209 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2210 chmod +w ${LIB}/$file 2>/dev/null
2211 chmod a+r ${LIB}/$file 2>/dev/null
2214 if [ -r ${LIB}/$file ]; then
2215 echo Fixing $file, sbrk declaration
2216 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2217 ${LIB}/$file > ${LIB}/${file}.sed
2218 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2219 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2222 # Find any include directives that use "file".
2223 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2224 dir=`echo $file | sed -e s'|/[^/]*$||'`
2225 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2230 # This file on SunOS 4 has a very large macro. When the sed loop
2231 # tries pull it in, it overflows the pattern space size of the SunOS
2232 # sed (GNU sed does not have this problem). Since the file does not
2233 # require fixing, we remove it from the fixed directory.
2234 file=sundev/ipi_error.h
2235 if [ -r ${LIB}/$file ]; then
2236 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2240 # Put cpp wrappers around these include files to avoid redeclaration
2241 # errors during multiple inclusion on m88k-tektronix-sysv3.
2242 for file in time.h sys/time.h ; do
2243 if egrep '#ifndef' $file >/dev/null 2>&1; then
2246 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2247 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2248 chmod +w ${LIB}/$file 2>/dev/null
2250 if [ -r ${LIB}/$file ]; then
2251 echo Fixing $file, to protect against multiple inclusion.
2252 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2253 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2254 echo "#define __GCC_GOT_${cpp_wrapper}_"
2256 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2257 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2262 # Fix fcntl prototype in fcntl.h on LynxOS.
2264 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2265 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2266 chmod +w ${LIB}/$file 2>/dev/null
2267 chmod a+r ${LIB}/$file 2>/dev/null
2270 if [ -r ${LIB}/$file ]; then
2271 echo Fixing $file, fcntl declaration
2272 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2273 ${LIB}/$file > ${LIB}/${file}.sed
2274 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2275 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2278 # Find any include directives that use "file".
2279 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2280 dir=`echo $file | sed -e s'|/[^/]*$||'`
2281 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2286 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2287 file=arch/i960/archI960.h
2288 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2289 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2290 chmod +w ${LIB}/$file 2>/dev/null
2291 chmod a+r ${LIB}/$file 2>/dev/null
2294 if [ -r ${LIB}/$file ]; then
2296 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2297 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2298 ${LIB}/$file > ${LIB}/${file}.sed
2299 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2300 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2303 # Find any include directives that use "file".
2304 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2305 dir=`echo $file | sed -e s'|/[^/]*$||'`
2306 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2311 # Make VxWorks header which is almost gcc ready fully gcc ready.
2312 file=types/vxTypesBase.h
2313 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2314 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2315 chmod +w ${LIB}/$file 2>/dev/null
2316 chmod a+r ${LIB}/$file 2>/dev/null
2319 if [ -r ${LIB}/$file ]; then
2321 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2323 #ifndef _GCC_SIZE_T\
2329 -e '/[ ]ptrdiff_t/i\
2330 #ifndef _GCC_PTRDIFF_T\
2331 #define _GCC_PTRDIFF_T
2333 -e '/[ ]ptrdiff_t/a\
2337 #ifndef _GCC_WCHAR_T\
2338 #define _GCC_WCHAR_T
2343 ${LIB}/$file > ${LIB}/${file}.sed
2344 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2345 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2348 # Find any include directives that use "file".
2349 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2350 dir=`echo $file | sed -e s'|/[^/]*$||'`
2351 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2356 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2358 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2359 mkdir ${LIB}/sys 2>/dev/null
2360 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2361 chmod +w ${LIB}/$file 2>/dev/null
2362 chmod a+r ${LIB}/$file 2>/dev/null
2365 if [ -r ${LIB}/$file ]; then
2366 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2369 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2370 && [ -r types/vxTypesOld.h ]; then
2372 sed -e '/#define[ ][ ]*__INCstath/a\
2373 #include <types/vxTypesOld.h>
2375 ${LIB}/$file > ${LIB}/${file}.sed
2376 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2379 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2382 # Find any include directives that use "file".
2383 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2384 dir=`echo $file | sed -e s'|/[^/]*$||'`
2385 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2390 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2392 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2393 mkdir ${LIB}/sys 2>/dev/null
2394 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2395 chmod +w ${LIB}/$file 2>/dev/null
2396 chmod a+r ${LIB}/$file 2>/dev/null
2399 if [ -r ${LIB}/$file ]; then
2400 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2402 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2403 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2405 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2408 # Find any include directives that use "file".
2409 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2410 dir=`echo $file | sed -e s'|/[^/]*$||'`
2411 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2417 # This loop does not appear to do anything, because it uses file
2418 # rather than $file when setting target. It also appears to be
2419 # unnecessary, since the main loop processes symbolic links.
2421 # echo 'Making internal symbolic non-directory links'
2423 # files=`find . -type l -print`
2424 # for file in $files; do
2425 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
2426 # if expr "$dest" : '[^/].*' > /dev/null; then
2427 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
2428 # if [ -f $target ]; then
2429 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
2435 # Make sure that any include files referenced using double quotes
2436 # exist in the fixed directory. This comes last since otherwise
2437 # we might end up deleting some of these files "because they don't
2441 while [ $# != 0 ]; do
2443 while [ $# != 0 ]; do
2444 # $1 is the directory to copy from, $2 is the unfixed file,
2445 # $3 is the fixed file name.
2448 if [ -r $2 ] && [ ! -r $3 ]; then
2449 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
2450 chmod +w $3 2>/dev/null
2451 chmod a+r $3 2>/dev/null
2453 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2454 dir=`echo $2 | sed -e s'|/[^/]*$||'`
2455 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
2456 newreq="$newreq $1 $dir/$include $dir2/$include"
2465 echo 'Cleaning up DONE files.'
2467 find . -name DONE -exec rm -f '{}' ';'
2469 echo 'Removing unneeded directories:'
2471 files=`find . -type d -print | sort -r`
2472 for file in $files; do
2473 rmdir $LIB/$file > /dev/null 2>&1