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 what target system we're fixing.
16 if test -r ./Makefile; then
17 target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`"
18 test -z "${target_canonical}" && target_canonical=unknown
20 target_canonical=unknown
23 # Define PWDCMD as a command to use to get the working dir
24 # in the form that we want.
28 # On an Apollo, discard everything before `/usr'.
29 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
36 # Make sure it exists.
37 if [ ! -d $LIB ]; then
41 # Make LIB absolute only if needed to avoid problems with the amd.
46 cd $LIB; LIB=`${PWDCMD}`
50 # Fail if no arg to specify a directory for the output.
52 then echo fixincludes: no output directory specified
56 echo Building fixed headers in ${LIB}
58 # Determine whether this system has symbolic links.
59 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
60 rm -f $LIB/ShouldNotExist
62 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
63 rm -f /tmp/ShouldNotExist
69 echo Finding directories and links to directories
71 # Find all directories and all symlinks that point to directories.
72 # Put the list in $files.
73 # Each time we find a symlink, add it to newdirs
74 # so that we do another find within the dir the link points to.
75 # Note that $files may have duplicates in it;
76 # later parts of this file are supposed to ignore them.
79 while [ -n "$dirs" ] && [ $levels -gt 0 ]
81 levels=`expr $levels - 1`
85 echo " Searching $INPUT/$d"
87 # Find all directories under $d, relative to $d, excluding $d itself.
88 # (The /. is needed after $d in case $d is a symlink.)
89 files="$files `find $d/. -type d -print | \
90 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
91 # Find all links to directories.
92 # Using `-exec test -d' in find fails on some systems,
93 # and trying to run test via sh fails on others,
94 # so this is the simplest alternative left.
95 # First find all the links, then test each one.
98 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
99 for d1 in $theselinks --dummy--
101 # If the link points to a directory,
102 # add that dir to $newdirs
106 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
108 newdirs="$newdirs $d1"
118 echo "All directories (including links to directories):"
121 for file in $files; do
123 if [ ! -d $LIB/$file ]
124 then mkdir $LIB/$file
129 # treetops gets an alternating list
130 # of old directories to copy
131 # and the new directories to copy to.
132 treetops="${INPUT} ${LIB}"
135 echo 'Making symbolic directory links'
136 for file in $files; do
137 dest=`ls -ld $file | sed -n 's/.*-> //p'`
140 # In case $dest is relative, get to $file's dir first.
142 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
143 # Check that the target directory exists.
144 # Redirections changed to avoid bug in sh on Ultrix.
145 (cd $dest) > /dev/null 2>&1
148 # X gets the dir that the link actually leads to.
150 # Canonicalize ${INPUT} now to minimize the time an
151 # automounter has to change the result of ${PWDCMD}.
152 cinput=`cd ${INPUT}; ${PWDCMD}`
153 # If a link points to ., make a similar link to .
154 if [ $x = ${cinput} ]; then
155 echo $file '->' . ': Making link'
156 rm -fr ${LIB}/$file > /dev/null 2>&1
157 ln -s . ${LIB}/$file > /dev/null 2>&1
158 # If link leads back into ${INPUT},
159 # make a similar link here.
160 elif expr $x : "${cinput}/.*" > /dev/null; then
161 # Y gets the actual target dir name, relative to ${INPUT}.
162 y=`echo $x | sed -n "s&${cinput}/&&p"`
163 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
165 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
166 echo $file '->' $dots$y ': Making link'
167 rm -fr ${LIB}/$file > /dev/null 2>&1
168 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
170 # If the link is to a dir $target outside ${INPUT},
171 # repoint the link at ${INPUT}/root$target
172 # and process $target into ${INPUT}/root$target
173 # treat this directory as if it actually contained the files.
174 echo $file '->' root$x ': Making link'
175 if [ -d $LIB/root$x ]
181 while [ x$dirname != x ]; do
182 component=`echo $dirname | sed -e 's|/.*$||'`
183 mkdir $component >/dev/null 2>&1
185 dirmade=$dirmade/$component
186 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
189 # Duplicate directory structure created in ${LIB}/$file in new
191 for file2 in $files; do
194 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
195 echo "Duplicating ${file}'s ${dupdir}"
206 # Get the path from ${LIB} to $file, accounting for symlinks.
207 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
208 libabs=`cd ${LIB}; ${PWDCMD}`
209 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
210 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
211 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
212 rm -fr ${LIB}/$file > /dev/null 2>&1
213 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
214 treetops="$treetops $x ${LIB}/root$x"
225 while [ $# != 0 ]; do
226 # $1 is an old directory to copy, and $2 is the new directory to copy to.
229 # The same dir can appear more than once in treetops.
230 # There's no need to scan it more than once.
236 echo Fixing directory $1 into $2
237 # Check .h files which are symlinks as well as those which are files.
238 # A link to a header file will not be processed by anything but this.
240 files=`find . -name '*.h' \( -type f -o -type l \) -print`
242 files=`find . -name '*.h' -type f -print`
244 echo Checking header files
246 # Note that BSD43_* are used on recent MIPS systems.
247 for file in $files; do
248 # This call to egrep is essential, since checking a file with egrep
249 # is much faster than actually trying to fix it.
250 # It is also essential that most files *not* match!
251 # Thus, matching every #endif is unacceptable.
252 # But the argument to egrep must be kept small, or many versions of egrep
253 # won't be able to handle it.
255 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
256 # following #else or #endif because some buggy egreps think [^/] matches
257 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
259 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
260 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
261 # in this pattern lacks `d' and `l'; this means we don't worry about
262 # identifiers starting with `d' or `l'. This is OK, since none of the
263 # identifiers below start with `d' or `l'. It also greatly improves
264 # performance, since many files contain lines of the form `#if ... defined ...'
266 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
267 if [ -r $file ]; then
268 cp $file $2/$file >/dev/null 2>&1 \
269 || echo "Can't copy $file"
272 # The fixinc_eol stuff is to work around a bug in the sed
273 # program on HP/UX 10.20.
274 # Here is how the sed commands in braces work.
275 # (It doesn't work to put the comments inside the sed commands.)
276 # Surround each word with spaces, to simplify matching below.
277 # ANSIfy each pre-ANSI machine-dependent symbol
278 # by surrounding it with __ __.
279 # Remove the spaces that we inserted around each word.
283 s/\\$/\\*fixinc_eol*/
285 s/\\\*fixinc_eol\*/\\/g
286 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
287 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
288 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
289 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
290 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
291 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
292 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
293 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
294 /#[ ]*define[ ]*[ ]_IO/ s/'\''\([cgxtf]\)'\''/\1/g
295 /#[ ]*define[ ]*[ ]BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
296 /#[ ]*define[ ]*[ ]DESIOC/ s/'\''\([cdgx]\)'\''/\1/g
297 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
298 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
299 /#[ ]*define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
300 /#[ ]*define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
301 /#[ ]*define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
303 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
305 s/ bsd4\([0-9]\) / __bsd4\1__ /g
306 s/ _*host_mips / __host_mips__ /g
307 s/ _*i386 / __i386__ /g
309 s/ is68k / __is68k__ /g
310 s/ m68k / __m68k__ /g
311 s/ mc680\([0-9]\)0 / __mc680\10__ /g
312 s/ m88k / __m88k__ /g
313 s/ _*mips / __mips__ /g
314 s/ news\([0-9]*\) / __news\1__ /g
315 s/ ns32000 / __ns32000__ /g
316 s/ pdp11 / __pdp11__ /g
319 s/ sony_news / __sony_news__ /g
320 s/ sparc / __sparc__ /g
321 s/ sun\([a-z0-9]*\) / __sun\1__ /g
322 s/ tahoe / __tahoe__ /g
323 s/ tower\([_0-9]*\) / __tower\1__ /g
324 s/ u370 / __u370__ /g
325 s/ u3b\([0-9]*\) / __u3b\1__ /g
326 s/ unix / __unix__ /g
328 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
329 s/ _*\([Rr][34]\)000 / __\1000__ /g
330 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
332 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
334 /^#define.NULL[ ]/ i\
336 ' $2/$file > $2/$file.
337 mv $2/$file. $2/$file
338 if cmp $file $2/$file >/dev/null 2>&1 \
339 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
343 # Find any include directives that use "file".
344 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
345 dir=`echo $file | sed -e s'|/[^/]*$||'`
346 required="$required $1 $dir/$include $2/$dir/$include"
357 # Install the proper definition of the three standard types in header files
358 # that they come from.
359 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
360 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
361 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
362 chmod +w ${LIB}/$file 2>/dev/null
363 chmod a+r ${LIB}/$file 2>/dev/null
366 if [ -r ${LIB}/$file ]; then
367 echo Fixing size_t, ptrdiff_t and wchar_t in $file
369 -e '/^[ ]*\*[ ]*typedef unsigned int size_t;/N' \
370 -e 's/^\([ ]*\*[ ]*typedef unsigned int size_t;\n[ ]*\*\/\)/\1\
371 #ifndef __SIZE_TYPE__\
372 #define __SIZE_TYPE__ long unsigned int\
374 typedef __SIZE_TYPE__ size_t;\
376 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
377 #ifndef __SIZE_TYPE__\
378 #define __SIZE_TYPE__ long unsigned int\
381 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
382 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
383 #ifndef __PTRDIFF_TYPE__\
384 #define __PTRDIFF_TYPE__ long int\
387 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
388 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
389 #ifndef __WCHAR_TYPE__\
390 #define __WCHAR_TYPE__ int\
394 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
397 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
398 ${LIB}/$file > ${LIB}/${file}.sed
399 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
400 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
403 # Find any include directives that use "file".
404 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
405 dir=`echo $file | sed -e s'|/[^/]*$||'`
406 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
412 # Fix one other error in this file: a mismatched quote not inside a C comment.
413 file=sundev/vuid_event.h
414 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
415 mkdir ${LIB}/sundev 2>/dev/null
416 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
417 chmod +w ${LIB}/$file 2>/dev/null
418 chmod a+r ${LIB}/$file 2>/dev/null
421 if [ -r ${LIB}/$file ]; then
422 echo Fixing $file comment
423 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
424 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
425 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
428 # Find any include directives that use "file".
429 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
430 dir=`echo $file | sed -e s'|/[^/]*$||'`
431 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
436 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
437 file=sunwindow/win_cursor.h
438 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
439 # mkdir ${LIB}/sunwindow 2>/dev/null
440 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
441 chmod +w ${LIB}/$file 2>/dev/null
443 if [ -r ${LIB}/$file ]; then
445 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
446 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
447 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
450 # Find any include directives that use "file".
451 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
452 dir=`echo $file | sed -e s'|/[^/]*$||'`
453 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
457 file=sunwindow/win_lock.h
458 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
459 # mkdir ${LIB}/sunwindow 2>/dev/null
460 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
461 chmod +w ${LIB}/$file 2>/dev/null
463 if [ -r ${LIB}/$file ]; then
465 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
466 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
467 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
470 # Find any include directives that use "file".
471 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
472 dir=`echo $file | sed -e s'|/[^/]*$||'`
473 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
478 # Fix this Sun file to avoid interfering with stddef.h.
480 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
481 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
482 chmod +w ${LIB}/$file 2>/dev/null
483 chmod a+r ${LIB}/$file 2>/dev/null
486 if [ -r ${LIB}/$file ]; then
488 sed -e '/[ ]size_t.*;/i\
495 -e '/[ ]ptrdiff_t.*;/i\
496 #ifndef _GCC_PTRDIFF_T\
497 #define _GCC_PTRDIFF_T
499 -e '/[ ]ptrdiff_t.*;/a\
502 -e '/[ ]wchar_t.*;/i\
503 #ifndef _GCC_WCHAR_T\
506 -e '/[ ]wchar_t.*;/a\
508 ' ${LIB}/$file > ${LIB}/${file}.sed
509 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
510 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
513 # Find any include directives that use "file".
514 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
515 dir=`echo $file | sed -e s'|/[^/]*$||'`
516 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
521 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
524 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
525 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
526 chmod +w ${LIB}/$file 2>/dev/null
527 chmod a+r ${LIB}/$file 2>/dev/null
530 if [ -r ${LIB}/$file ]; then
532 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
533 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
534 ${LIB}/$file > ${LIB}/${file}.sed
535 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
536 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
539 # Find any include directives that use "file".
540 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
541 dir=`echo $file | sed -e s'|/[^/]*$||'`
542 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
547 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
548 # the Norcroft compiler.
550 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
551 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
552 chmod +w ${LIB}/$file 2>/dev/null
553 chmod a+r ${LIB}/$file 2>/dev/null
556 if [ -r ${LIB}/$file ]; then
558 sed -e "s/___type p_type/p_type/" \
559 ${LIB}/$file > ${LIB}/${file}.sed
560 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
561 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
564 # Find any include directives that use "file".
565 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
566 dir=`echo $file | sed -e s'|/[^/]*$||'`
567 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
572 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
573 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
576 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
577 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
578 chmod +w ${LIB}/$file 2>/dev/null
579 chmod a+r ${LIB}/$file 2>/dev/null
582 if [ -r ${LIB}/$file ]; then
584 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
588 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
590 ' ${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
595 # Find any include directives that use "file".
596 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
597 dir=`echo $file | sed -e s'|/[^/]*$||'`
598 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
603 # Fix HP's use of ../machine/inline.h to refer to
604 # /usr/include/machine/inline.h
606 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
607 cp $file ${LIB}/$file
609 if [ -r ${LIB}/$file ] ; then
611 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
612 -e 's,"../machine/psl.h",<machine/psl.h>,' \
613 ${LIB}/$file > ${LIB}/${file}.sed
614 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
615 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
618 # Find any include directives that use "file".
619 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
620 dir=`echo $file | sed -e s'|/[^/]*$||'`
621 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
626 # Fix an error in this file: the #if says _cplusplus, not the double
627 # underscore __cplusplus that it should be
629 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
630 mkdir ${LIB}/rpcsvc 2>/dev/null
631 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
632 chmod +w ${LIB}/$file 2>/dev/null
633 chmod a+r ${LIB}/$file 2>/dev/null
636 if [ -r ${LIB}/$file ]; then
637 echo Fixing $file, __cplusplus macro
638 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
639 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
640 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
643 # Find any include directives that use "file".
644 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
645 dir=`echo $file | sed -e s'|/[^/]*$||'`
646 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
651 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
652 # structure definition.
654 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
655 mkdir ${LIB}/rpcsvc 2>/dev/null
656 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
657 chmod +w ${LIB}/$file 2>/dev/null
658 chmod a+r ${LIB}/$file 2>/dev/null
661 if [ -r ${LIB}/$file ]; then
662 echo Fixing $file, definition of statsswtch
663 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
664 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
665 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
668 # Find any include directives that use "file".
669 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
670 dir=`echo $file | sed -e s'|/[^/]*$||'`
671 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
676 # Fix an error in this file: a missing semi-colon at the end of the nodeent
677 # structure definition.
678 file=netdnet/dnetdb.h
679 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
680 mkdir ${LIB}/netdnet 2>/dev/null
681 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
682 chmod +w ${LIB}/$file 2>/dev/null
683 chmod a+r ${LIB}/$file 2>/dev/null
686 if [ -r ${LIB}/$file ]; then
687 echo Fixing $file, definition of nodeent
688 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
689 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
690 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
693 # Find any include directives that use "file".
694 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
695 dir=`echo $file | sed -e s'|/[^/]*$||'`
696 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
701 # Check for bad #ifdef line (in Ultrix 4.1)
703 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
704 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
705 chmod +w ${LIB}/$file 2>/dev/null
706 chmod a+r ${LIB}/$file 2>/dev/null
709 if [ -r ${LIB}/$file ]; then
710 echo Fixing $file, bad \#ifdef line
711 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
712 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
713 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
716 # Find any include directives that use "file".
717 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
718 dir=`echo $file | sed -e s'|/[^/]*$||'`
719 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
724 # Check for (...) in C++ code in HP/UX sys/file.h.
726 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
727 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
728 chmod +w ${LIB}/$file 2>/dev/null
729 chmod a+r ${LIB}/$file 2>/dev/null
732 if [ -r ${LIB}/$file ]; then
733 if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
734 echo Fixing $file, use of '(...)'
735 sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
736 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
737 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
740 # Find any include directives that use "file".
741 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
742 dir=`echo $file | sed -e s'|/[^/]*$||'`
743 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
749 # Check for superfluous `static' (in Ultrix 4.2)
750 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
752 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
753 mkdir ${LIB}/machine 2>/dev/null
754 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
755 chmod +w ${LIB}/$file 2>/dev/null
756 chmod a+r ${LIB}/$file 2>/dev/null
759 if [ -r ${LIB}/$file ]; then
760 echo Fixing $file, superfluous static and broken includes of other files.
761 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
762 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
763 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
764 ${LIB}/$file > ${LIB}/${file}.sed
765 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
766 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
769 # Find any include directives that use "file".
770 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
771 dir=`echo $file | sed -e s'|/[^/]*$||'`
772 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
774 # This file has an alternative name, mips/cpu.h. Fix that name, too.
775 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
776 mkdir ${LIB}/mips 2>&-
777 # Don't remove the file first, they may be the same file!
778 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
783 # Incorrect sprintf declaration in X11/Xmu.h
785 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
786 mkdir ${LIB}/X11 2>/dev/null
787 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
788 chmod +w ${LIB}/$file 2>/dev/null
789 chmod a+r ${LIB}/$file 2>/dev/null
792 if [ -r ${LIB}/$file ]; then
793 echo Fixing $file sprintf declaration
794 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
795 extern char * sprintf();\
796 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
797 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
798 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
801 # Find any include directives that use "file".
802 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
803 dir=`echo $file | sed -e s'|/[^/]*$||'`
804 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
809 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
810 # (It's not clear whether the right file name is this or X11/Xmu.h.)
812 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
813 mkdir ${LIB}/X11/Xmu 2>/dev/null
814 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
815 chmod +w ${LIB}/$file 2>/dev/null
816 chmod a+r ${LIB}/$file 2>/dev/null
819 if [ -r ${LIB}/$file ]; then
820 echo Fixing $file sprintf declaration
821 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
822 extern char * sprintf();\
823 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
824 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
825 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
828 # Find any include directives that use "file".
829 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
830 dir=`echo $file | sed -e s'|/[^/]*$||'`
831 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
836 # Check for missing ';' in struct
838 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
839 mkdir ${LIB}/netinet 2>/dev/null
840 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
841 chmod +w ${LIB}/$file 2>/dev/null
842 chmod a+r ${LIB}/$file 2>/dev/null
845 if [ -r ${LIB}/$file ]; then
847 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
848 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
849 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
852 # Find any include directives that use "file".
853 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
854 dir=`echo $file | sed -e s'|/[^/]*$||'`
855 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
860 # Fix the CAT macro in SunOS memvar.h.
861 file=pixrect/memvar.h
862 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
863 mkdir ${LIB}/pixrect 2>/dev/null
864 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
865 chmod +w ${LIB}/$file 2>/dev/null
866 chmod a+r ${LIB}/$file 2>/dev/null
869 if [ -r ${LIB}/$file ]; then
871 sed -e '/^#define.CAT(a,b)/ i\
873 #define CAT(a,b) a##b\
875 /^#define.CAT(a,b)/ a\
877 ' ${LIB}/$file > ${LIB}/${file}.sed
878 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
879 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
882 # Find any include directives that use "file".
883 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
884 dir=`echo $file | sed -e s'|/[^/]*$||'`
885 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
890 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
892 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
893 mkdir ${LIB}/rpcsvc 2>/dev/null
894 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
895 chmod +w ${LIB}/$file 2>/dev/null
896 chmod a+r ${LIB}/$file 2>/dev/null
899 if [ -r ${LIB}/$file ]; then
901 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
902 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
903 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
906 # Find any include directives that use "file".
907 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
908 dir=`echo $file | sed -e s'|/[^/]*$||'`
909 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
914 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
915 # Also wrap protection around size_t for m88k-sysv3 systems.
917 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
918 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
919 chmod +w ${LIB}/$file 2>/dev/null
920 chmod a+r ${LIB}/$file 2>/dev/null
923 if [ -r ${LIB}/$file ]; then
925 sed -e 's/int abort/void abort/g' \
926 -e 's/int free/void free/g' \
927 -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \
928 -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \
929 -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \
930 -e 's/int[ ][ ]*exit/void exit/g' \
931 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
935 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
938 ${LIB}/$file > ${LIB}/${file}.sed
939 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
940 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
943 # Find any include directives that use "file".
944 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
945 dir=`echo $file | sed -e s'|/[^/]*$||'`
946 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
951 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
952 # Also fix return type of {m,re}alloc in <malloc.h> on sysV68
954 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
955 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
956 chmod +w ${LIB}/$file 2>/dev/null
957 chmod a+r ${LIB}/$file 2>/dev/null
960 if [ -r ${LIB}/$file ]; then
962 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
963 -e 's/int[ ][ ]*free/void free/g' \
964 -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \
965 -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \
966 ${LIB}/$file > ${LIB}/${file}.sed
967 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
968 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
971 # Find any include directives that use "file".
972 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
973 dir=`echo $file | sed -e s'|/[^/]*$||'`
974 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
979 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
980 file=hsfs/hsfs_spec.h
981 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
982 mkdir ${LIB}/hsfs 2>/dev/null
983 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
984 chmod +w ${LIB}/$file 2>/dev/null
985 chmod a+r ${LIB}/$file 2>/dev/null
988 if [ -r ${LIB}/$file ]; then
990 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
991 ${LIB}/$file > ${LIB}/${file}.
992 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
993 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
996 # Find any include directives that use "file".
997 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
998 dir=`echo $file | sed -e s'|/[^/]*$||'`
999 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1004 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
1006 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1007 mkdir ${LIB}/hsfs 2>/dev/null
1008 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1009 chmod +w ${LIB}/$file 2>/dev/null
1010 chmod a+r ${LIB}/$file 2>/dev/null
1013 if [ -r ${LIB}/$file ]; then
1015 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
1016 ${LIB}/$file > ${LIB}/${file}.sed
1017 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1018 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1021 # Find any include directives that use "file".
1022 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1023 dir=`echo $file | sed -e s'|/[^/]*$||'`
1024 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1029 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
1030 file=hsfs/iso_spec.h
1031 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1032 mkdir ${LIB}/hsfs 2>/dev/null
1033 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1034 chmod +w ${LIB}/$file 2>/dev/null
1035 chmod a+r ${LIB}/$file 2>/dev/null
1038 if [ -r ${LIB}/$file ]; then
1040 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1041 ${LIB}/$file > ${LIB}/${file}.sed
1042 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1043 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1046 # Find any include directives that use "file".
1047 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1048 dir=`echo $file | sed -e s'|/[^/]*$||'`
1049 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1054 # Incorrect #include in Sony News-OS 3.2.
1055 file=machine/machparam.h
1056 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1057 mkdir ${LIB}/machine 2>/dev/null
1058 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1059 chmod +w ${LIB}/$file 2>/dev/null
1060 chmod a+r ${LIB}/$file 2>/dev/null
1063 if [ -r ${LIB}/$file ]; then
1064 echo Fixing $file, incorrect \#include
1065 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1066 ${LIB}/$file > ${LIB}/${file}.
1067 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1068 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1071 # Find any include directives that use "file".
1072 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1073 dir=`echo $file | sed -e s'|/[^/]*$||'`
1074 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1079 # Multiline comment after typedef on IRIX 4.0.1.
1081 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1082 mkdir ${LIB}/sys 2>/dev/null
1083 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1084 chmod +w ${LIB}/$file 2>/dev/null
1085 chmod a+r ${LIB}/$file 2>/dev/null
1088 if [ -r ${LIB}/$file ]; then
1089 echo Fixing $file, comment in the middle of \#ifdef
1090 sed -e 's@type of the result@type of the result */@' \
1091 -e 's@of the sizeof@/* of the sizeof@' \
1092 ${LIB}/$file > ${LIB}/${file}.sed
1093 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1094 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1097 # Find any include directives that use "file".
1098 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1099 dir=`echo $file | sed -e s'|/[^/]*$||'`
1100 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1105 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1106 # header file, which embeds // comments inside multi-line /* */
1107 # comments. If this looks like the IRIX header file, we refix it by
1108 # just throwing away the // comments.
1110 if [ -r ${LIB}/$file ]; then
1111 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1112 echo Fixing $file, overeager sed script
1114 sed -e 's|//.*$||g' $file > ${LIB}/$file
1115 chmod +w ${LIB}/$file 2>/dev/null
1116 chmod a+r ${LIB}/$file 2>/dev/null
1120 # There is a similar problem with the VxWorks drv/netif/if_med.h file.
1121 file=drv/netif/if_med.h
1122 if [ -r ${LIB}/$file ]; then
1123 if egrep 'Wind River' ${LIB}/$file > /dev/null; then
1124 echo Fixing $file, overeager sed script
1126 sed -e 's|//.*$||g' $file > ${LIB}/$file
1127 chmod +w ${LIB}/$file 2>/dev/null
1128 chmod a+r ${LIB}/$file 2>/dev/null
1132 # And also with the HP-UX 10 sys/pci.h file
1134 if [ -r ${LIB}/$file ]; then
1135 if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
1136 echo Fixing $file, overeager sed script
1138 sed -e 's|//.*$||g' $file > ${LIB}/$file
1139 chmod +w ${LIB}/$file 2>/dev/null
1140 chmod a+r ${LIB}/$file 2>/dev/null
1144 # Some IRIX header files contains the string "//"
1145 for file in elf_abi.h elf.h; do
1146 if [ -r ${LIB}/$file ]; then
1147 echo Fixing $file, overeager sed script
1148 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1149 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1150 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1153 # Find any include directives that use "file".
1154 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1155 dir=`echo $file | sed -e s'|/[^/]*$||'`
1156 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1162 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1163 # previous definition.
1165 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1166 mkdir ${LIB}/rpc 2>/dev/null
1167 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1168 chmod +w ${LIB}/$file 2>/dev/null
1169 chmod a+r ${LIB}/$file 2>/dev/null
1172 if [ -r ${LIB}/$file ]; then
1173 echo Fixing $file, undefined type
1174 sed -e '/authdes_create.*struct sockaddr/i\
1177 ${LIB}/$file > ${LIB}/$file.sed
1178 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1179 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1182 # Find any include directives that use "file".
1183 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1184 dir=`echo $file | sed -e s'|/[^/]*$||'`
1185 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1190 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1193 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1194 mkdir ${LIB}/rpc 2>/dev/null
1195 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1196 chmod +w ${LIB}/$file 2>/dev/null
1197 chmod a+r ${LIB}/$file 2>/dev/null
1200 if [ -r ${LIB}/$file ]; then
1201 echo Fixing $file, undefined type
1202 sed -e '/xdrstdio_create.*struct __file_s/i\
1205 ${LIB}/$file > ${LIB}/$file.sed
1206 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1207 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1210 # Find any include directives that use "file".
1211 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1212 dir=`echo $file | sed -e s'|/[^/]*$||'`
1213 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1218 # Same problem with a file from SunOS 4.1.3 : a header file containing
1219 # the string "//" embedded in "/**/"
1220 file=sbusdev/audiovar.h
1221 if [ -r ${LIB}/$file ]; then
1222 echo Fixing $file, overeager sed script
1224 sed -e 's|//.*$||g' $file > ${LIB}/$file
1225 chmod +w ${LIB}/$file 2>/dev/null
1226 chmod a+r ${LIB}/$file 2>/dev/null
1229 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1230 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1231 # many other systems have similar text but correct versions of the file.
1232 # To ensure only Sun's is fixed, we grep for a likely unique string.
1233 # Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1235 if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then
1236 if [ ! -r ${LIB}/$file ]; then
1237 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1238 chmod +w ${LIB}/$file 2>/dev/null
1239 chmod a+r ${LIB}/$file 2>/dev/null
1241 if [ -r ${LIB}/$file ]; then
1242 echo Replacing $file
1243 cat > ${LIB}/$file << EOF
1244 /* This file was generated by fixincludes */
1245 #ifndef __memory_h__
1246 #define __memory_h__
1249 extern void *memccpy();
1250 extern void *memchr();
1251 extern void *memcpy();
1252 extern void *memset();
1254 extern char *memccpy();
1255 extern char *memchr();
1256 extern char *memcpy();
1257 extern char *memset();
1258 #endif /* __STDC__ */
1260 extern int memcmp();
1262 #endif /* __memory_h__ */
1267 # Fix return type of fread and fwrite on sysV68
1269 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1270 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1271 chmod +w ${LIB}/$file 2>/dev/null
1272 chmod a+r ${LIB}/$file 2>/dev/null
1275 if [ -r ${LIB}/$file ]; then
1276 echo Fixing $file, fread and fwrite return type
1277 sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\
1279 ${LIB}/$file > ${LIB}/${file}.sed
1280 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1281 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1284 # Find any include directives that use "file".
1285 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1286 dir=`echo $file | sed -e s'|/[^/]*$||'`
1287 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1292 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1294 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1295 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1296 chmod +w ${LIB}/$file 2>/dev/null
1297 chmod a+r ${LIB}/$file 2>/dev/null
1300 if [ -r ${LIB}/$file ]; then
1301 echo Fixing $file, non-const arg
1302 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1303 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1304 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1305 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1306 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1307 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1308 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1309 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1310 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1311 ${LIB}/$file > ${LIB}/${file}.sed
1312 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1313 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1316 # Find any include directives that use "file".
1317 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1318 dir=`echo $file | sed -e s'|/[^/]*$||'`
1319 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1324 # parameters conflict with C++ new on rs/6000
1325 for file in stdio.h unistd.h ; do
1326 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1327 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1328 chmod +w ${LIB}/$file 2>/dev/null
1331 if [ -r ${LIB}/$file ]; then
1332 echo Fixing $file, parameter name conflicts
1333 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1334 ${LIB}/$file > ${LIB}/${file}.sed
1335 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1336 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1339 # Find any include directives that use "file".
1340 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1341 dir=`echo $file | sed -e s'|/[^/]*$||'`
1342 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1348 # function class(double x) conflicts with C++ keyword on rs/6000
1350 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1351 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1352 chmod +w ${LIB}/$file 2>/dev/null
1353 chmod a+r ${LIB}/$file 2>/dev/null
1356 if [ -r ${LIB}/$file ]; then
1357 if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
1359 sed -e '/class[(]/i\
1364 ' ${LIB}/$file > ${LIB}/${file}.sed
1365 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1366 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1369 # Find any include directives that use "file".
1370 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1371 dir=`echo $file | sed -e s'|/[^/]*$||'`
1372 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1378 # Wrong fchmod prototype on RS/6000.
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 echo Fixing $file, fchmod prototype
1389 sed -e 's/fchmod(char \*/fchmod(int/' \
1390 ${LIB}/$file > ${LIB}/$file.sed
1391 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1392 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1395 # Find any include directives that use "file".
1396 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1397 dir=`echo $file | sed -e s'|/[^/]*$||'`
1398 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1403 # There are several name conflicts with C++ reserved words in X11
1404 # header files. These are fixed in some versions, so don't do the
1405 # fixes if we find __cplusplus in the file. These were found on the
1408 # class in X11/ShellP.h
1410 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1411 mkdir ${LIB}/sys 2>/dev/null
1412 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1413 chmod +w ${LIB}/$file 2>/dev/null
1414 chmod a+r ${LIB}/$file 2>/dev/null
1417 if [ -r ${LIB}/$file ]; then
1418 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1421 echo Fixing $file, field class
1422 sed -e '/char [*]class;/i\
1427 -e '/char [*]class;/a\
1429 ' ${LIB}/$file > ${LIB}/${file}.sed
1430 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1432 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1435 # Find any include directives that use "file".
1436 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1437 dir=`echo $file | sed -e s'|/[^/]*$||'`
1438 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1442 # new in Xm/Traversal.h
1444 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1445 mkdir ${LIB}/sys 2>/dev/null
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 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1455 echo Fixing $file, uses of new
1456 sed -e '/Widget old, new;/i\
1461 -e '/Widget old, new;/a\
1464 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1465 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1467 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1470 # Find any include directives that use "file".
1471 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1472 dir=`echo $file | sed -e s'|/[^/]*$||'`
1473 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1477 # class in Xm/BaseClassI.h
1478 file=Xm/BaseClassI.h
1479 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1480 mkdir ${LIB}/sys 2>/dev/null
1481 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1482 chmod +w ${LIB}/$file 2>/dev/null
1483 chmod a+r ${LIB}/$file 2>/dev/null
1486 if [ -r ${LIB}/$file ]; then
1487 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1490 echo Fixing $file, prototype parameter name
1491 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1492 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 # NeXT 3.2 adds const prefix to some math functions. These conflict
1506 # with the built-in functions.
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
1512 if [ -r ${LIB}/$file ]; then
1514 sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
1515 -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
1516 -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1517 -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
1518 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${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
1523 # Find any include directives that use "file".
1524 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1525 dir=`echo $file | sed -e s'|/[^/]*$||'`
1526 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1531 # NeXT 3.2 uses the word "template" as a parameter for some
1532 # functions. GCC reports an invalid use of a reserved key word
1533 # with the built-in functions. NeXT 3.2 includes the keyword
1534 # volatile in the prototype for abort(). This conflicts with
1535 # the built-in definition.
1537 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1538 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1539 chmod +w ${LIB}/$file 2>/dev/null
1541 if [ -r ${LIB}/$file ]; then
1543 sed -e '/\(.*template\)/s/template//' \
1544 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1545 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1546 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1549 # Find any include directives that use "file".
1550 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1551 dir=`echo $file | sed -e s'|/[^/]*$||'`
1552 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1557 # NeXT 3.2 includes the keyword volatile in the abort() and
1558 # exit() function prototypes. That conflicts with the
1559 # built-in functions.
1561 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1563 chmod +w ${LIB}/$file 2>/dev/null
1565 if [ -r ${LIB}/$file ]; then
1567 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1568 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1569 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1570 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1573 # Find any include directives that use "file".
1574 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1575 dir=`echo $file | sed -e s'|/[^/]*$||'`
1576 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1581 # sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
1582 # of struct rusage, so the prototype (added by fixproto) causes havoc.
1584 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1585 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1586 chmod +w ${LIB}/$file 2>/dev/null
1589 if [ -r ${LIB}/$file ] \
1590 && grep 'bos325,' ${LIB}/$file >/dev/null; then
1591 echo Fixing $file, wait3 declaration
1592 sed -e '/^extern pid_t wait3();$/i\
1595 ${LIB}/$file > ${LIB}/${file}.sed
1596 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1597 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1600 # Find any include directives that use "file".
1601 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1602 dir=`echo $file | sed -e s'|/[^/]*$||'`
1603 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1608 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1609 # Note that version 3 of the NeXT system has wait.h in a different directory,
1610 # so that this code won't do anything. But wait.h in version 3 has a
1611 # conditional, so it doesn't need this fix. So everything is okay.
1613 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1614 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1615 chmod +w ${LIB}/$file 2>/dev/null
1618 if [ -r ${LIB}/$file ] \
1619 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1620 echo Fixing $file, bad wait formal
1621 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1622 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1623 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1626 # Find any include directives that use "file".
1627 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1628 dir=`echo $file | sed -e s'|/[^/]*$||'`
1629 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1634 # Don't use or define the name va_list in stdio.h.
1635 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1637 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1638 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1639 chmod +w ${LIB}/$file 2>/dev/null
1640 chmod a+r ${LIB}/$file 2>/dev/null
1643 if [ -r ${LIB}/$file ]; then
1644 echo Fixing $file, use of va_list
1645 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1646 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1647 touch ${LIB}/${file}.sed
1649 (echo "#define __need___va_list"
1650 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1652 # Use __gnuc_va_list in arg types in place of va_list.
1653 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1654 # trailing parentheses and semicolon save all other systems from this.
1655 # Define __va_list__ (something harmless and unused) instead of va_list.
1656 # Don't claim to have defined va_list.
1657 sed -e 's@ va_list @ __gnuc_va_list @' \
1658 -e 's@ va_list)@ __gnuc_va_list)@' \
1659 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1660 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1661 -e 's@ va_list@ __va_list__@' \
1662 -e 's@\*va_list@*__va_list__@' \
1663 -e 's@ __va_list)@ __gnuc_va_list)@' \
1664 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1665 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1666 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1667 -e 's@_Va_LIST@_VA_LIST@' \
1668 ${LIB}/$file >> ${LIB}/${file}.sed
1670 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1671 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1674 # Find any include directives that use "file".
1675 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1676 dir=`echo $file | sed -e s'|/[^/]*$||'`
1677 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1682 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1684 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1685 if grep -s ULTRIX $file; then
1686 echo "/* This file intentionally left blank. */" > $LIB/$file
1690 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1691 # also get rid of bogus inline definitions in HP-UX 8.0
1693 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1694 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1695 chmod +w ${LIB}/$file 2>/dev/null
1696 chmod a+r ${LIB}/$file 2>/dev/null
1699 if [ -r ${LIB}/$file ]; then
1700 echo Fixing $file, non-const arg
1701 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1702 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1703 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1704 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1705 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1706 ${LIB}/$file > ${LIB}/${file}.sed
1707 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1708 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1711 # Find any include directives that use "file".
1712 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1713 dir=`echo $file | sed -e s'|/[^/]*$||'`
1714 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1719 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1721 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1722 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1723 chmod +w ${LIB}/$file 2>/dev/null
1724 chmod a+r ${LIB}/$file 2>/dev/null
1727 if [ -r ${LIB}/$file ]; then
1728 echo Fixing $file, recursive inclusion
1729 sed -e '/^#include <stdlib.h>/i\
1732 -e '/^#include <stdlib.h>/a\
1735 ${LIB}/$file > ${LIB}/${file}.sed
1736 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1737 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1740 # Find any include directives that use "file".
1741 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1742 dir=`echo $file | sed -e s'|/[^/]*$||'`
1743 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1748 # Avoid nested comments on Ultrix 4.3.
1750 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1751 mkdir ${LIB}/rpc 2>/dev/null
1752 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1753 chmod +w ${LIB}/$file 2>/dev/null
1754 chmod a+r ${LIB}/$file 2>/dev/null
1757 if [ -r ${LIB}/$file ]; then
1758 echo Fixing $file, nested comment
1759 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1760 ${LIB}/$file > ${LIB}/$file.sed
1761 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1762 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1765 # Find any include directives that use "file".
1766 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1767 dir=`echo $file | sed -e s'|/[^/]*$||'`
1768 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1773 # This file in RISC/os uses /**/ to concatenate two tokens.
1775 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1776 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1777 chmod +w ${LIB}/$file 2>/dev/null
1778 chmod a+r ${LIB}/$file 2>/dev/null
1780 if [ -r ${LIB}/$file ]; then
1781 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1782 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1783 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1786 # Find any include directives that use "file".
1787 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1788 dir=`echo $file | sed -e s'|/[^/]*$||'`
1789 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1795 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1796 mkdir ${LIB}/rpc 2>/dev/null
1797 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1798 chmod +w ${LIB}/$file 2>/dev/null
1799 chmod a+r ${LIB}/$file 2>/dev/null
1802 if [ -r ${LIB}/$file ]; then
1803 echo Fixing $file, nested comment
1804 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1805 ${LIB}/$file > ${LIB}/$file.sed
1806 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1807 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1810 # Find any include directives that use "file".
1811 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1812 dir=`echo $file | sed -e s'|/[^/]*$||'`
1813 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1818 # rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1819 # is defined for the alpha. The problem is the declaration of malloc.
1821 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1822 mkdir ${LIB}/rpc 2>/dev/null
1823 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1824 chmod +w ${LIB}/$file 2>/dev/null
1825 chmod a+r ${LIB}/$file 2>/dev/null
1827 if [ -r ${LIB}/$file ]; then
1828 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
1832 echo '#ifdef __cplusplus
1834 #endif' > ${LIB}/${file}.sed
1835 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1836 echo '#ifdef __cplusplus
1838 #endif' >> ${LIB}/${file}.sed
1839 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1840 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1843 # Find any include directives that use "file".
1844 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1845 dir=`echo $file | sed -e s'|/[^/]*$||'`
1846 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1852 # In limits.h, put #ifndefs around things that are supposed to be defined
1853 # in float.h to avoid redefinition errors if float.h is included first.
1854 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1855 # multi line comments and the inserted #endif winds up inside the
1856 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1857 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1858 # are there, and we do not add them ourselves.
1859 for file in limits.h sys/limits.h; do
1860 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1861 mkdir ${LIB}/sys 2>/dev/null
1862 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1863 chmod +w ${LIB}/$file 2>/dev/null
1864 chmod a+r ${LIB}/$file 2>/dev/null
1867 if [ -r ${LIB}/$file ]; then
1868 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1872 sed -e '/[ ]FLT_MIN[ ]/i\
1875 -e '/[ ]FLT_MIN[ ]/a\
1878 -e '/[ ]FLT_MAX[ ]/i\
1881 -e '/[ ]FLT_MAX[ ]/a\
1884 -e '/[ ]FLT_DIG[ ]/i\
1887 -e '/[ ]FLT_DIG[ ]/a\
1890 -e '/[ ]DBL_MIN[ ]/i\
1893 -e '/[ ]DBL_MIN[ ]/a\
1896 -e '/[ ]DBL_MAX[ ]/i\
1899 -e '/[ ]DBL_MAX[ ]/a\
1902 -e '/[ ]DBL_DIG[ ]/i\
1905 -e '/[ ]DBL_DIG[ ]/a\
1908 ${LIB}/$file > ${LIB}/${file}.sed
1909 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1911 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1912 echo Deleting ${LIB}/$file\; no fixes were needed.
1915 # Find any include directives that use "file".
1916 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1917 dir=`echo $file | sed -e s'|/[^/]*$||'`
1918 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1924 # In math.h, put #ifndefs around things that might be defined in a gcc
1925 # specific math-*.h file.
1927 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1928 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1929 chmod +w ${LIB}/$file 2>/dev/null
1930 chmod a+r ${LIB}/$file 2>/dev/null
1933 if [ -r ${LIB}/$file ]; then
1935 sed -e '/define[ ]HUGE_VAL[ ]/i\
1938 -e '/define[ ]HUGE_VAL[ ]/a\
1941 ${LIB}/$file > ${LIB}/${file}.sed
1942 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1944 # In addition, copy the definition of DBL_MAX from float.h
1945 # if math.h requires one. The Lynx math.h requires it.
1946 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1947 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1950 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1951 if [ "$dbl_max_def" != "" ]; then
1952 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1953 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1954 ${LIB}/$file > ${LIB}/${file}.sed
1955 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1960 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1961 echo Deleting ${LIB}/$file\; no fixes were needed.
1964 # Find any include directives that use "file".
1965 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1966 dir=`echo $file | sed -e s'|/[^/]*$||'`
1967 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1972 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1974 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1975 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1976 chmod +w ${LIB}/$file 2>/dev/null
1977 chmod a+r ${LIB}/$file 2>/dev/null
1980 if [ -r ${LIB}/$file ]; then
1982 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1983 ${LIB}/$file > ${LIB}/${file}.sed
1984 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1985 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1988 # Find any include directives that use "file".
1989 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1990 dir=`echo $file | sed -e s'|/[^/]*$||'`
1991 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1996 # Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
1997 # in string.h on sysV68
1998 # Correct the return type for strlen in string.h on Lynx.
1999 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2000 # Add missing const for strdup on OSF/1 V3.0.
2001 # On sysV88 layout is slightly different.
2003 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2004 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2005 chmod +w ${LIB}/$file 2>/dev/null
2006 chmod a+r ${LIB}/$file 2>/dev/null
2009 if [ -r ${LIB}/$file ]; then
2010 echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
2011 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
2012 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
2013 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
2014 -e '/^extern char$/N' \
2015 -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\
2016 -e '/^ strncmp(),$/N'\
2017 -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\
2018 extern unsigned int\
2020 -e '/^extern int$/N'\
2021 -e 's/^extern int\(\n strlen(),\)/extern size_t\1/' \
2022 ${LIB}/$file > ${LIB}/${file}.sed
2023 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2024 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2027 # Find any include directives that use "file".
2028 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2029 dir=`echo $file | sed -e s'|/[^/]*$||'`
2030 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2035 # Correct the return type for strlen in strings.h in SunOS 4.
2037 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2038 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2039 chmod +w ${LIB}/$file 2>/dev/null
2040 chmod a+r ${LIB}/$file 2>/dev/null
2043 if [ -r ${LIB}/$file ]; then
2045 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
2046 ${LIB}/$file > ${LIB}/${file}.sed
2047 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2048 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2051 # Find any include directives that use "file".
2052 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2053 dir=`echo $file | sed -e s'|/[^/]*$||'`
2054 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2059 # Delete the '#define void int' line from curses.h on Lynx
2061 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2062 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2063 chmod +w ${LIB}/$file 2>/dev/null
2064 chmod a+r ${LIB}/$file 2>/dev/null
2067 if [ -r ${LIB}/$file ]; then
2069 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
2070 ${LIB}/$file > ${LIB}/${file}.sed
2071 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2072 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2075 # Find any include directives that use "file".
2076 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2077 dir=`echo $file | sed -e s'|/[^/]*$||'`
2078 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2083 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
2085 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2086 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2087 chmod +w ${LIB}/$file 2>/dev/null
2088 chmod a+r ${LIB}/$file 2>/dev/null
2091 if [ -r ${LIB}/$file ]; then
2093 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
2094 ${LIB}/$file > ${LIB}/${file}.sed
2095 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2096 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2099 # Find any include directives that use "file".
2100 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2101 dir=`echo $file | sed -e s'|/[^/]*$||'`
2102 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2107 # For C++, avoid any typedef or macro definition of bool, and use the
2108 # built in type instead.
2109 for files in curses.h; do
2110 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
2111 if [ ! -r ${LIB}/$file ]; then
2112 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2113 chmod +w ${LIB}/$file 2>/dev/null
2114 chmod a+r ${LIB}/$file 2>/dev/null
2118 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
2121 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
2124 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\
2127 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\
2130 ${LIB}/$file > ${LIB}/${file}.sed
2131 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2132 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2135 # Find any include directives that use "file".
2136 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2137 dir=`echo $file | sed -e s'|/[^/]*$||'`
2138 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2144 # Fix incorrect S_IF* definitions on m88k-sysv3.
2146 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2147 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2148 chmod +w ${LIB}/$file 2>/dev/null
2149 chmod a+r ${LIB}/$file 2>/dev/null
2152 if [ -r ${LIB}/$file ]; then
2154 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)/' \
2155 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2156 ${LIB}/$file > ${LIB}/${file}.sed
2157 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2158 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2161 # Find any include directives that use "file".
2162 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2163 dir=`echo $file | sed -e s'|/[^/]*$||'`
2164 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2169 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
2170 for file in stdio.h stdlib.h; do
2171 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2172 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2173 chmod +w ${LIB}/$file 2>/dev/null
2174 chmod a+r ${LIB}/$file 2>/dev/null
2177 if [ -r ${LIB}/$file ]; then
2178 echo Fixing $file, getopt declaration
2179 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2180 ${LIB}/$file > ${LIB}/${file}.sed
2181 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2182 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2185 # Find any include directives that use "file".
2186 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2187 dir=`echo $file | sed -e s'|/[^/]*$||'`
2188 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2194 # Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2195 # The original ones fail if uninitialized externs are not common.
2196 # This is the default for all ANSI standard C++ compilers.
2197 for file in pthread.h; do
2198 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2199 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2200 chmod +w ${LIB}/$file 2>/dev/null
2201 chmod a+r ${LIB}/$file 2>/dev/null
2204 if [ -r ${LIB}/$file ]; then
2205 echo Fixing $file, __page_size* declarations
2206 sed -e 's/^int __page_size/extern int __page_size/' \
2207 ${LIB}/$file > ${LIB}/${file}.sed
2208 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2209 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2212 # Find any include directives that use "file".
2213 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2214 dir=`echo $file | sed -e s'|/[^/]*$||'`
2215 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2221 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2222 # need to fix some additional files. This is the same test for ISC that
2224 if test -d /etc/conf/kconfig.d \
2225 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2226 echo "Fixing ISC __STDC__ goof in several files..."
2227 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2229 if test -r ${LIB}/$name; then
2234 # On Interactive 2.2, certain traditional Unix definitions
2235 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2236 # defined, not just if _POSIX_SOURCE is defined. This makes it
2237 # impossible to compile any nontrivial program except with -posix.
2239 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2240 < $file > ${LIB}/$name.
2241 mv ${LIB}/$name. ${LIB}/$name
2244 echo "Fixing ISC fmod declaration"
2245 # This one's already been fixed for other things.
2247 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2250 echo "Fixing nested comments in ISC <sys/limits.h>"
2252 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2253 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2256 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2257 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2258 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2259 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2261 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2262 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2263 chmod +w ${LIB}/$file 2>/dev/null
2264 chmod a+r ${LIB}/$file 2>/dev/null
2267 if [ -r ${LIB}/$file ]; then
2268 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2269 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2270 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2273 # Find any include directives that use "file".
2274 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2275 dir=`echo $file | sed -e s'|/[^/]*$||'`
2276 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2282 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2283 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2284 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
2286 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2287 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2288 chmod +w ${LIB}/$file 2>/dev/null
2289 chmod a+r ${LIB}/$file 2>/dev/null
2292 if [ -r ${LIB}/$file ]; then
2293 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2294 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2295 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2298 # Find any include directives that use "file".
2299 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2300 dir=`echo $file | sed -e s'|/[^/]*$||'`
2301 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2307 # libm.a on m88k-motorola-sysv3 contains a stupid optimization for function
2308 # hypot(), which returns the second argument without even looking at its value
2309 # if the other is 0.0
2310 # Another drawback is that fix-header doesn't fix fabs' prototype, and I have
2313 if [ $target_canonical = m88k-motorola-sysv3 ]; then
2314 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2315 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2316 chmod +w ${LIB}/$file 2>/dev/null
2317 chmod a+r ${LIB}/$file 2>/dev/null
2320 if [ -r ${LIB}/$file ]; then
2321 echo Fixing $file, fabs/hypot definition
2323 -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \
2324 -e '/^extern double hypot();$/a\
2325 \/* Workaround a stupid Motorola optimization if one\
2326 of x or y is 0.0 and the other is negative! *\/\
2328 static __inline__ double fake_hypot (double x, double y)\
2330 static __inline__ double fake_hypot (x, y)\
2334 return fabs (hypot (x, y));\
2336 #define hypot fake_hypot
2338 ${LIB}/$file > ${LIB}/${file}.sed
2339 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2340 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2346 # math.h on SunOS 4 puts the declaration of matherr before the definition
2347 # of struct exception, so the prototype (added by fixproto) causes havoc.
2349 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2350 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2351 chmod +w ${LIB}/$file 2>/dev/null
2352 chmod a+r ${LIB}/$file 2>/dev/null
2355 if [ -r ${LIB}/$file ]; then
2356 echo Fixing $file, matherr declaration
2357 sed -e '/^struct exception/,$b' \
2361 ${LIB}/$file > ${LIB}/${file}.sed
2362 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2363 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2366 # Find any include directives that use "file".
2367 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2368 dir=`echo $file | sed -e s'|/[^/]*$||'`
2369 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2374 # assert.h and sys/mman.h on HP/UX are not C++ ready, even though
2375 # NO_IMPLICIT_EXTERN_C is defined on HP/UX.
2376 for file in assert.h sys/mman.h; do
2377 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2378 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2379 chmod +w ${LIB}/$file 2>/dev/null
2380 chmod a+r ${LIB}/$file 2>/dev/null
2383 if [ -r ${LIB}/$file ]; then
2384 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2385 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2389 echo '#ifdef __cplusplus
2391 #endif' > ${LIB}/${file}.sed
2392 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2393 echo '#ifdef __cplusplus
2395 #endif' >> ${LIB}/${file}.sed
2396 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2398 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2401 # Find any include directives that use "file".
2402 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2403 dir=`echo $file | sed -e s'|/[^/]*$||'`
2404 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2410 # check for broken assert.h that needs stdio.h or stdlib.h
2412 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2413 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2414 chmod +w ${LIB}/$file 2>/dev/null
2415 chmod a+r ${LIB}/$file 2>/dev/null
2418 if [ -r ${LIB}/$file ]; then
2419 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
2420 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2423 echo "Fixing $file (needs stdio.h)"
2424 echo '#include <stdio.h>' >>${LIB}/$file
2427 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
2428 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
2429 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2432 echo "Fixing $file (needs stdlib.h)"
2433 echo '#ifdef __cplusplus
2435 #endif' >>${LIB}/$file
2438 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2441 # Find any include directives that use "file".
2442 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2443 dir=`echo $file | sed -e s'|/[^/]*$||'`
2444 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2449 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2451 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2452 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2453 chmod +w ${LIB}/$file 2>/dev/null
2454 chmod a+r ${LIB}/$file 2>/dev/null
2457 if [ -r ${LIB}/$file ]; then
2458 echo Fixing $file, sbrk declaration
2459 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2460 ${LIB}/$file > ${LIB}/${file}.sed
2461 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2462 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2465 # Find any include directives that use "file".
2466 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2467 dir=`echo $file | sed -e s'|/[^/]*$||'`
2468 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2473 # This file on SunOS 4 has a very large macro. When the sed loop
2474 # tries pull it in, it overflows the pattern space size of the SunOS
2475 # sed (GNU sed does not have this problem). Since the file does not
2476 # require fixing, we remove it from the fixed directory.
2477 file=sundev/ipi_error.h
2478 if [ -r ${LIB}/$file ]; then
2479 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2483 # Put cpp wrappers around these include files to avoid redeclaration
2484 # errors during multiple inclusion on m88k-tektronix-sysv3.
2485 for file in time.h sys/time.h ; do
2486 if egrep '#ifndef' $file >/dev/null 2>&1; then
2489 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2490 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2491 chmod +w ${LIB}/$file 2>/dev/null
2493 if [ -r ${LIB}/$file ]; then
2494 echo Fixing $file, to protect against multiple inclusion.
2495 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2496 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2497 echo "#define __GCC_GOT_${cpp_wrapper}_"
2499 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2500 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2505 # Fix fcntl prototype in fcntl.h on LynxOS.
2507 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2508 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2509 chmod +w ${LIB}/$file 2>/dev/null
2510 chmod a+r ${LIB}/$file 2>/dev/null
2513 if [ -r ${LIB}/$file ]; then
2514 echo Fixing $file, fcntl declaration
2515 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2516 ${LIB}/$file > ${LIB}/${file}.sed
2517 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2518 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2521 # Find any include directives that use "file".
2522 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2523 dir=`echo $file | sed -e s'|/[^/]*$||'`
2524 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2529 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2530 file=arch/i960/archI960.h
2531 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2532 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2533 chmod +w ${LIB}/$file 2>/dev/null
2534 chmod a+r ${LIB}/$file 2>/dev/null
2537 if [ -r ${LIB}/$file ]; then
2539 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2540 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2541 ${LIB}/$file > ${LIB}/${file}.sed
2542 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2543 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2546 # Find any include directives that use "file".
2547 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2548 dir=`echo $file | sed -e s'|/[^/]*$||'`
2549 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2554 # Make VxWorks header which is almost gcc ready fully gcc ready.
2555 file=types/vxTypesBase.h
2556 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2557 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2558 chmod +w ${LIB}/$file 2>/dev/null
2559 chmod a+r ${LIB}/$file 2>/dev/null
2562 if [ -r ${LIB}/$file ]; then
2564 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2566 #ifndef _GCC_SIZE_T\
2572 -e '/[ ]ptrdiff_t/i\
2573 #ifndef _GCC_PTRDIFF_T\
2574 #define _GCC_PTRDIFF_T
2576 -e '/[ ]ptrdiff_t/a\
2580 #ifndef _GCC_WCHAR_T\
2581 #define _GCC_WCHAR_T
2586 ${LIB}/$file > ${LIB}/${file}.sed
2587 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2588 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2591 # Find any include directives that use "file".
2592 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2593 dir=`echo $file | sed -e s'|/[^/]*$||'`
2594 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2599 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2601 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2602 mkdir ${LIB}/sys 2>/dev/null
2603 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2604 chmod +w ${LIB}/$file 2>/dev/null
2605 chmod a+r ${LIB}/$file 2>/dev/null
2608 if [ -r ${LIB}/$file ]; then
2609 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2612 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2613 && [ -r types/vxTypesOld.h ]; then
2615 sed -e '/#define[ ][ ]*__INCstath/a\
2616 #include <types/vxTypesOld.h>
2618 ${LIB}/$file > ${LIB}/${file}.sed
2619 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2622 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2625 # Find any include directives that use "file".
2626 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2627 dir=`echo $file | sed -e s'|/[^/]*$||'`
2628 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2633 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2635 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2636 mkdir ${LIB}/sys 2>/dev/null
2637 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2638 chmod +w ${LIB}/$file 2>/dev/null
2639 chmod a+r ${LIB}/$file 2>/dev/null
2642 if [ -r ${LIB}/$file ]; then
2643 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2645 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2646 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2648 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2651 # Find any include directives that use "file".
2652 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2653 dir=`echo $file | sed -e s'|/[^/]*$||'`
2654 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2659 # Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2661 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2662 mkdir ${LIB}/sys 2>/dev/null
2663 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2664 chmod +w ${LIB}/$file 2>/dev/null
2665 chmod a+r ${LIB}/$file 2>/dev/null
2668 if [ -r ${LIB}/$file ]; then
2669 if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
2671 sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
2672 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2674 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2677 # Find any include directives that use "file".
2678 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2679 dir=`echo $file | sed -e s'|/[^/]*$||'`
2680 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2685 # Another bad dependency in VxWorks 5.2 <time.h>.
2687 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2688 mkdir ${LIB}/sys 2>/dev/null
2689 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2690 chmod +w ${LIB}/$file 2>/dev/null
2691 chmod a+r ${LIB}/$file 2>/dev/null
2694 if [ -r ${LIB}/$file ]; then
2695 if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
2696 if [ -r vxWorks.h ]; then
2698 sed -e '/VOIDFUNCPTR/i\
2699 #ifndef __gcc_VOIDFUNCPTR_defined\
2701 typedef void (*__gcc_VOIDFUNCPTR) (...);\
2703 typedef void (*__gcc_VOIDFUNCPTR) ();\
2705 #define __gcc_VOIDFUNCPTR_defined\
2708 -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
2709 ${LIB}/$file > ${LIB}/${file}.sed
2710 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2713 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2716 # Find any include directives that use "file".
2717 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2718 dir=`echo $file | sed -e s'|/[^/]*$||'`
2719 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2724 # This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
2725 # doesn't understand it.
2727 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2728 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2729 chmod +w ${LIB}/$file 2>/dev/null
2730 chmod a+r ${LIB}/$file 2>/dev/null
2733 if [ -r ${LIB}/$file ]; then
2734 echo "Fixing __asm directive in sys/param.h"
2735 sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
2736 ${LIB}/$file > ${LIB}/${file}.sed
2737 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2738 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2741 # Find any include directives that use "file".
2742 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2743 dir=`echo $file | sed -e s'|/[^/]*$||'`
2744 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2749 # signal.h on SunOS defines signal using (), which causes trouble when
2750 # compiling with g++ -pedantic.
2751 for file in signal.h sys/signal.h; do
2752 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2753 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2754 chmod +w ${LIB}/$file 2>/dev/null
2755 chmod a+r ${LIB}/$file 2>/dev/null
2758 if [ -r ${LIB}/$file ]; then
2759 echo "Checking for bad C++ prototype in $file"
2760 sed -e '/^void (\*signal())();$/i\
2762 void (*signal(...))(...);\
2765 -e '/^void (\*signal())();$/a\
2768 ${LIB}/$file > ${LIB}/${file}.sed
2769 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2770 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2773 # Find any include directives that use "file".
2774 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2775 dir=`echo $file | sed -e s'|/[^/]*$||'`
2776 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2782 # sys/signal.h on some versions of AIX uses volatile in the typedef of
2783 # sig_atomic_t, which causes gcc to generate a warning about duplicate
2784 # volatile when a sig_atomic_t variable is declared volatile, as
2785 # required by ANSI C.
2787 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2788 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2789 chmod +w ${LIB}/$file 2>/dev/null
2790 chmod a+r ${LIB}/$file 2>/dev/null
2793 if [ -r ${LIB}/$file ]; then
2794 echo "Checking for duplicate volatile in sys/signal.h"
2795 sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
2796 ${LIB}/$file > ${LIB}/${file}.sed
2797 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2798 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2801 # Find any include directives that use "file".
2802 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2803 dir=`echo $file | sed -e s'|/[^/]*$||'`
2804 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2809 # Some math.h files define struct exception, which conflicts with
2810 # the class exception defined in the C++ file std/stdexcept.h. We
2811 # redefine it to __math_exception. This is not a great fix, but I
2812 # haven't been able to think of anything better.
2814 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2815 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2816 chmod +w ${LIB}/$file 2>/dev/null
2817 chmod a+r ${LIB}/$file 2>/dev/null
2820 if [ -r ${LIB}/$file ]; then
2821 echo Fixing $file, exception
2822 sed -e '/struct exception/i\
2824 #define exception __math_exception\
2827 -e '/struct exception/a\
2831 ' ${LIB}/$file > ${LIB}/${file}.sed
2832 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2833 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
2836 #define exception __math_exception\
2843 ' ${LIB}/$file > ${LIB}/${file}.sed
2844 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2846 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2849 # Find any include directives that use "file".
2850 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2851 dir=`echo $file | sed -e s'|/[^/]*$||'`
2852 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2857 # rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers.
2859 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2860 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2861 chmod +w ${LIB}/$file 2>/dev/null
2862 chmod a+r ${LIB}/$file 2>/dev/null
2865 if [ -r ${LIB}/$file ]; then
2866 echo "Checking for needed C++ prototype in $file"
2867 sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
2873 $LIB/$file > ${LIB}/${file}.sed
2875 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2876 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2879 # Find any include directives that use "file".
2880 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2881 dir=`echo $file | sed -e s'|/[^/]*$||'`
2882 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2887 # sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2888 # defining regex.h related types. This causes libg++ build and usage failures.
2889 # Fixing this correctly requires checking and modifying 3 files.
2890 for file in reg_types.h regex.h sys/lc_core.h; do
2891 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2892 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2893 chmod +w ${LIB}/$file 2>/dev/null
2894 chmod a+r ${LIB}/$file 2>/dev/null
2897 if [ -r ${LIB}/reg_types.h ]; then
2898 if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
2899 if [ -r ${LIB}/sys/lc_core.h ]; then
2900 if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
2901 if [ -r ${LIB}/regex.h ]; then
2902 if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
2905 echo Fixing reg_types.h, regex.h, sys/lc_core.h
2906 for file in reg_types.h sys/lc_core.h; do
2907 sed -e 's/regex_t/__regex_t/g' \
2908 -e 's/regoff_t/__regoff_t/g' \
2909 -e 's/regmatch_t/__regmatch_t/g' \
2910 ${LIB}/$file > ${LIB}/${file}.sed
2911 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2913 sed -e '/#include <reg_types.h>/a\
2914 typedef __regex_t regex_t;\
2915 typedef __regoff_t regoff_t;\
2916 typedef __regmatch_t regmatch_t;\
2918 ${LIB}/regex.h > ${LIB}/regex.h.sed
2919 rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
2926 for file in reg_types.h regex.h sys/lc_core.h; do
2927 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2930 # Find any include directives that use "file".
2931 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2932 dir=`echo $file | sed -e s'|/[^/]*$||'`
2933 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2938 # AIX headers define NULL to be cast to a void pointer, which is illegal
2940 for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h sys/dir.h sys/param.h sys/types.h ; do
2941 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2942 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2943 chmod +w ${LIB}/$file 2>/dev/null
2944 chmod a+r ${LIB}/$file 2>/dev/null
2947 if [ -r ${LIB}/$file ]; then
2948 if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
2949 echo "Fixing $file, bad NULL macro"
2950 sed -e 's/^#[ ]*define[ ]*NULL[ ]*((void[ ]*\*)0)/#define NULL 0/' \
2951 ${LIB}/$file > ${LIB}/${file}.sed
2952 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2953 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2956 # Find any include directives that use "file".
2957 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2958 dir=`echo $file | sed -e s'|/[^/]*$||'`
2959 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2966 # HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
2968 base=`basename $file`
2969 if [ -r ${LIB}/$file ]; then
2970 file_to_fix=${LIB}/$file
2972 if [ -r ${INPUT}/$file ]; then
2973 file_to_fix=${INPUT}/$file
2978 if [ \! -z "$file_to_fix" ]; then
2979 echo Checking $file_to_fix
2980 sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\
2983 -e '/^#[ ]*define[ ]*MAXINT[ ]/a\
2985 ' $file_to_fix > /tmp/$base
2986 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
2989 echo Fixed $file_to_fix
2991 cp /tmp/$base ${LIB}/$file
2992 chmod a+r ${LIB}/$file
2993 # Find any include directives that use "file".
2994 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2995 dir=`echo $file | sed -e s'|/[^/]*$||'`
2996 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3003 # This loop does not appear to do anything, because it uses file
3004 # rather than $file when setting target. It also appears to be
3005 # unnecessary, since the main loop processes symbolic links.
3007 # echo 'Making internal symbolic non-directory links'
3009 # files=`find . -type l -print`
3010 # for file in $files; do
3011 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
3012 # if expr "$dest" : '[^/].*' > /dev/null; then
3013 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
3014 # if [ -f $target ]; then
3015 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
3021 # Make sure that any include files referenced using double quotes
3022 # exist in the fixed directory. This comes last since otherwise
3023 # we might end up deleting some of these files "because they don't
3027 while [ $# != 0 ]; do
3029 while [ $# != 0 ]; do
3030 # $1 is the directory to copy from, $2 is the unfixed file,
3031 # $3 is the fixed file name.
3034 if [ -r $2 ] && [ ! -r $3 ]; then
3035 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
3036 chmod +w $3 2>/dev/null
3037 chmod a+r $3 2>/dev/null
3039 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3040 dir=`echo $2 | sed -e s'|/[^/]*$||'`
3041 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
3042 newreq="$newreq $1 $dir/$include $dir2/$include"
3051 echo 'Cleaning up DONE files.'
3053 find . -name DONE -exec rm -f '{}' ';'
3055 echo 'Removing unneeded directories:'
3057 files=`find . -type d -print | sort -r`
3058 for file in $files; do
3059 rmdir $LIB/$file > /dev/null 2>&1