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 where gcc sources (and sometimes special include files) live.
9 # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
10 # sure somebody doesn't try to use arg3 for something incompatible. -- gumby
11 SRCDIR=${3-${SRCDIR-.}}
13 # Directory containing the original header files.
14 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
15 INPUT=${2-${INPUT-/usr/include}}
17 # Directory in which to store the results.
18 LIB=${1?"fixincludes: output directory not specified"}
20 # Define PWDCMD as a command to use to get the working dir
21 # in the form that we want.
25 # On an Apollo, discard everything before `/usr'.
26 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
33 # Make sure it exists.
34 if [ ! -d $LIB ]; then
38 # Make LIB absolute only if needed to avoid problems with the amd.
43 cd $LIB; LIB=`${PWDCMD}`
47 # Make SRCDIR absolute only if needed to avoid problems with the amd.
53 cd $SRCDIR; SRCDIR=`${PWDCMD}`
57 # Fail if no arg to specify a directory for the output.
59 then echo fixincludes: no output directory specified
63 echo Building fixed headers in ${LIB}
65 # Determine whether this system has symbolic links.
66 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
67 rm -f $LIB/ShouldNotExist
69 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
70 rm -f /tmp/ShouldNotExist
76 echo Finding directories and links to directories
78 # Find all directories and all symlinks that point to directories.
79 # Put the list in $files.
80 # Each time we find a symlink, add it to newdirs
81 # so that we do another find within the dir the link points to.
82 # Note that $files may have duplicates in it;
83 # later parts of this file are supposed to ignore them.
86 while [ -n "$dirs" ] && [ $levels -gt 0 ]
88 levels=`expr $levels - 1`
92 echo " Searching $INPUT/$d"
98 # Find all directories under $d, relative to $d, excluding $d itself.
99 files="$files `find $d -type d -print | \
100 sed -e '/\/\.$/d' -e '/^\.$/d'`"
101 # Find all links to directories.
102 # Using `-exec test -d' in find fails on some systems,
103 # and trying to run test via sh fails on others,
104 # so this is the simplest alternative left.
105 # First find all the links, then test each one.
108 theselinks=`find $d -type l -print`
109 for d1 in $theselinks --dummy--
111 # If the link points to a directory,
112 # add that dir to $newdirs
116 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
118 newdirs="$newdirs $d1"
128 echo "All directories (including links to directories):"
131 for file in $files; do
133 if [ ! -d $LIB/$file ]
134 then mkdir $LIB/$file
139 # treetops gets an alternating list
140 # of old directories to copy
141 # and the new directories to copy to.
142 treetops="${INPUT} ${LIB}"
145 echo 'Making symbolic directory links'
146 for file in $files; do
147 dest=`ls -ld $file | sed -n 's/.*-> //p'`
150 # In case $dest is relative, get to $file's dir first.
152 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
153 # Check that the target directory exists.
154 # Redirections changed to avoid bug in sh on Ultrix.
155 (cd $dest) > /dev/null 2>&1
158 # X gets the dir that the link actually leads to.
160 # If a link points to ., make a similar link to .
161 if [ $x = $INPUT ]; then
162 echo $file '->' . ': Making link'
163 rm -fr ${LIB}/$file > /dev/null 2>&1
164 ln -s . ${LIB}/$file > /dev/null 2>&1
165 # If link leads back into ${INPUT},
166 # make a similar link here.
167 elif expr $x : "${INPUT}/.*" > /dev/null; then
168 # Y gets the actual target dir name, relative to ${INPUT}.
169 y=`echo $x | sed -n "s&${INPUT}/&&p"`
170 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
172 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
173 echo $file '->' $dots$y ': Making link'
174 rm -fr ${LIB}/$file > /dev/null 2>&1
175 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
177 # If the link is to a dir $target outside ${INPUT},
178 # repoint the link at ${INPUT}/root$target
179 # and process $target into ${INPUT}/root$target
180 # treat this directory as if it actually contained the files.
181 echo $file '->' root$x ': Making link'
182 if [ -d $LIB/root$x ]
188 while [ x$dirname != x ]; do
189 component=`echo $dirname | sed -e 's|/.*$||'`
190 mkdir $component >/dev/null 2>&1
192 dirmade=$dirmade/$component
193 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
196 # Duplicate directory structure created in ${LIB}/$file in new
198 for file2 in $files; do
201 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
202 echo "Duplicating ${file}'s ${dupdir}"
213 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
215 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
216 rm -fr ${LIB}/$file > /dev/null 2>&1
217 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
218 treetops="$treetops $x ${LIB}/root$x"
229 while [ $# != 0 ]; do
230 # $1 is an old directory to copy, and $2 is the new directory to copy to.
233 # The same dir can appear more than once in treetops.
234 # There's no need to scan it more than once.
240 echo Fixing directory $1 into $2
241 # Check .h files which are symlinks as well as those which are files.
242 # A link to a header file will not be processed by anything but this.
244 files=`find . -name '*.h' \( -type f -o -type l \) -print`
246 files=`find . -name '*.h' -type f -print`
248 echo Checking header files
250 # Note that BSD43_* are used on recent MIPS systems.
251 for file in $files; do
252 # This call to egrep is essential, since checking a file with egrep
253 # is much faster than actually trying to fix it.
254 # It is also essential that most files *not* match!
255 # Thus, matching every #endif is unacceptable.
256 # But the argument to egrep must be kept small, or many versions of egrep
257 # won't be able to handle it.
259 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
260 # following #else or #endif because some buggy egreps think [^/] matches
261 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
263 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
264 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
265 # in this pattern lacks `d' and `l'; this means we don't worry about
266 # identifiers starting with `d' or `l'. This is OK, since none of the
267 # identifiers below start with `d' or `l'. It also greatly improves
268 # performance, since many files contain lines of the form `#if ... defined ...'
270 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
271 if [ -r $file ]; then
272 cp $file $2/$file >/dev/null 2>&1 \
273 || echo "Can't copy $file"
276 # Here is how the sed commands in braces work.
277 # (It doesn't work to put the comments inside the sed commands.)
278 # Surround each word with spaces, to simplify matching below.
279 # ANSIfy each pre-ANSI machine-dependent symbol
280 # by surrounding it with __ __.
281 # Remove the spaces that we inserted around each word.
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 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
297 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
298 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
299 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
300 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
302 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
304 s/ bsd4\([0-9]\) / __bsd4\1__ /g
305 s/ _*host_mips / __host_mips__ /g
306 s/ _*i386 / __i386__ /g
308 s/ is68k / __is68k__ /g
309 s/ m68k / __m68k__ /g
310 s/ mc680\([0-9]\)0 / __mc680\10__ /g
311 s/ m88k / __m88k__ /g
312 s/ _*mips / __mips__ /g
313 s/ news\([0-9]*\) / __news\1__ /g
314 s/ ns32000 / __ns32000__ /g
315 s/ pdp11 / __pdp11__ /g
317 s/ sony_news / __sony_news__ /g
318 s/ sparc / __sparc__ /g
319 s/ sun\([a-z0-9]*\) / __sun\1__ /g
320 s/ tower\([_0-9]*\) / __tower\1__ /g
321 s/ u370 / __u370__ /g
322 s/ u3b\([0-9]*\) / __u3b\1__ /g
323 s/ unix / __unix__ /g
325 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
326 s/ _*R\([34]\)000 / __R\1000__ /g
327 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
329 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
331 /^#define.NULL[ ]/ i\
333 ' $2/$file > $2/$file.
334 mv $2/$file. $2/$file
335 if cmp $file $2/$file >/dev/null 2>&1; then
339 # Find any include directives that use "file".
340 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
341 dir=`echo $file | sed -e s'|/[^/]*$||'`
342 required="$required $1 $dir/$include $2/$dir/$include"
353 # Install the proper definition of the three standard types in header files
354 # that they come from.
355 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
356 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
357 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
358 chmod +w ${LIB}/$file 2>/dev/null
359 chmod a+r ${LIB}/$file 2>/dev/null
362 if [ -r ${LIB}/$file ]; then
363 echo Fixing size_t, ptrdiff_t and wchar_t in $file
365 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
366 #ifndef __SIZE_TYPE__\
367 #define __SIZE_TYPE__ long unsigned int\
370 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
371 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
372 #ifndef __PTRDIFF_TYPE__\
373 #define __PTRDIFF_TYPE__ long int\
376 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
377 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
378 #ifndef __WCHAR_TYPE__\
379 #define __WCHAR_TYPE__ int\
382 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
383 ${LIB}/$file > ${LIB}/${file}.sed
384 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
385 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
391 # Fix one other error in this file: a mismatched quote not inside a C comment.
392 file=sundev/vuid_event.h
393 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
394 mkdir ${LIB}/sundev 2>/dev/null
395 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
396 chmod +w ${LIB}/$file 2>/dev/null
397 chmod a+r ${LIB}/$file 2>/dev/null
400 if [ -r ${LIB}/$file ]; then
401 echo Fixing $file comment
402 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
403 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
404 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
409 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
410 file=sunwindow/win_cursor.h
411 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
412 # mkdir ${LIB}/sunwindow 2>/dev/null
413 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
414 chmod +w ${LIB}/$file 2>/dev/null
416 if [ -r ${LIB}/$file ]; then
418 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
419 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
420 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
424 file=sunwindow/win_lock.h
425 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
426 # mkdir ${LIB}/sunwindow 2>/dev/null
427 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
428 chmod +w ${LIB}/$file 2>/dev/null
430 if [ -r ${LIB}/$file ]; then
432 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
433 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
434 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
439 # Fix this Sun file to avoid interfering with stddef.h.
441 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
442 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
443 chmod +w ${LIB}/$file 2>/dev/null
444 chmod a+r ${LIB}/$file 2>/dev/null
447 if [ -r ${LIB}/$file ]; then
449 sed -e '/[ ]size_t.*;/i\
456 -e '/[ ]ptrdiff_t.*;/i\
457 #ifndef _GCC_PTRDIFF_T\
458 #define _GCC_PTRDIFF_T
460 -e '/[ ]ptrdiff_t.*;/a\
463 -e '/[ ]wchar_t.*;/i\
464 #ifndef _GCC_WCHAR_T\
467 -e '/[ ]wchar_t.*;/a\
469 ' ${LIB}/$file > ${LIB}/${file}.sed
470 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
471 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
476 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
479 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
480 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
481 chmod +w ${LIB}/$file 2>/dev/null
482 chmod a+r ${LIB}/$file 2>/dev/null
485 if [ -r ${LIB}/$file ]; then
487 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
488 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
489 ${LIB}/$file > ${LIB}/${file}.sed
490 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
491 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
496 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
497 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
500 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
501 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
502 chmod +w ${LIB}/$file 2>/dev/null
503 chmod a+r ${LIB}/$file 2>/dev/null
506 if [ -r ${LIB}/$file ]; then
508 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
512 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
514 ' ${LIB}/$file > ${LIB}/${file}.sed
515 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
516 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
521 # Fix HP's use of ../machine/inline.h to refer to
522 # /usr/include/machine/inline.h
524 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
525 cp $file ${LIB}/$file
527 if [ -r ${LIB}/$file ] ; then
529 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
530 -e 's,"../machine/psl.h",<machine/psl.h>,' \
531 ${LIB}/$file > ${LIB}/${file}.sed
532 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
533 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
538 # Fix an error in this file: the #if says _cplusplus, not the double
539 # underscore __cplusplus that it should be
541 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
542 mkdir ${LIB}/rpcsvc 2>/dev/null
543 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
544 chmod +w ${LIB}/$file 2>/dev/null
545 chmod a+r ${LIB}/$file 2>/dev/null
548 if [ -r ${LIB}/$file ]; then
549 echo Fixing $file, __cplusplus macro
550 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
551 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
552 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
557 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
558 # structure definition.
560 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
561 mkdir ${LIB}/rpcsvc 2>/dev/null
562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
563 chmod +w ${LIB}/$file 2>/dev/null
564 chmod a+r ${LIB}/$file 2>/dev/null
567 if [ -r ${LIB}/$file ]; then
568 echo Fixing $file, definition of statsswtch
569 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
570 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
571 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
576 # Fix an error in this file: a missing semi-colon at the end of the nodeent
577 # structure definition.
578 file=netdnet/dnetdb.h
579 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
580 mkdir ${LIB}/netdnet 2>/dev/null
581 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
582 chmod +w ${LIB}/$file 2>/dev/null
583 chmod a+r ${LIB}/$file 2>/dev/null
586 if [ -r ${LIB}/$file ]; then
587 echo Fixing $file, definition of nodeent
588 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
589 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
590 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
595 # Check for bad #ifdef line (in Ultrix 4.1)
597 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
598 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
599 chmod +w ${LIB}/$file 2>/dev/null
600 chmod a+r ${LIB}/$file 2>/dev/null
603 if [ -r ${LIB}/$file ]; then
604 echo Fixing $file, bad \#ifdef line
605 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
606 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
607 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
612 # Check for superfluous `static' (in Ultrix 4.2)
613 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
615 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
616 mkdir ${LIB}/machine 2>/dev/null
617 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
618 chmod +w ${LIB}/$file 2>/dev/null
619 chmod a+r ${LIB}/$file 2>/dev/null
622 if [ -r ${LIB}/$file ]; then
623 echo Fixing $file, superfluous static and broken includes of other files.
624 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
625 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
626 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
627 ${LIB}/$file > ${LIB}/${file}.sed
628 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
629 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
632 # This file has an alternative name, mips/cpu.h. Fix that name, too.
633 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
634 mkdir ${LIB}/mips 2>&-
635 # Don't remove the file first, they may be the same file!
636 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
641 # Incorrect sprintf declaration in X11/Xmu.h
643 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
644 mkdir ${LIB}/X11 2>/dev/null
645 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
646 chmod +w ${LIB}/$file 2>/dev/null
647 chmod a+r ${LIB}/$file 2>/dev/null
650 if [ -r ${LIB}/$file ]; then
651 echo Fixing $file sprintf declaration
652 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
653 extern char * sprintf();\
654 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
655 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
656 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
661 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
662 # (It's not clear whether the right file name is this or X11/Xmu.h.)
664 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
665 mkdir ${LIB}/X11/Xmu 2>/dev/null
666 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
667 chmod +w ${LIB}/$file 2>/dev/null
668 chmod a+r ${LIB}/$file 2>/dev/null
671 if [ -r ${LIB}/$file ]; then
672 echo Fixing $file sprintf declaration
673 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
674 extern char * sprintf();\
675 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
676 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
677 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
682 # Check for missing ';' in struct
684 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
685 mkdir ${LIB}/netinet 2>/dev/null
686 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
687 chmod +w ${LIB}/$file 2>/dev/null
688 chmod a+r ${LIB}/$file 2>/dev/null
691 if [ -r ${LIB}/$file ]; then
693 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
694 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
695 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
700 # Fix the CAT macro in SunOS memvar.h.
701 file=pixrect/memvar.h
702 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
703 mkdir ${LIB}/pixrect 2>/dev/null
704 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
705 chmod +w ${LIB}/$file 2>/dev/null
706 chmod a+r ${LIB}/$file 2>/dev/null
709 if [ -r ${LIB}/$file ]; then
711 sed -e '/^#define.CAT(a,b)/ i\
713 #define CAT(a,b) a##b\
715 /^#define.CAT(a,b)/ a\
717 ' ${LIB}/$file > ${LIB}/${file}.sed
718 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
719 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
724 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
726 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
727 mkdir ${LIB}/rpcsvc 2>/dev/null
728 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
729 chmod +w ${LIB}/$file 2>/dev/null
730 chmod a+r ${LIB}/$file 2>/dev/null
733 if [ -r ${LIB}/$file ]; then
735 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
736 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
737 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
742 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
743 # Also wrap protection around size_t for m88k-sysv3 systems.
745 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
746 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
747 chmod +w ${LIB}/$file 2>/dev/null
748 chmod a+r ${LIB}/$file 2>/dev/null
751 if [ -r ${LIB}/$file ]; then
753 sed -e 's/int abort/void abort/g' \
754 -e 's/int free/void free/g' \
755 -e 's/char \* calloc/void \* calloc/g' \
756 -e 's/char \* malloc/void \* malloc/g' \
757 -e 's/char \* realloc/void \* realloc/g' \
758 -e 's/int exit/void exit/g' \
759 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
763 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
766 ${LIB}/$file > ${LIB}/${file}.sed
767 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
768 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
773 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
775 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
776 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
777 chmod +w ${LIB}/$file 2>/dev/null
778 chmod a+r ${LIB}/$file 2>/dev/null
781 if [ -r ${LIB}/$file ]; then
783 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
784 -e 's/int[ ][ ]*free/void free/g' \
785 ${LIB}/$file > ${LIB}/${file}.sed
786 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
787 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
792 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
793 file=hsfs/hsfs_spec.h
794 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
795 mkdir ${LIB}/hsfs 2>/dev/null
796 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
797 chmod +w ${LIB}/$file 2>/dev/null
798 chmod a+r ${LIB}/$file 2>/dev/null
801 if [ -r ${LIB}/$file ]; then
803 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
804 ${LIB}/$file > ${LIB}/${file}.
805 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
806 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
811 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
813 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
814 mkdir ${LIB}/hsfs 2>/dev/null
815 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
816 chmod +w ${LIB}/$file 2>/dev/null
817 chmod a+r ${LIB}/$file 2>/dev/null
820 if [ -r ${LIB}/$file ]; then
822 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
823 ${LIB}/$file > ${LIB}/${file}.sed
824 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
825 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
830 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
832 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
833 mkdir ${LIB}/hsfs 2>/dev/null
834 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
835 chmod +w ${LIB}/$file 2>/dev/null
836 chmod a+r ${LIB}/$file 2>/dev/null
839 if [ -r ${LIB}/$file ]; then
841 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
842 ${LIB}/$file > ${LIB}/${file}.sed
843 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
844 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
849 # Incorrect #include in Sony News-OS 3.2.
850 file=machine/machparam.h
851 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
852 mkdir ${LIB}/machine 2>/dev/null
853 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
854 chmod +w ${LIB}/$file 2>/dev/null
855 chmod a+r ${LIB}/$file 2>/dev/null
858 if [ -r ${LIB}/$file ]; then
859 echo Fixing $file, incorrect \#include
860 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
861 ${LIB}/$file > ${LIB}/${file}.
862 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
863 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
868 # Multiline comment after typedef on IRIX 4.0.1.
870 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
871 mkdir ${LIB}/sys 2>/dev/null
872 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
873 chmod +w ${LIB}/$file 2>/dev/null
874 chmod a+r ${LIB}/$file 2>/dev/null
877 if [ -r ${LIB}/$file ]; then
878 echo Fixing $file, comment in the middle of \#ifdef
879 sed -e 's@type of the result@type of the result */@' \
880 -e 's@of the sizeof@/* of the sizeof@' \
881 ${LIB}/$file > ${LIB}/${file}.sed
882 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
883 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
888 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
889 # header file, which embeds // comments inside multi-line /* */
890 # comments. If this looks like the IRIX header file, we refix it by
891 # just throwing away the // comments.
893 if [ -r ${LIB}/$file ]; then
894 if egrep indigo.esd ${LIB}/$file > /dev/null; then
895 echo Fixing $file, overeager sed script
897 sed -e 's|//.*$||g' $file > ${LIB}/$file
898 chmod +w ${LIB}/$file 2>/dev/null
899 chmod a+r ${LIB}/$file 2>/dev/null
903 # Some IRIX header files contains the string "//"
904 for file in elf_abi.h elf.h; do
905 if [ -r ${LIB}/$file ]; then
906 echo Fixing $file, overeager sed script
907 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
908 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
909 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
915 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
916 # previous definition.
918 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
919 mkdir ${LIB}/rpc 2>/dev/null
920 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
921 chmod +w ${LIB}/$file 2>/dev/null
922 chmod a+r ${LIB}/$file 2>/dev/null
925 if [ -r ${LIB}/$file ]; then
926 echo Fixing $file, undefined type
927 sed -e '/authdes_create.*struct sockaddr/i\
930 ${LIB}/$file > ${LIB}/$file.sed
931 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
932 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
937 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
940 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
941 mkdir ${LIB}/rpc 2>/dev/null
942 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
943 chmod +w ${LIB}/$file 2>/dev/null
944 chmod a+r ${LIB}/$file 2>/dev/null
947 if [ -r ${LIB}/$file ]; then
948 echo Fixing $file, undefined type
949 sed -e '/xdrstdio_create.*struct __file_s/i\
952 ${LIB}/$file > ${LIB}/$file.sed
953 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
954 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
959 # Same problem with a file from SunOS 4.1.3 : a header file containing
960 # the string "//" embedded in "/**/"
961 file=sbusdev/audiovar.h
962 if [ -r ${LIB}/$file ]; then
963 echo Fixing $file, overeager sed script
965 sed -e 's|//.*$||g' $file > ${LIB}/$file
966 chmod +w ${LIB}/$file 2>/dev/null
967 chmod a+r ${LIB}/$file 2>/dev/null
970 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
971 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
972 # many other systems have similar text but correct versions of the file.
973 # To ensure only Sun's is fixed, we grep for a likely unique string.
975 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
976 if [ ! -r ${LIB}/$file ]; then
977 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
978 chmod +w ${LIB}/$file 2>/dev/null
979 chmod a+r ${LIB}/$file 2>/dev/null
981 if [ -r ${LIB}/$file ]; then
983 cat > ${LIB}/$file << EOF
984 /* This file was generated by fixincludes */
989 extern void *memccpy();
990 extern void *memchr();
991 extern void *memcpy();
992 extern void *memset();
994 extern char *memccpy();
995 extern char *memchr();
996 extern char *memcpy();
997 extern char *memset();
998 #endif /* __STDC__ */
1000 extern int memcmp();
1002 #endif /* __memory_h__ */
1007 # parameters not const on DECstation Ultrix V4.0.
1009 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1010 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1011 chmod +w ${LIB}/$file 2>/dev/null
1012 chmod a+r ${LIB}/$file 2>/dev/null
1015 if [ -r ${LIB}/$file ]; then
1016 echo Fixing $file, non-const arg
1017 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1018 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1019 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1020 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1021 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1022 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1023 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1024 ${LIB}/$file > ${LIB}/${file}.sed
1025 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1026 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1031 # parameters conflict with C++ new on rs/6000
1032 for file in stdio.h unistd.h ; do
1033 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1034 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1035 chmod +w ${LIB}/$file 2>/dev/null
1038 if [ -r ${LIB}/$file ]; then
1039 echo Fixing $file, parameter name conflicts
1040 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1041 ${LIB}/$file > ${LIB}/${file}.sed
1042 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1043 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1049 # function class(double x) conflicts with C++ keyword on rs/6000
1051 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1052 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1053 chmod +w ${LIB}/$file 2>/dev/null
1054 chmod a+r ${LIB}/$file 2>/dev/null
1057 if [ -r ${LIB}/$file ]; then
1058 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1060 sed -e '/class[(]/i\
1065 ' ${LIB}/$file > ${LIB}/${file}.sed
1066 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1067 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1073 # Wrong fchmod prototype on RS/6000.
1075 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1076 mkdir ${LIB}/sys 2>/dev/null
1077 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1078 chmod +w ${LIB}/$file 2>/dev/null
1079 chmod a+r ${LIB}/$file 2>/dev/null
1082 if [ -r ${LIB}/$file ]; then
1083 echo Fixing $file, fchmod prototype
1084 sed -e 's/fchmod(char \*/fchmod(int/' \
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
1092 # There are several name conflicts with C++ reserved words in X11
1093 # header files. These are fixed in some versions, so don't do the
1094 # fixes if we find __cplusplus in the file. These were found on the
1097 # class in X11/ShellP.h
1099 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1100 mkdir ${LIB}/sys 2>/dev/null
1101 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1102 chmod +w ${LIB}/$file 2>/dev/null
1103 chmod a+r ${LIB}/$file 2>/dev/null
1106 if [ -r ${LIB}/$file ]; then
1107 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1110 echo Fixing $file, field class
1111 sed -e '/char [*]class;/i\
1116 -e '/char [*]class;/a\
1118 ' ${LIB}/$file > ${LIB}/${file}.sed
1119 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1121 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1125 # new in Xm/Traversal.h
1127 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1128 mkdir ${LIB}/sys 2>/dev/null
1129 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1130 chmod +w ${LIB}/$file 2>/dev/null
1131 chmod a+r ${LIB}/$file 2>/dev/null
1134 if [ -r ${LIB}/$file ]; then
1135 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1138 echo Fixing $file, uses of new
1139 sed -e '/Widget old, new;/i\
1144 -e '/Widget old, new;/a\
1147 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1148 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1150 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1154 # class in Xm/BaseClassI.h
1155 file=Xm/BaseClassI.h
1156 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1157 mkdir ${LIB}/sys 2>/dev/null
1158 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1159 chmod +w ${LIB}/$file 2>/dev/null
1160 chmod a+r ${LIB}/$file 2>/dev/null
1163 if [ -r ${LIB}/$file ]; then
1164 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1167 echo Fixing $file, prototype parameter name
1168 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1169 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1171 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1177 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1178 # Note that version 3 of the NeXT system has wait.h in a different directory,
1179 # so that this code won't do anything. But wait.h in version 3 has a
1180 # conditional, so it doesn't need this fix. So everything is okay.
1182 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1183 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1184 chmod +w ${LIB}/$file 2>/dev/null
1187 if [ -r ${LIB}/$file ] \
1188 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1189 echo Fixing $file, bad wait formal
1190 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1191 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1192 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1197 # Don't use or define the name va_list in stdio.h.
1198 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1200 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1201 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1202 chmod +w ${LIB}/$file 2>/dev/null
1203 chmod a+r ${LIB}/$file 2>/dev/null
1206 if [ -r ${LIB}/$file ]; then
1207 echo Fixing $file, use of va_list
1208 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1209 (echo "#define __need___va_list"
1210 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1211 # Use __gnuc_va_list in arg types in place of va_list.
1212 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1213 # trailing parentheses and semicolon save all other systems from this.
1214 # Define __va_list__ (something harmless and unused) instead of va_list.
1215 # Don't claim to have defined va_list.
1216 sed -e 's@ va_list @ __gnuc_va_list @' \
1217 -e 's@ va_list)@ __gnuc_va_list)@' \
1218 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1219 -e 's@ va_list@ __va_list__@' \
1220 -e 's@\*va_list@*__va_list__@' \
1221 -e 's@ __va_list)@ __gnuc_va_list)@' \
1222 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1223 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1224 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1225 ${LIB}/$file >> ${LIB}/${file}.sed
1227 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1228 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1233 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1235 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1236 if grep -s ULTRIX $file; then
1237 echo "/* This file intentionally left blank. */" > $LIB/$file
1241 # parameter to atof not const on DECstation Ultrix V4.0.
1242 # also get rid of bogus inline definitions in HP-UX 8.0
1244 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1245 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1246 chmod +w ${LIB}/$file 2>/dev/null
1247 chmod a+r ${LIB}/$file 2>/dev/null
1250 if [ -r ${LIB}/$file ]; then
1251 echo Fixing $file, non-const arg
1252 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1253 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1254 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1255 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1256 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1257 ${LIB}/$file > ${LIB}/${file}.sed
1258 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1259 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1264 # Avoid nested comments on Ultrix 4.3.
1266 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1267 mkdir ${LIB}/rpc 2>/dev/null
1268 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1269 chmod +w ${LIB}/$file 2>/dev/null
1270 chmod a+r ${LIB}/$file 2>/dev/null
1273 if [ -r ${LIB}/$file ]; then
1274 echo Fixing $file, nested comment
1275 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1276 ${LIB}/$file > ${LIB}/$file.sed
1277 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1278 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1283 # This file in RISC/os uses /**/ to concatenate two tokens.
1285 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1286 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1287 chmod +w ${LIB}/$file 2>/dev/null
1288 chmod a+r ${LIB}/$file 2>/dev/null
1290 if [ -r ${LIB}/$file ]; then
1291 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1292 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1293 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1299 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1300 mkdir ${LIB}/rpc 2>/dev/null
1301 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1302 chmod +w ${LIB}/$file 2>/dev/null
1303 chmod a+r ${LIB}/$file 2>/dev/null
1306 if [ -r ${LIB}/$file ]; then
1307 echo Fixing $file, nested comment
1308 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1309 ${LIB}/$file > ${LIB}/$file.sed
1310 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1311 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1316 # In limits.h, put #ifndefs around things that are supposed to be defined
1317 # in float.h to avoid redefinition errors if float.h is included first.
1318 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1319 # multi line comments and the inserted #endif winds up inside the
1320 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1321 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1322 # are there, and we do not add them ourselves.
1323 for file in limits.h sys/limits.h; do
1324 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1325 mkdir ${LIB}/sys 2>/dev/null
1326 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1327 chmod +w ${LIB}/$file 2>/dev/null
1328 chmod a+r ${LIB}/$file 2>/dev/null
1331 if [ -r ${LIB}/$file ]; then
1332 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1336 sed -e '/[ ]FLT_MIN[ ]/i\
1339 -e '/[ ]FLT_MIN[ ]/a\
1342 -e '/[ ]FLT_MAX[ ]/i\
1345 -e '/[ ]FLT_MAX[ ]/a\
1348 -e '/[ ]FLT_DIG[ ]/i\
1351 -e '/[ ]FLT_DIG[ ]/a\
1354 -e '/[ ]DBL_MIN[ ]/i\
1357 -e '/[ ]DBL_MIN[ ]/a\
1360 -e '/[ ]DBL_MAX[ ]/i\
1363 -e '/[ ]DBL_MAX[ ]/a\
1366 -e '/[ ]DBL_DIG[ ]/i\
1369 -e '/[ ]DBL_DIG[ ]/a\
1372 ${LIB}/$file > ${LIB}/${file}.sed
1373 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1375 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1376 echo Deleting ${LIB}/$file\; no fixes were needed.
1382 # In math.h, put #ifndefs around things that might be defined in a gcc
1383 # specific math-*.h file.
1385 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1386 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1387 chmod +w ${LIB}/$file 2>/dev/null
1388 chmod a+r ${LIB}/$file 2>/dev/null
1391 if [ -r ${LIB}/$file ]; then
1393 sed -e '/define[ ]HUGE_VAL[ ]/i\
1396 -e '/define[ ]HUGE_VAL[ ]/a\
1399 ${LIB}/$file > ${LIB}/${file}.sed
1400 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1401 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1402 echo Deleting ${LIB}/$file\; no fixes were needed.
1407 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1409 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1410 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1411 chmod +w ${LIB}/$file 2>/dev/null
1412 chmod a+r ${LIB}/$file 2>/dev/null
1415 if [ -r ${LIB}/$file ]; then
1417 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1418 ${LIB}/$file > ${LIB}/${file}.sed
1419 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1420 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1425 # Fix incorrect S_IF* definitions on m88k-sysv3.
1427 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1428 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1429 chmod +w ${LIB}/$file 2>/dev/null
1430 chmod a+r ${LIB}/$file 2>/dev/null
1433 if [ -r ${LIB}/$file ]; then
1435 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)/' \
1436 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1437 ${LIB}/$file > ${LIB}/${file}.sed
1438 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1439 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1444 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
1445 for file in stdio.h stdlib.h; do
1446 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1447 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1448 chmod +w ${LIB}/$file 2>/dev/null
1449 chmod a+r ${LIB}/$file 2>/dev/null
1452 if [ -r ${LIB}/$file ]; then
1453 echo Fixing $file, getopt declaration
1454 sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
1455 ${LIB}/$file > ${LIB}/${file}.sed
1456 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1457 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1463 # These two files on SunOS 4 are included by other files
1464 # in the same directory, using "...". So we must make sure they exist
1465 # in the same directory as the other fixed files.
1466 if [ -r ${INPUT}/multimedia/audio_errno.h ]
1468 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
1470 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
1472 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
1475 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1476 # need to fix some additional files. This is the same test for ISC that
1478 if test -d /etc/conf/kconfig.d \
1479 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1480 echo "Fixing ISC __STDC__ goof in several files..."
1481 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1483 if test -r ${LIB}/$name; then
1488 # On Interactive 2.2, certain traditional Unix definitions
1489 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1490 # defined, not just if _POSIX_SOURCE is defined. This makes it
1491 # impossible to compile any nontrivial program except with -posix.
1493 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1494 < $file > ${LIB}/$name.
1495 mv ${LIB}/$name. ${LIB}/$name
1498 echo "Fixing ISC fmod declaration"
1499 # This one's already been fixed for other things.
1501 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1504 echo "Fixing nested comments in ISC <sys/limits.h>"
1506 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1507 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1510 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1511 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1512 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1513 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1515 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1516 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1517 chmod +w ${LIB}/$file 2>/dev/null
1518 chmod a+r ${LIB}/$file 2>/dev/null
1521 if [ -r ${LIB}/$file ]; then
1522 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1523 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1524 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1530 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1531 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1532 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1534 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1535 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1536 chmod +w ${LIB}/$file 2>/dev/null
1537 chmod a+r ${LIB}/$file 2>/dev/null
1540 if [ -r ${LIB}/$file ]; then
1541 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1542 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1543 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1549 # This file on SunOS 4 has a very large macro. When the sed loop
1550 # tries pull it in, it overflows the pattern space size of the SunOS
1551 # sed (GNU sed does not have this problem). Since the file does not
1552 # require fixing, we remove it from the fixed directory.
1553 file=sundev/ipi_error.h
1554 if [ -r ${LIB}/$file ]; then
1555 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1559 echo 'Removing unneeded directories:'
1561 files=`find . -type d -print | sort -r`
1562 for file in $files; do
1563 rmdir $LIB/$file > /dev/null 2>&1
1567 echo 'Making internal symbolic non-directory links'
1569 files=`find . -type l -print`
1570 for file in $files; do
1571 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1572 if expr "$dest" : '[^/].*' > /dev/null; then
1573 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1574 if [ -f $target ]; then
1575 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1581 # Make sure that any include files referenced using double quotes
1582 # exist in the fixed directory. This comes last since otherwise
1583 # we might end up deleting some of these files "because they don't
1585 while [ -n "$required" ]; do
1589 while [ $# != 0 ]; do
1590 # $1 is the directory to copy from, $2 is the unfixed file,
1591 # $3 is the fixed file name.
1594 if [ -r $2 ] && [ ! -r $3 ]; then
1595 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1596 chmod +w $3 2>/dev/null
1597 chmod a+r $3 2>/dev/null
1599 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1600 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1601 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1602 newreq="$newreq $1 $dir/$include $dir2/$include"
1610 echo 'Cleaning up DONE files.'
1612 find . -name DONE -exec rm -f '{}' ';'