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[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
370 #ifndef __SIZE_TYPE__\
371 #define __SIZE_TYPE__ long unsigned int\
374 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
375 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
376 #ifndef __PTRDIFF_TYPE__\
377 #define __PTRDIFF_TYPE__ long int\
380 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
381 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
382 #ifndef __WCHAR_TYPE__\
383 #define __WCHAR_TYPE__ int\
387 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
390 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
391 ${LIB}/$file > ${LIB}/${file}.sed
392 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
393 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
396 # Find any include directives that use "file".
397 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
398 dir=`echo $file | sed -e s'|/[^/]*$||'`
399 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
405 # Fix one other error in this file: a mismatched quote not inside a C comment.
406 file=sundev/vuid_event.h
407 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
408 mkdir ${LIB}/sundev 2>/dev/null
409 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
410 chmod +w ${LIB}/$file 2>/dev/null
411 chmod a+r ${LIB}/$file 2>/dev/null
414 if [ -r ${LIB}/$file ]; then
415 echo Fixing $file comment
416 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
417 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
418 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
421 # Find any include directives that use "file".
422 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
423 dir=`echo $file | sed -e s'|/[^/]*$||'`
424 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
429 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
430 file=sunwindow/win_cursor.h
431 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
432 # mkdir ${LIB}/sunwindow 2>/dev/null
433 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
434 chmod +w ${LIB}/$file 2>/dev/null
436 if [ -r ${LIB}/$file ]; then
438 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
439 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
440 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
443 # Find any include directives that use "file".
444 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
445 dir=`echo $file | sed -e s'|/[^/]*$||'`
446 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
450 file=sunwindow/win_lock.h
451 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
452 # mkdir ${LIB}/sunwindow 2>/dev/null
453 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
454 chmod +w ${LIB}/$file 2>/dev/null
456 if [ -r ${LIB}/$file ]; then
458 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
459 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
460 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
463 # Find any include directives that use "file".
464 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
465 dir=`echo $file | sed -e s'|/[^/]*$||'`
466 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
471 # Fix this Sun file to avoid interfering with stddef.h.
473 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
474 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
475 chmod +w ${LIB}/$file 2>/dev/null
476 chmod a+r ${LIB}/$file 2>/dev/null
479 if [ -r ${LIB}/$file ]; then
481 sed -e '/[ ]size_t.*;/i\
488 -e '/[ ]ptrdiff_t.*;/i\
489 #ifndef _GCC_PTRDIFF_T\
490 #define _GCC_PTRDIFF_T
492 -e '/[ ]ptrdiff_t.*;/a\
495 -e '/[ ]wchar_t.*;/i\
496 #ifndef _GCC_WCHAR_T\
499 -e '/[ ]wchar_t.*;/a\
501 ' ${LIB}/$file > ${LIB}/${file}.sed
502 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
503 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
506 # Find any include directives that use "file".
507 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
508 dir=`echo $file | sed -e s'|/[^/]*$||'`
509 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
514 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
517 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
518 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
519 chmod +w ${LIB}/$file 2>/dev/null
520 chmod a+r ${LIB}/$file 2>/dev/null
523 if [ -r ${LIB}/$file ]; then
525 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
526 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
527 ${LIB}/$file > ${LIB}/${file}.sed
528 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
529 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
532 # Find any include directives that use "file".
533 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
534 dir=`echo $file | sed -e s'|/[^/]*$||'`
535 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
540 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
541 # the Norcroft compiler.
543 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
544 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
545 chmod +w ${LIB}/$file 2>/dev/null
546 chmod a+r ${LIB}/$file 2>/dev/null
549 if [ -r ${LIB}/$file ]; then
551 sed -e "s/___type p_type/p_type/" \
552 ${LIB}/$file > ${LIB}/${file}.sed
553 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
554 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
557 # Find any include directives that use "file".
558 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
559 dir=`echo $file | sed -e s'|/[^/]*$||'`
560 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
565 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
566 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
569 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
570 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
571 chmod +w ${LIB}/$file 2>/dev/null
572 chmod a+r ${LIB}/$file 2>/dev/null
575 if [ -r ${LIB}/$file ]; then
577 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
581 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
583 ' ${LIB}/$file > ${LIB}/${file}.sed
584 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
585 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
588 # Find any include directives that use "file".
589 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
590 dir=`echo $file | sed -e s'|/[^/]*$||'`
591 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
596 # Fix HP's use of ../machine/inline.h to refer to
597 # /usr/include/machine/inline.h
599 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
600 cp $file ${LIB}/$file
602 if [ -r ${LIB}/$file ] ; then
604 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
605 -e 's,"../machine/psl.h",<machine/psl.h>,' \
606 ${LIB}/$file > ${LIB}/${file}.sed
607 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
608 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
611 # Find any include directives that use "file".
612 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
613 dir=`echo $file | sed -e s'|/[^/]*$||'`
614 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
619 # Fix an error in this file: the #if says _cplusplus, not the double
620 # underscore __cplusplus that it should be
622 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
623 mkdir ${LIB}/rpcsvc 2>/dev/null
624 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
625 chmod +w ${LIB}/$file 2>/dev/null
626 chmod a+r ${LIB}/$file 2>/dev/null
629 if [ -r ${LIB}/$file ]; then
630 echo Fixing $file, __cplusplus macro
631 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
632 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
633 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
636 # Find any include directives that use "file".
637 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
638 dir=`echo $file | sed -e s'|/[^/]*$||'`
639 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
644 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
645 # structure definition.
647 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
648 mkdir ${LIB}/rpcsvc 2>/dev/null
649 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
650 chmod +w ${LIB}/$file 2>/dev/null
651 chmod a+r ${LIB}/$file 2>/dev/null
654 if [ -r ${LIB}/$file ]; then
655 echo Fixing $file, definition of statsswtch
656 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
657 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
658 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
661 # Find any include directives that use "file".
662 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
663 dir=`echo $file | sed -e s'|/[^/]*$||'`
664 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
669 # Fix an error in this file: a missing semi-colon at the end of the nodeent
670 # structure definition.
671 file=netdnet/dnetdb.h
672 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
673 mkdir ${LIB}/netdnet 2>/dev/null
674 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
675 chmod +w ${LIB}/$file 2>/dev/null
676 chmod a+r ${LIB}/$file 2>/dev/null
679 if [ -r ${LIB}/$file ]; then
680 echo Fixing $file, definition of nodeent
681 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
682 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
683 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
686 # Find any include directives that use "file".
687 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
688 dir=`echo $file | sed -e s'|/[^/]*$||'`
689 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
694 # Check for bad #ifdef line (in Ultrix 4.1)
696 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
697 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
698 chmod +w ${LIB}/$file 2>/dev/null
699 chmod a+r ${LIB}/$file 2>/dev/null
702 if [ -r ${LIB}/$file ]; then
703 echo Fixing $file, bad \#ifdef line
704 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
705 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
706 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
709 # Find any include directives that use "file".
710 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
711 dir=`echo $file | sed -e s'|/[^/]*$||'`
712 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
717 # Check for (...) in C++ code in HP/UX sys/file.h.
719 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
720 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
721 chmod +w ${LIB}/$file 2>/dev/null
722 chmod a+r ${LIB}/$file 2>/dev/null
725 if [ -r ${LIB}/$file ]; then
726 if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
727 echo Fixing $file, use of '(...)'
728 sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
729 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
730 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
733 # Find any include directives that use "file".
734 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
735 dir=`echo $file | sed -e s'|/[^/]*$||'`
736 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
742 # Check for superfluous `static' (in Ultrix 4.2)
743 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
745 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
746 mkdir ${LIB}/machine 2>/dev/null
747 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
748 chmod +w ${LIB}/$file 2>/dev/null
749 chmod a+r ${LIB}/$file 2>/dev/null
752 if [ -r ${LIB}/$file ]; then
753 echo Fixing $file, superfluous static and broken includes of other files.
754 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
755 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
756 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
757 ${LIB}/$file > ${LIB}/${file}.sed
758 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
759 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
762 # Find any include directives that use "file".
763 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
764 dir=`echo $file | sed -e s'|/[^/]*$||'`
765 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
767 # This file has an alternative name, mips/cpu.h. Fix that name, too.
768 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
769 mkdir ${LIB}/mips 2>&-
770 # Don't remove the file first, they may be the same file!
771 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
776 # Incorrect sprintf declaration in X11/Xmu.h
778 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
779 mkdir ${LIB}/X11 2>/dev/null
780 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
781 chmod +w ${LIB}/$file 2>/dev/null
782 chmod a+r ${LIB}/$file 2>/dev/null
785 if [ -r ${LIB}/$file ]; then
786 echo Fixing $file sprintf declaration
787 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
788 extern char * sprintf();\
789 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
790 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
791 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
794 # Find any include directives that use "file".
795 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
796 dir=`echo $file | sed -e s'|/[^/]*$||'`
797 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
802 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
803 # (It's not clear whether the right file name is this or X11/Xmu.h.)
805 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
806 mkdir ${LIB}/X11/Xmu 2>/dev/null
807 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
808 chmod +w ${LIB}/$file 2>/dev/null
809 chmod a+r ${LIB}/$file 2>/dev/null
812 if [ -r ${LIB}/$file ]; then
813 echo Fixing $file sprintf declaration
814 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
815 extern char * sprintf();\
816 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
817 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
818 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
821 # Find any include directives that use "file".
822 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
823 dir=`echo $file | sed -e s'|/[^/]*$||'`
824 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
829 # Check for missing ';' in struct
831 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
832 mkdir ${LIB}/netinet 2>/dev/null
833 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
834 chmod +w ${LIB}/$file 2>/dev/null
835 chmod a+r ${LIB}/$file 2>/dev/null
838 if [ -r ${LIB}/$file ]; then
840 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
841 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
842 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
845 # Find any include directives that use "file".
846 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
847 dir=`echo $file | sed -e s'|/[^/]*$||'`
848 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
853 # Fix the CAT macro in SunOS memvar.h.
854 file=pixrect/memvar.h
855 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
856 mkdir ${LIB}/pixrect 2>/dev/null
857 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
858 chmod +w ${LIB}/$file 2>/dev/null
859 chmod a+r ${LIB}/$file 2>/dev/null
862 if [ -r ${LIB}/$file ]; then
864 sed -e '/^#define.CAT(a,b)/ i\
866 #define CAT(a,b) a##b\
868 /^#define.CAT(a,b)/ a\
870 ' ${LIB}/$file > ${LIB}/${file}.sed
871 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
872 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
875 # Find any include directives that use "file".
876 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
877 dir=`echo $file | sed -e s'|/[^/]*$||'`
878 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
883 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
885 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
886 mkdir ${LIB}/rpcsvc 2>/dev/null
887 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
888 chmod +w ${LIB}/$file 2>/dev/null
889 chmod a+r ${LIB}/$file 2>/dev/null
892 if [ -r ${LIB}/$file ]; then
894 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
895 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
896 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
899 # Find any include directives that use "file".
900 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
901 dir=`echo $file | sed -e s'|/[^/]*$||'`
902 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
907 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
908 # Also wrap protection around size_t for m88k-sysv3 systems.
910 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
911 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
912 chmod +w ${LIB}/$file 2>/dev/null
913 chmod a+r ${LIB}/$file 2>/dev/null
916 if [ -r ${LIB}/$file ]; then
918 sed -e 's/int abort/void abort/g' \
919 -e 's/int free/void free/g' \
920 -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \
921 -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \
922 -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \
923 -e 's/int[ ][ ]*exit/void exit/g' \
924 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
928 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
931 ${LIB}/$file > ${LIB}/${file}.sed
932 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
933 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
936 # Find any include directives that use "file".
937 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
938 dir=`echo $file | sed -e s'|/[^/]*$||'`
939 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
944 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
945 # Also fix return type of {m,re}alloc in <malloc.h> on sysV68
947 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
948 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
949 chmod +w ${LIB}/$file 2>/dev/null
950 chmod a+r ${LIB}/$file 2>/dev/null
953 if [ -r ${LIB}/$file ]; then
955 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
956 -e 's/int[ ][ ]*free/void free/g' \
957 -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \
958 -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \
959 ${LIB}/$file > ${LIB}/${file}.sed
960 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
961 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
964 # Find any include directives that use "file".
965 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
966 dir=`echo $file | sed -e s'|/[^/]*$||'`
967 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
972 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
973 file=hsfs/hsfs_spec.h
974 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
975 mkdir ${LIB}/hsfs 2>/dev/null
976 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
977 chmod +w ${LIB}/$file 2>/dev/null
978 chmod a+r ${LIB}/$file 2>/dev/null
981 if [ -r ${LIB}/$file ]; then
983 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
984 ${LIB}/$file > ${LIB}/${file}.
985 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
986 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
989 # Find any include directives that use "file".
990 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
991 dir=`echo $file | sed -e s'|/[^/]*$||'`
992 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
997 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
999 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1000 mkdir ${LIB}/hsfs 2>/dev/null
1001 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1002 chmod +w ${LIB}/$file 2>/dev/null
1003 chmod a+r ${LIB}/$file 2>/dev/null
1006 if [ -r ${LIB}/$file ]; then
1008 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
1009 ${LIB}/$file > ${LIB}/${file}.sed
1010 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1011 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1014 # Find any include directives that use "file".
1015 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1016 dir=`echo $file | sed -e s'|/[^/]*$||'`
1017 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1022 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
1023 file=hsfs/iso_spec.h
1024 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1025 mkdir ${LIB}/hsfs 2>/dev/null
1026 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1027 chmod +w ${LIB}/$file 2>/dev/null
1028 chmod a+r ${LIB}/$file 2>/dev/null
1031 if [ -r ${LIB}/$file ]; then
1033 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1034 ${LIB}/$file > ${LIB}/${file}.sed
1035 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1036 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1039 # Find any include directives that use "file".
1040 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1041 dir=`echo $file | sed -e s'|/[^/]*$||'`
1042 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1047 # Incorrect #include in Sony News-OS 3.2.
1048 file=machine/machparam.h
1049 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1050 mkdir ${LIB}/machine 2>/dev/null
1051 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1052 chmod +w ${LIB}/$file 2>/dev/null
1053 chmod a+r ${LIB}/$file 2>/dev/null
1056 if [ -r ${LIB}/$file ]; then
1057 echo Fixing $file, incorrect \#include
1058 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1059 ${LIB}/$file > ${LIB}/${file}.
1060 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1061 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1064 # Find any include directives that use "file".
1065 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1066 dir=`echo $file | sed -e s'|/[^/]*$||'`
1067 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1072 # Multiline comment after typedef on IRIX 4.0.1.
1074 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1075 mkdir ${LIB}/sys 2>/dev/null
1076 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1077 chmod +w ${LIB}/$file 2>/dev/null
1078 chmod a+r ${LIB}/$file 2>/dev/null
1081 if [ -r ${LIB}/$file ]; then
1082 echo Fixing $file, comment in the middle of \#ifdef
1083 sed -e 's@type of the result@type of the result */@' \
1084 -e 's@of the sizeof@/* of the sizeof@' \
1085 ${LIB}/$file > ${LIB}/${file}.sed
1086 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1087 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1090 # Find any include directives that use "file".
1091 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1092 dir=`echo $file | sed -e s'|/[^/]*$||'`
1093 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1098 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1099 # header file, which embeds // comments inside multi-line /* */
1100 # comments. If this looks like the IRIX header file, we refix it by
1101 # just throwing away the // comments.
1103 if [ -r ${LIB}/$file ]; then
1104 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1105 echo Fixing $file, overeager sed script
1107 sed -e 's|//.*$||g' $file > ${LIB}/$file
1108 chmod +w ${LIB}/$file 2>/dev/null
1109 chmod a+r ${LIB}/$file 2>/dev/null
1113 # There is a similar problem with the VxWorks drv/netif/if_med.h file.
1114 file=drv/netif/if_med.h
1115 if [ -r ${LIB}/$file ]; then
1116 if egrep 'Wind River' ${LIB}/$file > /dev/null; then
1117 echo Fixing $file, overeager sed script
1119 sed -e 's|//.*$||g' $file > ${LIB}/$file
1120 chmod +w ${LIB}/$file 2>/dev/null
1121 chmod a+r ${LIB}/$file 2>/dev/null
1125 # And also with the HP-UX 10 sys/pci.h file
1127 if [ -r ${LIB}/$file ]; then
1128 if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
1129 echo Fixing $file, overeager sed script
1131 sed -e 's|//.*$||g' $file > ${LIB}/$file
1132 chmod +w ${LIB}/$file 2>/dev/null
1133 chmod a+r ${LIB}/$file 2>/dev/null
1137 # Some IRIX header files contains the string "//"
1138 for file in elf_abi.h elf.h; do
1139 if [ -r ${LIB}/$file ]; then
1140 echo Fixing $file, overeager sed script
1141 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1142 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1143 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1146 # Find any include directives that use "file".
1147 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1148 dir=`echo $file | sed -e s'|/[^/]*$||'`
1149 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1155 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1156 # previous definition.
1158 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1159 mkdir ${LIB}/rpc 2>/dev/null
1160 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1161 chmod +w ${LIB}/$file 2>/dev/null
1162 chmod a+r ${LIB}/$file 2>/dev/null
1165 if [ -r ${LIB}/$file ]; then
1166 echo Fixing $file, undefined type
1167 sed -e '/authdes_create.*struct sockaddr/i\
1170 ${LIB}/$file > ${LIB}/$file.sed
1171 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1172 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1175 # Find any include directives that use "file".
1176 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1177 dir=`echo $file | sed -e s'|/[^/]*$||'`
1178 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1183 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1186 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1187 mkdir ${LIB}/rpc 2>/dev/null
1188 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1189 chmod +w ${LIB}/$file 2>/dev/null
1190 chmod a+r ${LIB}/$file 2>/dev/null
1193 if [ -r ${LIB}/$file ]; then
1194 echo Fixing $file, undefined type
1195 sed -e '/xdrstdio_create.*struct __file_s/i\
1198 ${LIB}/$file > ${LIB}/$file.sed
1199 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1200 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1203 # Find any include directives that use "file".
1204 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1205 dir=`echo $file | sed -e s'|/[^/]*$||'`
1206 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1211 # Same problem with a file from SunOS 4.1.3 : a header file containing
1212 # the string "//" embedded in "/**/"
1213 file=sbusdev/audiovar.h
1214 if [ -r ${LIB}/$file ]; then
1215 echo Fixing $file, overeager sed script
1217 sed -e 's|//.*$||g' $file > ${LIB}/$file
1218 chmod +w ${LIB}/$file 2>/dev/null
1219 chmod a+r ${LIB}/$file 2>/dev/null
1222 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1223 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1224 # many other systems have similar text but correct versions of the file.
1225 # To ensure only Sun's is fixed, we grep for a likely unique string.
1226 # Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1228 if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then
1229 if [ ! -r ${LIB}/$file ]; then
1230 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1231 chmod +w ${LIB}/$file 2>/dev/null
1232 chmod a+r ${LIB}/$file 2>/dev/null
1234 if [ -r ${LIB}/$file ]; then
1235 echo Replacing $file
1236 cat > ${LIB}/$file << EOF
1237 /* This file was generated by fixincludes */
1238 #ifndef __memory_h__
1239 #define __memory_h__
1242 extern void *memccpy();
1243 extern void *memchr();
1244 extern void *memcpy();
1245 extern void *memset();
1247 extern char *memccpy();
1248 extern char *memchr();
1249 extern char *memcpy();
1250 extern char *memset();
1251 #endif /* __STDC__ */
1253 extern int memcmp();
1255 #endif /* __memory_h__ */
1260 # Fix return type of fread and fwrite on sysV68
1262 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1263 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1264 chmod +w ${LIB}/$file 2>/dev/null
1265 chmod a+r ${LIB}/$file 2>/dev/null
1268 if [ -r ${LIB}/$file ]; then
1269 echo Fixing $file, fread and fwrite return type
1270 sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\
1272 ${LIB}/$file > ${LIB}/${file}.sed
1273 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1274 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1277 # Find any include directives that use "file".
1278 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1279 dir=`echo $file | sed -e s'|/[^/]*$||'`
1280 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1285 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1287 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1288 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1289 chmod +w ${LIB}/$file 2>/dev/null
1290 chmod a+r ${LIB}/$file 2>/dev/null
1293 if [ -r ${LIB}/$file ]; then
1294 echo Fixing $file, non-const arg
1295 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1296 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1297 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1298 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1299 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1300 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1301 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1302 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1303 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1304 ${LIB}/$file > ${LIB}/${file}.sed
1305 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1306 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1309 # Find any include directives that use "file".
1310 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1311 dir=`echo $file | sed -e s'|/[^/]*$||'`
1312 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1317 # parameters conflict with C++ new on rs/6000
1318 for file in stdio.h unistd.h ; do
1319 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1320 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1321 chmod +w ${LIB}/$file 2>/dev/null
1324 if [ -r ${LIB}/$file ]; then
1325 echo Fixing $file, parameter name conflicts
1326 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1327 ${LIB}/$file > ${LIB}/${file}.sed
1328 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1329 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1332 # Find any include directives that use "file".
1333 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1334 dir=`echo $file | sed -e s'|/[^/]*$||'`
1335 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1341 # function class(double x) conflicts with C++ keyword on rs/6000
1343 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1344 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1345 chmod +w ${LIB}/$file 2>/dev/null
1346 chmod a+r ${LIB}/$file 2>/dev/null
1349 if [ -r ${LIB}/$file ]; then
1350 if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
1352 sed -e '/class[(]/i\
1357 ' ${LIB}/$file > ${LIB}/${file}.sed
1358 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1359 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1362 # Find any include directives that use "file".
1363 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1364 dir=`echo $file | sed -e s'|/[^/]*$||'`
1365 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1371 # Wrong fchmod prototype on RS/6000.
1373 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1374 mkdir ${LIB}/sys 2>/dev/null
1375 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1376 chmod +w ${LIB}/$file 2>/dev/null
1377 chmod a+r ${LIB}/$file 2>/dev/null
1380 if [ -r ${LIB}/$file ]; then
1381 echo Fixing $file, fchmod prototype
1382 sed -e 's/fchmod(char \*/fchmod(int/' \
1383 ${LIB}/$file > ${LIB}/$file.sed
1384 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1385 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1388 # Find any include directives that use "file".
1389 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1390 dir=`echo $file | sed -e s'|/[^/]*$||'`
1391 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1396 # There are several name conflicts with C++ reserved words in X11
1397 # header files. These are fixed in some versions, so don't do the
1398 # fixes if we find __cplusplus in the file. These were found on the
1401 # class in X11/ShellP.h
1403 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1404 mkdir ${LIB}/sys 2>/dev/null
1405 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1406 chmod +w ${LIB}/$file 2>/dev/null
1407 chmod a+r ${LIB}/$file 2>/dev/null
1410 if [ -r ${LIB}/$file ]; then
1411 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1414 echo Fixing $file, field class
1415 sed -e '/char [*]class;/i\
1420 -e '/char [*]class;/a\
1422 ' ${LIB}/$file > ${LIB}/${file}.sed
1423 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1425 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1428 # Find any include directives that use "file".
1429 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1430 dir=`echo $file | sed -e s'|/[^/]*$||'`
1431 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1435 # new in Xm/Traversal.h
1437 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1438 mkdir ${LIB}/sys 2>/dev/null
1439 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1440 chmod +w ${LIB}/$file 2>/dev/null
1441 chmod a+r ${LIB}/$file 2>/dev/null
1444 if [ -r ${LIB}/$file ]; then
1445 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1448 echo Fixing $file, uses of new
1449 sed -e '/Widget old, new;/i\
1454 -e '/Widget old, new;/a\
1457 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1458 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1460 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1463 # Find any include directives that use "file".
1464 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1465 dir=`echo $file | sed -e s'|/[^/]*$||'`
1466 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1470 # class in Xm/BaseClassI.h
1471 file=Xm/BaseClassI.h
1472 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1473 mkdir ${LIB}/sys 2>/dev/null
1474 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1475 chmod +w ${LIB}/$file 2>/dev/null
1476 chmod a+r ${LIB}/$file 2>/dev/null
1479 if [ -r ${LIB}/$file ]; then
1480 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1483 echo Fixing $file, prototype parameter name
1484 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1485 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1487 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1490 # Find any include directives that use "file".
1491 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1492 dir=`echo $file | sed -e s'|/[^/]*$||'`
1493 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1498 # NeXT 3.2 adds const prefix to some math functions. These conflict
1499 # with the built-in functions.
1501 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1502 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1503 chmod +w ${LIB}/$file 2>/dev/null
1505 if [ -r ${LIB}/$file ]; then
1507 sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
1508 -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
1509 -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1510 -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
1511 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1512 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1513 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1516 # Find any include directives that use "file".
1517 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1518 dir=`echo $file | sed -e s'|/[^/]*$||'`
1519 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1524 # NeXT 3.2 uses the word "template" as a parameter for some
1525 # functions. GCC reports an invalid use of a reserved key word
1526 # with the built-in functions. NeXT 3.2 includes the keyword
1527 # volatile in the prototype for abort(). This conflicts with
1528 # the built-in definition.
1530 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1531 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1532 chmod +w ${LIB}/$file 2>/dev/null
1534 if [ -r ${LIB}/$file ]; then
1536 sed -e '/\(.*template\)/s/template//' \
1537 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1538 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1539 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1542 # Find any include directives that use "file".
1543 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1544 dir=`echo $file | sed -e s'|/[^/]*$||'`
1545 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1550 # NeXT 3.2 includes the keyword volatile in the abort() and
1551 # exit() function prototypes. That conflicts with the
1552 # built-in functions.
1554 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1555 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1556 chmod +w ${LIB}/$file 2>/dev/null
1558 if [ -r ${LIB}/$file ]; then
1560 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1561 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1562 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1563 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1566 # Find any include directives that use "file".
1567 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1568 dir=`echo $file | sed -e s'|/[^/]*$||'`
1569 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1574 # sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
1575 # of struct rusage, so the prototype (added by fixproto) causes havoc.
1577 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1578 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1579 chmod +w ${LIB}/$file 2>/dev/null
1582 if [ -r ${LIB}/$file ] \
1583 && grep 'bos325,' ${LIB}/$file >/dev/null; then
1584 echo Fixing $file, wait3 declaration
1585 sed -e '/^extern pid_t wait3();$/i\
1588 ${LIB}/$file > ${LIB}/${file}.sed
1589 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1590 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1593 # Find any include directives that use "file".
1594 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1595 dir=`echo $file | sed -e s'|/[^/]*$||'`
1596 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1601 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1602 # Note that version 3 of the NeXT system has wait.h in a different directory,
1603 # so that this code won't do anything. But wait.h in version 3 has a
1604 # conditional, so it doesn't need this fix. So everything is okay.
1606 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1607 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1608 chmod +w ${LIB}/$file 2>/dev/null
1611 if [ -r ${LIB}/$file ] \
1612 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1613 echo Fixing $file, bad wait formal
1614 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1615 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1616 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1619 # Find any include directives that use "file".
1620 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1621 dir=`echo $file | sed -e s'|/[^/]*$||'`
1622 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1627 # Don't use or define the name va_list in stdio.h.
1628 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1630 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1631 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1632 chmod +w ${LIB}/$file 2>/dev/null
1633 chmod a+r ${LIB}/$file 2>/dev/null
1636 if [ -r ${LIB}/$file ]; then
1637 echo Fixing $file, use of va_list
1638 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1639 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1640 touch ${LIB}/${file}.sed
1642 (echo "#define __need___va_list"
1643 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1645 # Use __gnuc_va_list in arg types in place of va_list.
1646 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1647 # trailing parentheses and semicolon save all other systems from this.
1648 # Define __va_list__ (something harmless and unused) instead of va_list.
1649 # Don't claim to have defined va_list.
1650 sed -e 's@ va_list @ __gnuc_va_list @' \
1651 -e 's@ va_list)@ __gnuc_va_list)@' \
1652 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1653 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1654 -e 's@ va_list@ __va_list__@' \
1655 -e 's@\*va_list@*__va_list__@' \
1656 -e 's@ __va_list)@ __gnuc_va_list)@' \
1657 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1658 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1659 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1660 -e 's@_Va_LIST@_VA_LIST@' \
1661 ${LIB}/$file >> ${LIB}/${file}.sed
1663 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1664 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1667 # Find any include directives that use "file".
1668 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1669 dir=`echo $file | sed -e s'|/[^/]*$||'`
1670 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1675 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1677 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1678 if grep -s ULTRIX $file; then
1679 echo "/* This file intentionally left blank. */" > $LIB/$file
1683 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1684 # also get rid of bogus inline definitions in HP-UX 8.0
1686 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1687 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1688 chmod +w ${LIB}/$file 2>/dev/null
1689 chmod a+r ${LIB}/$file 2>/dev/null
1692 if [ -r ${LIB}/$file ]; then
1693 echo Fixing $file, non-const arg
1694 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1695 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1696 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1697 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1698 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1699 ${LIB}/$file > ${LIB}/${file}.sed
1700 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1701 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1704 # Find any include directives that use "file".
1705 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1706 dir=`echo $file | sed -e s'|/[^/]*$||'`
1707 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1712 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1714 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1715 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1716 chmod +w ${LIB}/$file 2>/dev/null
1717 chmod a+r ${LIB}/$file 2>/dev/null
1720 if [ -r ${LIB}/$file ]; then
1721 echo Fixing $file, recursive inclusion
1722 sed -e '/^#include <stdlib.h>/i\
1725 -e '/^#include <stdlib.h>/a\
1728 ${LIB}/$file > ${LIB}/${file}.sed
1729 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1730 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1733 # Find any include directives that use "file".
1734 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1735 dir=`echo $file | sed -e s'|/[^/]*$||'`
1736 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1741 # Avoid nested comments on Ultrix 4.3.
1743 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1744 mkdir ${LIB}/rpc 2>/dev/null
1745 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1746 chmod +w ${LIB}/$file 2>/dev/null
1747 chmod a+r ${LIB}/$file 2>/dev/null
1750 if [ -r ${LIB}/$file ]; then
1751 echo Fixing $file, nested comment
1752 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1753 ${LIB}/$file > ${LIB}/$file.sed
1754 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1755 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1758 # Find any include directives that use "file".
1759 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1760 dir=`echo $file | sed -e s'|/[^/]*$||'`
1761 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1766 # This file in RISC/os uses /**/ to concatenate two tokens.
1768 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1769 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1770 chmod +w ${LIB}/$file 2>/dev/null
1771 chmod a+r ${LIB}/$file 2>/dev/null
1773 if [ -r ${LIB}/$file ]; then
1774 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1775 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1776 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1779 # Find any include directives that use "file".
1780 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1781 dir=`echo $file | sed -e s'|/[^/]*$||'`
1782 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1788 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1789 mkdir ${LIB}/rpc 2>/dev/null
1790 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1791 chmod +w ${LIB}/$file 2>/dev/null
1792 chmod a+r ${LIB}/$file 2>/dev/null
1795 if [ -r ${LIB}/$file ]; then
1796 echo Fixing $file, nested comment
1797 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1798 ${LIB}/$file > ${LIB}/$file.sed
1799 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1800 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1803 # Find any include directives that use "file".
1804 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1805 dir=`echo $file | sed -e s'|/[^/]*$||'`
1806 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1811 # rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1812 # is defined for the alpha. The problem is the declaration of malloc.
1814 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1815 mkdir ${LIB}/rpc 2>/dev/null
1816 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1817 chmod +w ${LIB}/$file 2>/dev/null
1818 chmod a+r ${LIB}/$file 2>/dev/null
1820 if [ -r ${LIB}/$file ]; then
1821 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
1825 echo '#ifdef __cplusplus
1827 #endif' > ${LIB}/${file}.sed
1828 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1829 echo '#ifdef __cplusplus
1831 #endif' >> ${LIB}/${file}.sed
1832 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1833 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1836 # Find any include directives that use "file".
1837 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1838 dir=`echo $file | sed -e s'|/[^/]*$||'`
1839 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1845 # In limits.h, put #ifndefs around things that are supposed to be defined
1846 # in float.h to avoid redefinition errors if float.h is included first.
1847 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1848 # multi line comments and the inserted #endif winds up inside the
1849 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1850 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1851 # are there, and we do not add them ourselves.
1852 for file in limits.h sys/limits.h; do
1853 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1854 mkdir ${LIB}/sys 2>/dev/null
1855 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1856 chmod +w ${LIB}/$file 2>/dev/null
1857 chmod a+r ${LIB}/$file 2>/dev/null
1860 if [ -r ${LIB}/$file ]; then
1861 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1865 sed -e '/[ ]FLT_MIN[ ]/i\
1868 -e '/[ ]FLT_MIN[ ]/a\
1871 -e '/[ ]FLT_MAX[ ]/i\
1874 -e '/[ ]FLT_MAX[ ]/a\
1877 -e '/[ ]FLT_DIG[ ]/i\
1880 -e '/[ ]FLT_DIG[ ]/a\
1883 -e '/[ ]DBL_MIN[ ]/i\
1886 -e '/[ ]DBL_MIN[ ]/a\
1889 -e '/[ ]DBL_MAX[ ]/i\
1892 -e '/[ ]DBL_MAX[ ]/a\
1895 -e '/[ ]DBL_DIG[ ]/i\
1898 -e '/[ ]DBL_DIG[ ]/a\
1901 ${LIB}/$file > ${LIB}/${file}.sed
1902 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1904 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1905 echo Deleting ${LIB}/$file\; no fixes were needed.
1908 # Find any include directives that use "file".
1909 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1910 dir=`echo $file | sed -e s'|/[^/]*$||'`
1911 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1917 # In math.h, put #ifndefs around things that might be defined in a gcc
1918 # specific math-*.h file.
1920 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1921 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1922 chmod +w ${LIB}/$file 2>/dev/null
1923 chmod a+r ${LIB}/$file 2>/dev/null
1926 if [ -r ${LIB}/$file ]; then
1928 sed -e '/define[ ]HUGE_VAL[ ]/i\
1931 -e '/define[ ]HUGE_VAL[ ]/a\
1934 ${LIB}/$file > ${LIB}/${file}.sed
1935 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1937 # In addition, copy the definition of DBL_MAX from float.h
1938 # if math.h requires one. The Lynx math.h requires it.
1939 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1940 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1943 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1944 if [ "$dbl_max_def" != "" ]; then
1945 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1946 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1947 ${LIB}/$file > ${LIB}/${file}.sed
1948 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1953 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1954 echo Deleting ${LIB}/$file\; no fixes were needed.
1957 # Find any include directives that use "file".
1958 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1959 dir=`echo $file | sed -e s'|/[^/]*$||'`
1960 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1965 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1967 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1968 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1969 chmod +w ${LIB}/$file 2>/dev/null
1970 chmod a+r ${LIB}/$file 2>/dev/null
1973 if [ -r ${LIB}/$file ]; then
1975 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1976 ${LIB}/$file > ${LIB}/${file}.sed
1977 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1978 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1981 # Find any include directives that use "file".
1982 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1983 dir=`echo $file | sed -e s'|/[^/]*$||'`
1984 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1989 # Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
1990 # in string.h on sysV68
1991 # Correct the return type for strlen in string.h on Lynx.
1992 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1993 # Add missing const for strdup on OSF/1 V3.0.
1994 # On sysV88 layout is slightly different.
1996 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1997 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1998 chmod +w ${LIB}/$file 2>/dev/null
1999 chmod a+r ${LIB}/$file 2>/dev/null
2002 if [ -r ${LIB}/$file ]; then
2003 echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
2004 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
2005 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
2006 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
2007 -e '/^extern char$/N' \
2008 -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\
2009 -e '/^ strncmp(),$/N'\
2010 -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\
2011 extern unsigned int\
2013 -e '/^extern int$/N'\
2014 -e 's/^extern int\(\n strlen(),\)/extern size_t\1/' \
2015 ${LIB}/$file > ${LIB}/${file}.sed
2016 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2017 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2020 # Find any include directives that use "file".
2021 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2022 dir=`echo $file | sed -e s'|/[^/]*$||'`
2023 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2028 # Correct the return type for strlen in strings.h in SunOS 4.
2030 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2031 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2032 chmod +w ${LIB}/$file 2>/dev/null
2033 chmod a+r ${LIB}/$file 2>/dev/null
2036 if [ -r ${LIB}/$file ]; then
2038 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
2039 ${LIB}/$file > ${LIB}/${file}.sed
2040 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2041 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2044 # Find any include directives that use "file".
2045 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2046 dir=`echo $file | sed -e s'|/[^/]*$||'`
2047 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2052 # Delete the '#define void int' line from curses.h on Lynx
2054 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2055 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2056 chmod +w ${LIB}/$file 2>/dev/null
2057 chmod a+r ${LIB}/$file 2>/dev/null
2060 if [ -r ${LIB}/$file ]; then
2062 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
2063 ${LIB}/$file > ${LIB}/${file}.sed
2064 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2065 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2068 # Find any include directives that use "file".
2069 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2070 dir=`echo $file | sed -e s'|/[^/]*$||'`
2071 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2076 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
2078 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2079 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2080 chmod +w ${LIB}/$file 2>/dev/null
2081 chmod a+r ${LIB}/$file 2>/dev/null
2084 if [ -r ${LIB}/$file ]; then
2086 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
2087 ${LIB}/$file > ${LIB}/${file}.sed
2088 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2089 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2092 # Find any include directives that use "file".
2093 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2094 dir=`echo $file | sed -e s'|/[^/]*$||'`
2095 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2100 # For C++, avoid any typedef or macro definition of bool, and use the
2101 # built in type instead.
2102 for files in curses.h; do
2103 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
2104 if [ ! -r ${LIB}/$file ]; then
2105 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2106 chmod +w ${LIB}/$file 2>/dev/null
2107 chmod a+r ${LIB}/$file 2>/dev/null
2111 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
2114 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
2117 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\
2120 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\
2123 ${LIB}/$file > ${LIB}/${file}.sed
2124 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2125 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2128 # Find any include directives that use "file".
2129 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2130 dir=`echo $file | sed -e s'|/[^/]*$||'`
2131 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2137 # Fix incorrect S_IF* definitions on m88k-sysv3.
2139 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2140 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2141 chmod +w ${LIB}/$file 2>/dev/null
2142 chmod a+r ${LIB}/$file 2>/dev/null
2145 if [ -r ${LIB}/$file ]; then
2147 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)/' \
2148 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2149 ${LIB}/$file > ${LIB}/${file}.sed
2150 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2151 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2154 # Find any include directives that use "file".
2155 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2156 dir=`echo $file | sed -e s'|/[^/]*$||'`
2157 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2162 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
2163 for file in stdio.h stdlib.h; do
2164 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2165 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2166 chmod +w ${LIB}/$file 2>/dev/null
2167 chmod a+r ${LIB}/$file 2>/dev/null
2170 if [ -r ${LIB}/$file ]; then
2171 echo Fixing $file, getopt declaration
2172 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2173 ${LIB}/$file > ${LIB}/${file}.sed
2174 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2175 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2178 # Find any include directives that use "file".
2179 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2180 dir=`echo $file | sed -e s'|/[^/]*$||'`
2181 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2187 # Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2188 # The original ones fail if uninitialized externs are not common.
2189 # This is the default for all ANSI standard C++ compilers.
2190 for file in pthread.h; do
2191 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2192 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2193 chmod +w ${LIB}/$file 2>/dev/null
2194 chmod a+r ${LIB}/$file 2>/dev/null
2197 if [ -r ${LIB}/$file ]; then
2198 echo Fixing $file, __page_size* declarations
2199 sed -e 's/^int __page_size/extern int __page_size/' \
2200 ${LIB}/$file > ${LIB}/${file}.sed
2201 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2202 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2205 # Find any include directives that use "file".
2206 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2207 dir=`echo $file | sed -e s'|/[^/]*$||'`
2208 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2214 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2215 # need to fix some additional files. This is the same test for ISC that
2217 if test -d /etc/conf/kconfig.d \
2218 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2219 echo "Fixing ISC __STDC__ goof in several files..."
2220 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2222 if test -r ${LIB}/$name; then
2227 # On Interactive 2.2, certain traditional Unix definitions
2228 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2229 # defined, not just if _POSIX_SOURCE is defined. This makes it
2230 # impossible to compile any nontrivial program except with -posix.
2232 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2233 < $file > ${LIB}/$name.
2234 mv ${LIB}/$name. ${LIB}/$name
2237 echo "Fixing ISC fmod declaration"
2238 # This one's already been fixed for other things.
2240 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2243 echo "Fixing nested comments in ISC <sys/limits.h>"
2245 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2246 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2249 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2250 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2251 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2252 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2254 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2255 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2256 chmod +w ${LIB}/$file 2>/dev/null
2257 chmod a+r ${LIB}/$file 2>/dev/null
2260 if [ -r ${LIB}/$file ]; then
2261 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2262 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2263 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2266 # Find any include directives that use "file".
2267 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2268 dir=`echo $file | sed -e s'|/[^/]*$||'`
2269 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2275 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2276 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2277 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
2279 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2280 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2281 chmod +w ${LIB}/$file 2>/dev/null
2282 chmod a+r ${LIB}/$file 2>/dev/null
2285 if [ -r ${LIB}/$file ]; then
2286 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2287 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2288 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2291 # Find any include directives that use "file".
2292 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2293 dir=`echo $file | sed -e s'|/[^/]*$||'`
2294 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2300 # libm.a on m88k-motorola-sysv3 contains a stupid optimization for function
2301 # hypot(), which returns the second argument without even looking at its value
2302 # if the other is 0.0
2304 if [ $target_canonical = m88k-motorola-sysv3 ]; then
2305 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2306 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2307 chmod +w ${LIB}/$file 2>/dev/null
2308 chmod a+r ${LIB}/$file 2>/dev/null
2311 if [ -r ${LIB}/$file ]; then
2312 echo Fixing $file, hypot definition
2313 sed -e '/^extern double hypot();$/a\
2314 \/* Workaround a stupid Motorola optimization if one\
2315 of x or y is 0.0 and the other is negative! *\/\
2317 static __inline__ double fake_hypot (double x, double y)\
2319 static __inline__ double fake_hypot (x, y)\
2323 return fabs (hypot (x, y));\
2325 #define hypot fake_hypot
2327 ${LIB}/$file > ${LIB}/${file}.sed
2328 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2329 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2335 # math.h on SunOS 4 puts the declaration of matherr before the definition
2336 # of struct exception, so the prototype (added by fixproto) causes havoc.
2338 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2339 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2340 chmod +w ${LIB}/$file 2>/dev/null
2341 chmod a+r ${LIB}/$file 2>/dev/null
2344 if [ -r ${LIB}/$file ]; then
2345 echo Fixing $file, matherr declaration
2346 sed -e '/^struct exception/,$b' \
2350 ${LIB}/$file > ${LIB}/${file}.sed
2351 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2352 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2355 # Find any include directives that use "file".
2356 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2357 dir=`echo $file | sed -e s'|/[^/]*$||'`
2358 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2363 # assert.h and sys/mman.h on HP/UX are not C++ ready, even though
2364 # NO_IMPLICIT_EXTERN_C is defined on HP/UX.
2365 for file in assert.h sys/mman.h; do
2366 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2367 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2368 chmod +w ${LIB}/$file 2>/dev/null
2369 chmod a+r ${LIB}/$file 2>/dev/null
2372 if [ -r ${LIB}/$file ]; then
2373 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2374 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2378 echo '#ifdef __cplusplus
2380 #endif' > ${LIB}/${file}.sed
2381 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2382 echo '#ifdef __cplusplus
2384 #endif' >> ${LIB}/${file}.sed
2385 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2387 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2390 # Find any include directives that use "file".
2391 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2392 dir=`echo $file | sed -e s'|/[^/]*$||'`
2393 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2399 # check for broken assert.h that needs stdio.h or stdlib.h
2401 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2402 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2403 chmod +w ${LIB}/$file 2>/dev/null
2404 chmod a+r ${LIB}/$file 2>/dev/null
2407 if [ -r ${LIB}/$file ]; then
2408 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
2409 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2412 echo "Fixing $file (needs stdio.h)"
2413 echo '#include <stdio.h>' >>${LIB}/$file
2416 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
2417 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
2418 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2421 echo "Fixing $file (needs stdlib.h)"
2422 echo '#ifdef __cplusplus
2424 #endif' >>${LIB}/$file
2427 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2430 # Find any include directives that use "file".
2431 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2432 dir=`echo $file | sed -e s'|/[^/]*$||'`
2433 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2438 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2440 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2441 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2442 chmod +w ${LIB}/$file 2>/dev/null
2443 chmod a+r ${LIB}/$file 2>/dev/null
2446 if [ -r ${LIB}/$file ]; then
2447 echo Fixing $file, sbrk declaration
2448 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2449 ${LIB}/$file > ${LIB}/${file}.sed
2450 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2451 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2454 # Find any include directives that use "file".
2455 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2456 dir=`echo $file | sed -e s'|/[^/]*$||'`
2457 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2462 # This file on SunOS 4 has a very large macro. When the sed loop
2463 # tries pull it in, it overflows the pattern space size of the SunOS
2464 # sed (GNU sed does not have this problem). Since the file does not
2465 # require fixing, we remove it from the fixed directory.
2466 file=sundev/ipi_error.h
2467 if [ -r ${LIB}/$file ]; then
2468 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2472 # Put cpp wrappers around these include files to avoid redeclaration
2473 # errors during multiple inclusion on m88k-tektronix-sysv3.
2474 for file in time.h sys/time.h ; do
2475 if egrep '#ifndef' $file >/dev/null 2>&1; then
2478 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2479 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2480 chmod +w ${LIB}/$file 2>/dev/null
2482 if [ -r ${LIB}/$file ]; then
2483 echo Fixing $file, to protect against multiple inclusion.
2484 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2485 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2486 echo "#define __GCC_GOT_${cpp_wrapper}_"
2488 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2489 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2494 # Fix fcntl prototype in fcntl.h on LynxOS.
2496 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2497 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2498 chmod +w ${LIB}/$file 2>/dev/null
2499 chmod a+r ${LIB}/$file 2>/dev/null
2502 if [ -r ${LIB}/$file ]; then
2503 echo Fixing $file, fcntl declaration
2504 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2505 ${LIB}/$file > ${LIB}/${file}.sed
2506 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2507 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2510 # Find any include directives that use "file".
2511 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2512 dir=`echo $file | sed -e s'|/[^/]*$||'`
2513 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2518 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2519 file=arch/i960/archI960.h
2520 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2521 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2522 chmod +w ${LIB}/$file 2>/dev/null
2523 chmod a+r ${LIB}/$file 2>/dev/null
2526 if [ -r ${LIB}/$file ]; then
2528 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2529 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2530 ${LIB}/$file > ${LIB}/${file}.sed
2531 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2532 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2535 # Find any include directives that use "file".
2536 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2537 dir=`echo $file | sed -e s'|/[^/]*$||'`
2538 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2543 # Make VxWorks header which is almost gcc ready fully gcc ready.
2544 file=types/vxTypesBase.h
2545 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2546 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2547 chmod +w ${LIB}/$file 2>/dev/null
2548 chmod a+r ${LIB}/$file 2>/dev/null
2551 if [ -r ${LIB}/$file ]; then
2553 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2555 #ifndef _GCC_SIZE_T\
2561 -e '/[ ]ptrdiff_t/i\
2562 #ifndef _GCC_PTRDIFF_T\
2563 #define _GCC_PTRDIFF_T
2565 -e '/[ ]ptrdiff_t/a\
2569 #ifndef _GCC_WCHAR_T\
2570 #define _GCC_WCHAR_T
2575 ${LIB}/$file > ${LIB}/${file}.sed
2576 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2577 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2580 # Find any include directives that use "file".
2581 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2582 dir=`echo $file | sed -e s'|/[^/]*$||'`
2583 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2588 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2590 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2591 mkdir ${LIB}/sys 2>/dev/null
2592 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2593 chmod +w ${LIB}/$file 2>/dev/null
2594 chmod a+r ${LIB}/$file 2>/dev/null
2597 if [ -r ${LIB}/$file ]; then
2598 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2601 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2602 && [ -r types/vxTypesOld.h ]; then
2604 sed -e '/#define[ ][ ]*__INCstath/a\
2605 #include <types/vxTypesOld.h>
2607 ${LIB}/$file > ${LIB}/${file}.sed
2608 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2611 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2614 # Find any include directives that use "file".
2615 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2616 dir=`echo $file | sed -e s'|/[^/]*$||'`
2617 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2622 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2624 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2625 mkdir ${LIB}/sys 2>/dev/null
2626 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2627 chmod +w ${LIB}/$file 2>/dev/null
2628 chmod a+r ${LIB}/$file 2>/dev/null
2631 if [ -r ${LIB}/$file ]; then
2632 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2634 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2635 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2637 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2640 # Find any include directives that use "file".
2641 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2642 dir=`echo $file | sed -e s'|/[^/]*$||'`
2643 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2648 # Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2650 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2651 mkdir ${LIB}/sys 2>/dev/null
2652 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2653 chmod +w ${LIB}/$file 2>/dev/null
2654 chmod a+r ${LIB}/$file 2>/dev/null
2657 if [ -r ${LIB}/$file ]; then
2658 if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
2660 sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
2661 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2663 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2666 # Find any include directives that use "file".
2667 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2668 dir=`echo $file | sed -e s'|/[^/]*$||'`
2669 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2674 # Another bad dependency in VxWorks 5.2 <time.h>.
2676 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2677 mkdir ${LIB}/sys 2>/dev/null
2678 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2679 chmod +w ${LIB}/$file 2>/dev/null
2680 chmod a+r ${LIB}/$file 2>/dev/null
2683 if [ -r ${LIB}/$file ]; then
2684 if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
2685 if [ -r vxWorks.h ]; then
2687 sed -e '/VOIDFUNCPTR/i\
2688 #ifndef __gcc_VOIDFUNCPTR_defined\
2690 typedef void (*__gcc_VOIDFUNCPTR) (...);\
2692 typedef void (*__gcc_VOIDFUNCPTR) ();\
2694 #define __gcc_VOIDFUNCPTR_defined\
2697 -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
2698 ${LIB}/$file > ${LIB}/${file}.sed
2699 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2702 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2705 # Find any include directives that use "file".
2706 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2707 dir=`echo $file | sed -e s'|/[^/]*$||'`
2708 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2713 # This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
2714 # doesn't understand it.
2716 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2717 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2718 chmod +w ${LIB}/$file 2>/dev/null
2719 chmod a+r ${LIB}/$file 2>/dev/null
2722 if [ -r ${LIB}/$file ]; then
2723 echo "Fixing __asm directive in sys/param.h"
2724 sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
2725 ${LIB}/$file > ${LIB}/${file}.sed
2726 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2727 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2730 # Find any include directives that use "file".
2731 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2732 dir=`echo $file | sed -e s'|/[^/]*$||'`
2733 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2738 # signal.h on SunOS defines signal using (), which causes trouble when
2739 # compiling with g++ -pedantic.
2740 for file in signal.h sys/signal.h; do
2741 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2742 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2743 chmod +w ${LIB}/$file 2>/dev/null
2744 chmod a+r ${LIB}/$file 2>/dev/null
2747 if [ -r ${LIB}/$file ]; then
2748 echo "Checking for bad C++ prototype in $file"
2749 sed -e '/^void (\*signal())();$/i\
2751 void (*signal(...))(...);\
2754 -e '/^void (\*signal())();$/a\
2757 ${LIB}/$file > ${LIB}/${file}.sed
2758 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2759 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2762 # Find any include directives that use "file".
2763 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2764 dir=`echo $file | sed -e s'|/[^/]*$||'`
2765 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2771 # sys/signal.h on some versions of AIX uses volatile in the typedef of
2772 # sig_atomic_t, which causes gcc to generate a warning about duplicate
2773 # volatile when a sig_atomic_t variable is declared volatile, as
2774 # required by ANSI C.
2776 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2777 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2778 chmod +w ${LIB}/$file 2>/dev/null
2779 chmod a+r ${LIB}/$file 2>/dev/null
2782 if [ -r ${LIB}/$file ]; then
2783 echo "Checking for duplicate volatile in sys/signal.h"
2784 sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
2785 ${LIB}/$file > ${LIB}/${file}.sed
2786 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2787 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2790 # Find any include directives that use "file".
2791 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2792 dir=`echo $file | sed -e s'|/[^/]*$||'`
2793 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2798 # Some math.h files define struct exception, which conflicts with
2799 # the class exception defined in the C++ file std/stdexcept.h. We
2800 # redefine it to __math_exception. This is not a great fix, but I
2801 # haven't been able to think of anything better.
2803 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2804 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2805 chmod +w ${LIB}/$file 2>/dev/null
2806 chmod a+r ${LIB}/$file 2>/dev/null
2809 if [ -r ${LIB}/$file ]; then
2810 echo Fixing $file, exception
2811 sed -e '/struct exception/i\
2813 #define exception __math_exception\
2815 -e '/struct exception/a\
2818 #endif' ${LIB}/$file > ${LIB}/${file}.sed
2819 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2820 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
2823 #define exception __math_exception\
2828 #endif' ${LIB}/$file > ${LIB}/${file}.sed
2829 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2831 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2834 # Find any include directives that use "file".
2835 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2836 dir=`echo $file | sed -e s'|/[^/]*$||'`
2837 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2842 # rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers.
2844 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2845 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2846 chmod +w ${LIB}/$file 2>/dev/null
2847 chmod a+r ${LIB}/$file 2>/dev/null
2850 if [ -r ${LIB}/$file ]; then
2851 echo "Checking for needed C++ prototype in $file"
2852 sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
2858 $LIB/$file > ${LIB}/${file}.sed
2860 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2861 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2864 # Find any include directives that use "file".
2865 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2866 dir=`echo $file | sed -e s'|/[^/]*$||'`
2867 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2872 # sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2873 # defining regex.h related types. This causes libg++ build and usage failures.
2874 # Fixing this correctly requires checking and modifying 3 files.
2875 for file in reg_types.h regex.h sys/lc_core.h; do
2876 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2877 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2878 chmod +w ${LIB}/$file 2>/dev/null
2879 chmod a+r ${LIB}/$file 2>/dev/null
2882 if [ -r ${LIB}/reg_types.h ]; then
2883 if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
2884 if [ -r ${LIB}/sys/lc_core.h ]; then
2885 if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
2886 if [ -r ${LIB}/regex.h ]; then
2887 if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
2890 echo Fixing reg_types.h, regex.h, sys/lc_core.h
2891 for file in reg_types.h sys/lc_core.h; do
2892 sed -e 's/regex_t/__regex_t/g' \
2893 -e 's/regoff_t/__regoff_t/g' \
2894 -e 's/regmatch_t/__regmatch_t/g' \
2895 ${LIB}/$file > ${LIB}/${file}.sed
2896 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2898 sed -e '/#include <reg_types.h>/a\
2899 typedef __regex_t regex_t;\
2900 typedef __regoff_t regoff_t;\
2901 typedef __regmatch_t regmatch_t;\
2903 ${LIB}/regex.h > ${LIB}/regex.h.sed
2904 rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
2911 for file in reg_types.h regex.h sys/lc_core.h; do
2912 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2915 # Find any include directives that use "file".
2916 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2917 dir=`echo $file | sed -e s'|/[^/]*$||'`
2918 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2923 # AIX headers define NULL to be cast to a void pointer, which is illegal
2925 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
2926 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2927 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2928 chmod +w ${LIB}/$file 2>/dev/null
2929 chmod a+r ${LIB}/$file 2>/dev/null
2932 if [ -r ${LIB}/$file ]; then
2933 if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
2934 echo "Fixing $file, bad NULL macro"
2935 sed -e 's/^#[ ]*define[ ]*NULL[ ]*((void[ ]*\*)0)/#define NULL 0/' \
2936 ${LIB}/$file > ${LIB}/${file}.sed
2937 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2938 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2941 # Find any include directives that use "file".
2942 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2943 dir=`echo $file | sed -e s'|/[^/]*$||'`
2944 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2951 # HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
2953 base=`basename $file`
2954 if [ -r ${LIB}/$file ]; then
2955 file_to_fix=${LIB}/$file
2957 if [ -r ${INPUT}/$file ]; then
2958 file_to_fix=${INPUT}/$file
2963 if [ \! -z "$file_to_fix" ]; then
2964 echo Checking $file_to_fix
2965 sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\
2968 -e '/^#[ ]*define[ ]*MAXINT[ ]/a\
2970 ' $file_to_fix > /tmp/$base
2971 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
2974 echo Fixed $file_to_fix
2976 cp /tmp/$base ${LIB}/$file
2977 chmod a+r ${LIB}/$file
2978 # Find any include directives that use "file".
2979 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2980 dir=`echo $file | sed -e s'|/[^/]*$||'`
2981 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2988 # This loop does not appear to do anything, because it uses file
2989 # rather than $file when setting target. It also appears to be
2990 # unnecessary, since the main loop processes symbolic links.
2992 # echo 'Making internal symbolic non-directory links'
2994 # files=`find . -type l -print`
2995 # for file in $files; do
2996 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
2997 # if expr "$dest" : '[^/].*' > /dev/null; then
2998 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
2999 # if [ -f $target ]; then
3000 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
3006 # Make sure that any include files referenced using double quotes
3007 # exist in the fixed directory. This comes last since otherwise
3008 # we might end up deleting some of these files "because they don't
3012 while [ $# != 0 ]; do
3014 while [ $# != 0 ]; do
3015 # $1 is the directory to copy from, $2 is the unfixed file,
3016 # $3 is the fixed file name.
3019 if [ -r $2 ] && [ ! -r $3 ]; then
3020 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
3021 chmod +w $3 2>/dev/null
3022 chmod a+r $3 2>/dev/null
3024 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3025 dir=`echo $2 | sed -e s'|/[^/]*$||'`
3026 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
3027 newreq="$newreq $1 $dir/$include $dir2/$include"
3036 echo 'Cleaning up DONE files.'
3038 find . -name DONE -exec rm -f '{}' ';'
3040 echo 'Removing unneeded directories:'
3042 files=`find . -type d -print | sort -r`
3043 for file in $files; do
3044 rmdir $LIB/$file > /dev/null 2>&1