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
115 newdirs="$newdirs $d1"
120 files="$files $newdirs"
125 echo "All directories (including links to directories):"
128 for file in $files; do
130 if [ ! -d $LIB/$file ]
131 then mkdir $LIB/$file
136 # treetops gets an alternating list
137 # of old directories to copy
138 # and the new directories to copy to.
139 treetops="${INPUT} ${LIB}"
142 echo 'Making symbolic directory links'
143 for file in $files; do
144 dest=`ls -ld $file | sed -n 's/.*-> //p'`
147 # In case $dest is relative, get to $file's dir first.
149 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
150 # Check that the target directory exists.
151 # Redirections changed to avoid bug in sh on Ultrix.
152 (cd $dest) > /dev/null 2>&1
155 # X gets the dir that the link actually leads to.
157 # If a link points to ., make a similar link to .
158 if [ $x = $INPUT ]; then
159 echo $file '->' . ': Making link'
160 rm -fr ${LIB}/$file > /dev/null 2>&1
161 ln -s . ${LIB}/$file > /dev/null 2>&1
162 # If link leads back into ${INPUT},
163 # make a similar link here.
164 elif expr $x : "${INPUT}/.*" > /dev/null; then
165 # Y gets the actual target dir name, relative to ${INPUT}.
166 y=`echo $x | sed -n "s&${INPUT}/&&p"`
167 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
169 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
170 echo $file '->' $dots$y ': Making link'
171 rm -fr ${LIB}/$file > /dev/null 2>&1
172 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
174 # If the link is to a dir $target outside ${INPUT},
175 # repoint the link at ${INPUT}/root$target
176 # and process $target into ${INPUT}/root$target
177 # treat this directory as if it actually contained the files.
178 echo $file '->' root$x ': Making link'
179 if [ -d $LIB/root$x ]
185 while [ x$dirname != x ]; do
186 component=`echo $dirname | sed -e 's|/.*$||'`
187 mkdir $component >/dev/null 2>&1
189 dirmade=$dirmade/$component
190 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
193 # Duplicate directory structure created in ${LIB}/$file in new
195 for file2 in $files; do
198 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
199 echo "Duplicating ${file}'s ${dupdir}"
210 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
212 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
213 rm -fr ${LIB}/$file > /dev/null 2>&1
214 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
215 treetops="$treetops $x ${LIB}/root$x"
226 while [ $# != 0 ]; do
227 # $1 is an old directory to copy, and $2 is the new directory to copy to.
230 # The same dir can appear more than once in treetops.
231 # There's no need to scan it more than once.
237 echo Fixing directory $1 into $2
238 # Check .h files which are symlinks as well as those which are files.
239 # A link to a header file will not be processed by anything but this.
241 files=`find . -name '*.h' \( -type f -o -type l \) -print`
243 files=`find . -name '*.h' -type f -print`
245 echo Checking header files
247 # Note that BSD43_* are used on recent MIPS systems.
248 for file in $files; do
249 # This call to egrep is essential, since checking a file with egrep
250 # is much faster than actually trying to fix it.
251 # It is also essential that most files *not* match!
252 # Thus, matching every #endif is unacceptable.
253 # But the argument to egrep must be kept small, or many versions of egrep
254 # won't be able to handle it.
256 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
257 # following #else or #endif because some buggy egreps think [^/] matches
258 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
260 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
261 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
262 # in this pattern lacks `d' and `l'; this means we don't worry about
263 # identifiers starting with `d' or `l'. This is OK, since none of the
264 # identifiers below start with `d' or `l'. It also greatly improves
265 # performance, since many files contain lines of the form `#if ... defined ...'
267 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
268 if [ -r $file ]; then
269 cp $file $2/$file >/dev/null 2>&1 \
270 || echo "Can't copy $file"
273 # Here is how the sed commands in braces work.
274 # (It doesn't work to put the comments inside the sed commands.)
275 # Surround each word with spaces, to simplify matching below.
276 # ANSIfy each pre-ANSI machine-dependent symbol
277 # by surrounding it with __ __.
278 # Remove the spaces that we inserted around each word.
283 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
284 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
285 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
286 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
287 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
288 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
289 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
290 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
291 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
292 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
293 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
294 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
295 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
296 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
297 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
299 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
301 s/ bsd4\([0-9]\) / __bsd4\1__ /g
302 s/ _*host_mips / __host_mips__ /g
303 s/ _*i386 / __i386__ /g
305 s/ is68k / __is68k__ /g
306 s/ m68k / __m68k__ /g
307 s/ mc680\([0-9]\)0 / __mc680\10__ /g
308 s/ m88k / __m88k__ /g
309 s/ _*mips / __mips__ /g
310 s/ news\([0-9]*\) / __news\1__ /g
311 s/ ns32000 / __ns32000__ /g
312 s/ pdp11 / __pdp11__ /g
314 s/ sony_news / __sony_news__ /g
315 s/ sparc / __sparc__ /g
316 s/ sun\([a-z0-9]*\) / __sun\1__ /g
317 s/ tower\([_0-9]*\) / __tower\1__ /g
318 s/ u370 / __u370__ /g
319 s/ u3b\([0-9]*\) / __u3b\1__ /g
320 s/ unix / __unix__ /g
322 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
323 s/ _*R\([34]\)000 / __R\1000__ /g
324 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
326 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
328 /^#define.NULL[ ]/ i\
330 ' $2/$file > $2/$file.
331 mv $2/$file. $2/$file
332 if cmp $file $2/$file >/dev/null 2>&1; then
336 # Find any include directives that use "file".
337 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
338 dir=`echo $file | sed -e s'|/[^/]*$||'`
339 required="$required $1 $dir/$include $2/$dir/$include"
350 # Install the proper definition of size_t in header files that it comes from.
351 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
352 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
353 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
354 chmod +w ${LIB}/$file 2>/dev/null
355 chmod a+r ${LIB}/$file 2>/dev/null
358 if [ -r ${LIB}/$file ]; then
359 echo Fixing size_t in $file
360 sed -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
361 #ifndef __SIZE_TYPE__\
362 #define __SIZE_TYPE__ long unsigned int\
365 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' ${LIB}/$file > ${LIB}/${file}.sed
366 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
367 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
373 # Fix one other error in this file: a mismatched quote not inside a C comment.
374 file=sundev/vuid_event.h
375 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
376 mkdir ${LIB}/sundev 2>/dev/null
377 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
378 chmod +w ${LIB}/$file 2>/dev/null
379 chmod a+r ${LIB}/$file 2>/dev/null
382 if [ -r ${LIB}/$file ]; then
383 echo Fixing $file comment
384 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
385 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
386 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
391 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
392 file=sunwindow/win_cursor.h
393 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
394 # mkdir ${LIB}/sunwindow 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
398 if [ -r ${LIB}/$file ]; then
400 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
401 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
402 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
406 file=sunwindow/win_lock.h
407 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
408 # mkdir ${LIB}/sunwindow 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
412 if [ -r ${LIB}/$file ]; then
414 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
415 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
416 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
421 # Fix this Sun file to avoid interfering with stddef.h.
423 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
424 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
425 chmod +w ${LIB}/$file 2>/dev/null
426 chmod a+r ${LIB}/$file 2>/dev/null
429 if [ -r ${LIB}/$file ]; then
431 sed -e '/[ ]size_t.*;/i\
438 -e '/[ ]ptrdiff_t.*;/i\
439 #ifndef _GCC_PTRDIFF_T\
440 #define _GCC_PTRDIFF_T
442 -e '/[ ]ptrdiff_t.*;/a\
445 -e '/[ ]wchar_t.*;/i\
446 #ifndef _GCC_WCHAR_T\
449 -e '/[ ]wchar_t.*;/a\
451 ' ${LIB}/$file > ${LIB}/${file}.sed
452 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
453 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
458 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
461 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
462 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
463 chmod +w ${LIB}/$file 2>/dev/null
464 chmod a+r ${LIB}/$file 2>/dev/null
467 if [ -r ${LIB}/$file ]; then
469 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
470 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
471 ${LIB}/$file > ${LIB}/${file}.sed
472 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
473 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
478 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
479 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
482 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
483 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
484 chmod +w ${LIB}/$file 2>/dev/null
485 chmod a+r ${LIB}/$file 2>/dev/null
488 if [ -r ${LIB}/$file ]; then
490 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
494 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
496 ' ${LIB}/$file > ${LIB}/${file}.sed
497 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
498 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
503 # Fix HP's use of ../machine/inline.h to refer to
504 # /usr/include/machine/inline.h
506 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
507 cp $file ${LIB}/$file
509 if [ -r ${LIB}/$file ] ; then
511 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
512 -e 's,"../machine/psl.h",<machine/psl.h>,' \
513 ${LIB}/$file > ${LIB}/${file}.sed
514 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
515 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
520 # Fix an error in this file: the #if says _cplusplus, not the double
521 # underscore __cplusplus that it should be
523 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
524 mkdir ${LIB}/rpcsvc 2>/dev/null
525 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
526 chmod +w ${LIB}/$file 2>/dev/null
527 chmod a+r ${LIB}/$file 2>/dev/null
530 if [ -r ${LIB}/$file ]; then
531 echo Fixing $file, __cplusplus macro
532 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
533 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
534 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
539 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
540 # structure definition.
542 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
543 mkdir ${LIB}/rpcsvc 2>/dev/null
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
550 echo Fixing $file, definition of statsswtch
551 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
552 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
553 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
558 # Fix an error in this file: a missing semi-colon at the end of the nodeent
559 # structure definition.
560 file=netdnet/dnetdb.h
561 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
562 mkdir ${LIB}/netdnet 2>/dev/null
563 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
564 chmod +w ${LIB}/$file 2>/dev/null
565 chmod a+r ${LIB}/$file 2>/dev/null
568 if [ -r ${LIB}/$file ]; then
569 echo Fixing $file, definition of nodeent
570 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
571 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
572 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
577 # Check for bad #ifdef line (in Ultrix 4.1)
579 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
580 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
581 chmod +w ${LIB}/$file 2>/dev/null
582 chmod a+r ${LIB}/$file 2>/dev/null
585 if [ -r ${LIB}/$file ]; then
586 echo Fixing $file, bad \#ifdef line
587 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
588 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
589 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
594 # Check for superfluous `static' (in Ultrix 4.2)
595 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
597 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
598 mkdir ${LIB}/machine 2>/dev/null
599 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
600 chmod +w ${LIB}/$file 2>/dev/null
601 chmod a+r ${LIB}/$file 2>/dev/null
604 if [ -r ${LIB}/$file ]; then
605 echo Fixing $file, superfluous static and broken includes of other files.
606 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
607 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
608 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
609 ${LIB}/$file > ${LIB}/${file}.sed
610 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
611 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
614 # This file has an alternative name, mips/cpu.h. Fix that name, too.
615 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
616 mkdir ${LIB}/mips 2>&-
617 # Don't remove the file first, they may be the same file!
618 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
623 # Incorrect sprintf declaration in X11/Xmu.h
625 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
626 mkdir ${LIB}/X11 2>/dev/null
627 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
628 chmod +w ${LIB}/$file 2>/dev/null
629 chmod a+r ${LIB}/$file 2>/dev/null
632 if [ -r ${LIB}/$file ]; then
633 echo Fixing $file sprintf declaration
634 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
635 extern char * sprintf();\
636 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
637 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
638 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
643 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
644 # (It's not clear whether the right file name is this or X11/Xmu.h.)
646 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
647 mkdir ${LIB}/X11/Xmu 2>/dev/null
648 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
649 chmod +w ${LIB}/$file 2>/dev/null
650 chmod a+r ${LIB}/$file 2>/dev/null
653 if [ -r ${LIB}/$file ]; then
654 echo Fixing $file sprintf declaration
655 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
656 extern char * sprintf();\
657 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
658 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
659 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
664 # Check for missing ';' in struct
666 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
667 mkdir ${LIB}/netinet 2>/dev/null
668 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
669 chmod +w ${LIB}/$file 2>/dev/null
670 chmod a+r ${LIB}/$file 2>/dev/null
673 if [ -r ${LIB}/$file ]; then
675 sed -e '/^struct/,/^};/s/}$/};/' ${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 # Fix the CAT macro in SunOS memvar.h.
683 file=pixrect/memvar.h
684 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
685 mkdir ${LIB}/pixrect 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 '/^#define.CAT(a,b)/ i\
695 #define CAT(a,b) a##b\
697 /^#define.CAT(a,b)/ a\
699 ' ${LIB}/$file > ${LIB}/${file}.sed
700 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
701 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
706 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
708 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
709 mkdir ${LIB}/rpcsvc 2>/dev/null
710 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
711 chmod +w ${LIB}/$file 2>/dev/null
712 chmod a+r ${LIB}/$file 2>/dev/null
715 if [ -r ${LIB}/$file ]; then
717 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${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 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
725 # Also wrap protection around size_t for m88k-sysv3 systems.
727 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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 's/int abort/void abort/g' \
736 -e 's/int free/void free/g' \
737 -e 's/char \* calloc/void \* calloc/g' \
738 -e 's/char \* malloc/void \* malloc/g' \
739 -e 's/char \* realloc/void \* realloc/g' \
740 -e 's/int exit/void exit/g' \
741 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
745 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
748 ${LIB}/$file > ${LIB}/${file}.sed
749 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
750 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
755 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
757 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
758 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
759 chmod +w ${LIB}/$file 2>/dev/null
760 chmod a+r ${LIB}/$file 2>/dev/null
763 if [ -r ${LIB}/$file ]; then
765 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
766 -e 's/int[ ][ ]*free/void free/g' \
767 ${LIB}/$file > ${LIB}/${file}.sed
768 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
769 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
774 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
775 file=hsfs/hsfs_spec.h
776 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
777 mkdir ${LIB}/hsfs 2>/dev/null
778 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
779 chmod +w ${LIB}/$file 2>/dev/null
780 chmod a+r ${LIB}/$file 2>/dev/null
783 if [ -r ${LIB}/$file ]; then
785 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
786 ${LIB}/$file > ${LIB}/${file}.
787 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
788 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
793 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
795 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
796 mkdir ${LIB}/hsfs 2>/dev/null
797 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
798 chmod +w ${LIB}/$file 2>/dev/null
799 chmod a+r ${LIB}/$file 2>/dev/null
802 if [ -r ${LIB}/$file ]; then
804 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
805 ${LIB}/$file > ${LIB}/${file}.sed
806 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
807 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
812 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
814 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
815 mkdir ${LIB}/hsfs 2>/dev/null
816 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
817 chmod +w ${LIB}/$file 2>/dev/null
818 chmod a+r ${LIB}/$file 2>/dev/null
821 if [ -r ${LIB}/$file ]; then
823 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
824 ${LIB}/$file > ${LIB}/${file}.sed
825 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
826 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
831 # Incorrect #include in Sony News-OS 3.2.
832 file=machine/machparam.h
833 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
834 mkdir ${LIB}/machine 2>/dev/null
835 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
836 chmod +w ${LIB}/$file 2>/dev/null
837 chmod a+r ${LIB}/$file 2>/dev/null
840 if [ -r ${LIB}/$file ]; then
841 echo Fixing $file, incorrect \#include
842 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
843 ${LIB}/$file > ${LIB}/${file}.
844 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
845 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
850 # Multiline comment after typedef on IRIX 4.0.1.
852 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
853 mkdir ${LIB}/sys 2>/dev/null
854 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
855 chmod +w ${LIB}/$file 2>/dev/null
856 chmod a+r ${LIB}/$file 2>/dev/null
859 if [ -r ${LIB}/$file ]; then
860 echo Fixing $file, comment in the middle of \#ifdef
861 sed -e 's@type of the result@type of the result */@' \
862 -e 's@of the sizeof@/* of the sizeof@' \
863 ${LIB}/$file > ${LIB}/${file}.sed
864 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
865 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
870 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
871 # header file, which embeds // comments inside multi-line /* */
872 # comments. If this looks like the IRIX header file, we refix it by
873 # just throwing away the // comments.
875 if [ -r ${LIB}/$file ]; then
876 if egrep indigo.esd ${LIB}/$file > /dev/null; then
877 echo Fixing $file, overeager sed script
879 sed -e 's|//.*$||g' $file > ${LIB}/$file
880 chmod +w ${LIB}/$file 2>/dev/null
881 chmod a+r ${LIB}/$file 2>/dev/null
885 # Some IRIX header files contains the string "//"
886 for file in elf_abi.h elf.h; do
887 if [ -r ${LIB}/$file ]; then
888 echo Fixing $file, overeager sed script
889 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
890 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
891 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
897 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
898 # previous definition.
900 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
901 mkdir ${LIB}/rpc 2>/dev/null
902 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
903 chmod +w ${LIB}/$file 2>/dev/null
904 chmod a+r ${LIB}/$file 2>/dev/null
907 if [ -r ${LIB}/$file ]; then
908 echo Fixing $file, undefined type
909 sed -e '/authdes_create.*struct sockaddr/i\
912 ${LIB}/$file > ${LIB}/$file.sed
913 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
914 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
919 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
922 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
923 mkdir ${LIB}/rpc 2>/dev/null
924 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
925 chmod +w ${LIB}/$file 2>/dev/null
926 chmod a+r ${LIB}/$file 2>/dev/null
929 if [ -r ${LIB}/$file ]; then
930 echo Fixing $file, undefined type
931 sed -e '/xdrstdio_create.*struct __file_s/i\
934 ${LIB}/$file > ${LIB}/$file.sed
935 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
936 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
941 # Same problem with a file from SunOS 4.1.3 : a header file containing
942 # the string "//" embedded in "/**/"
943 file=sbusdev/audiovar.h
944 if [ -r ${LIB}/$file ]; then
945 echo Fixing $file, overeager sed script
947 sed -e 's|//.*$||g' $file > ${LIB}/$file
948 chmod +w ${LIB}/$file 2>/dev/null
949 chmod a+r ${LIB}/$file 2>/dev/null
952 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
953 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
954 # many other systems have similar text but correct versions of the file.
955 # To ensure only Sun's is fixed, we grep for a likely unique string.
957 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
958 if [ ! -r ${LIB}/$file ]; then
959 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
960 chmod +w ${LIB}/$file 2>/dev/null
961 chmod a+r ${LIB}/$file 2>/dev/null
963 if [ -r ${LIB}/$file ]; then
965 cat > ${LIB}/$file << EOF
966 /* This file was generated by fixincludes */
971 extern void *memccpy();
972 extern void *memchr();
973 extern void *memcpy();
974 extern void *memset();
976 extern char *memccpy();
977 extern char *memchr();
978 extern char *memcpy();
979 extern char *memset();
980 #endif /* __STDC__ */
984 #endif /* __memory_h__ */
989 # parameters not const on DECstation Ultrix V4.0.
991 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
992 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
993 chmod +w ${LIB}/$file 2>/dev/null
994 chmod a+r ${LIB}/$file 2>/dev/null
997 if [ -r ${LIB}/$file ]; then
998 echo Fixing $file, non-const arg
999 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1000 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1001 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1002 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1003 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1004 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1005 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1006 ${LIB}/$file > ${LIB}/${file}.sed
1007 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1008 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1013 # parameters conflict with C++ new on rs/6000
1014 for file in stdio.h unistd.h ; do
1015 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1016 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1017 chmod +w ${LIB}/$file 2>/dev/null
1020 if [ -r ${LIB}/$file ]; then
1021 echo Fixing $file, parameter name conflicts
1022 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1023 ${LIB}/$file > ${LIB}/${file}.sed
1024 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1025 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1031 # function class(double x) conflicts with C++ keyword on rs/6000
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
1036 chmod a+r ${LIB}/$file 2>/dev/null
1039 if [ -r ${LIB}/$file ]; then
1040 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1042 sed -e '/class[(]/i\
1047 ' ${LIB}/$file > ${LIB}/${file}.sed
1048 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1049 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1055 # Wrong fchmod prototype on RS/6000.
1057 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1058 mkdir ${LIB}/sys 2>/dev/null
1059 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1060 chmod +w ${LIB}/$file 2>/dev/null
1061 chmod a+r ${LIB}/$file 2>/dev/null
1064 if [ -r ${LIB}/$file ]; then
1065 echo Fixing $file, fchmod prototype
1066 sed -e 's/fchmod(char \*/fchmod(int/' \
1067 ${LIB}/$file > ${LIB}/$file.sed
1068 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1069 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1074 # There are several name conflicts with C++ reserved words in X11
1075 # header files. These are fixed in some versions, so don't do the
1076 # fixes if we find __cplusplus in the file. These were found on the
1079 # class in X11/ShellP.h
1081 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1082 mkdir ${LIB}/sys 2>/dev/null
1083 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1084 chmod +w ${LIB}/$file 2>/dev/null
1085 chmod a+r ${LIB}/$file 2>/dev/null
1088 if [ -r ${LIB}/$file ]; then
1089 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1092 echo Fixing $file, field class
1093 sed -e '/char [*]class;/i\
1098 -e '/char [*]class;/a\
1100 ' ${LIB}/$file > ${LIB}/${file}.sed
1101 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1103 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1107 # new in Xm/Traversal.h
1109 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1110 mkdir ${LIB}/sys 2>/dev/null
1111 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1112 chmod +w ${LIB}/$file 2>/dev/null
1113 chmod a+r ${LIB}/$file 2>/dev/null
1116 if [ -r ${LIB}/$file ]; then
1117 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1120 echo Fixing $file, uses of new
1121 sed -e '/Widget old, new;/i\
1126 -e '/Widget old, new;/a\
1129 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1130 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1132 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1136 # class in Xm/BaseClassI.h
1137 file=Xm/BaseClassI.h
1138 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1139 mkdir ${LIB}/sys 2>/dev/null
1140 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1141 chmod +w ${LIB}/$file 2>/dev/null
1142 chmod a+r ${LIB}/$file 2>/dev/null
1145 if [ -r ${LIB}/$file ]; then
1146 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1149 echo Fixing $file, prototype parameter name
1150 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1151 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1153 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1159 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1160 # Note that version 3 of the NeXT system has wait.h in a different directory,
1161 # so that this code won't do anything. But wait.h in version 3 has a
1162 # conditional, so it doesn't need this fix. So everything is okay.
1164 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1165 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1166 chmod +w ${LIB}/$file 2>/dev/null
1169 if [ -r ${LIB}/$file ] \
1170 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1171 echo Fixing $file, bad wait formal
1172 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1173 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1174 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1179 # Don't use or define the name va_list in stdio.h.
1180 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
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
1185 chmod a+r ${LIB}/$file 2>/dev/null
1188 if [ -r ${LIB}/$file ]; then
1189 echo Fixing $file, use of va_list
1190 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1191 (echo "#define __need___va_list"
1192 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1193 # Use __gnuc_va_list in arg types in place of va_list.
1194 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1195 # trailing parentheses and semicolon save all other systems from this.
1196 # Define __va_list__ (something harmless and unused) instead of va_list.
1197 # Don't claim to have defined va_list.
1198 sed -e 's@ va_list @ __gnuc_va_list @' \
1199 -e 's@ va_list)@ __gnuc_va_list)@' \
1200 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1201 -e 's@ va_list@ __va_list__@' \
1202 -e 's@\*va_list@*__va_list__@' \
1203 -e 's@ __va_list)@ __gnuc_va_list)@' \
1204 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1205 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1206 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1207 ${LIB}/$file >> ${LIB}/${file}.sed
1209 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1210 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1215 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1217 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1218 if grep -s ULTRIX $file; then
1219 echo "/* This file intentionally left blank. */" > $LIB/$file
1223 # parameter to atof not const on DECstation Ultrix V4.0.
1224 # also get rid of bogus inline definitions in HP-UX 8.0
1226 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1227 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1228 chmod +w ${LIB}/$file 2>/dev/null
1229 chmod a+r ${LIB}/$file 2>/dev/null
1232 if [ -r ${LIB}/$file ]; then
1233 echo Fixing $file, non-const arg
1234 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1235 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1236 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1237 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1238 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1239 ${LIB}/$file > ${LIB}/${file}.sed
1240 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1241 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1246 # Avoid nested comments on Ultrix 4.3.
1248 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1249 mkdir ${LIB}/rpc 2>/dev/null
1250 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1251 chmod +w ${LIB}/$file 2>/dev/null
1252 chmod a+r ${LIB}/$file 2>/dev/null
1255 if [ -r ${LIB}/$file ]; then
1256 echo Fixing $file, nested comment
1257 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1258 ${LIB}/$file > ${LIB}/$file.sed
1259 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1260 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1265 # This file in RISC/os uses /**/ to concatenate two tokens.
1267 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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
1272 if [ -r ${LIB}/$file ]; then
1273 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1274 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1275 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1281 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1282 mkdir ${LIB}/rpc 2>/dev/null
1283 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1284 chmod +w ${LIB}/$file 2>/dev/null
1285 chmod a+r ${LIB}/$file 2>/dev/null
1288 if [ -r ${LIB}/$file ]; then
1289 echo Fixing $file, nested comment
1290 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1291 ${LIB}/$file > ${LIB}/$file.sed
1292 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1293 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1298 # In limits.h, put #ifndefs around things that are supposed to be defined
1299 # in float.h to avoid redefinition errors if float.h is included first.
1300 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1301 # multi line comments and the inserted #endif winds up inside the
1302 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1303 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1304 # are there, and we do not add them ourselves.
1305 for file in limits.h sys/limits.h; do
1306 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1307 mkdir ${LIB}/sys 2>/dev/null
1308 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1309 chmod +w ${LIB}/$file 2>/dev/null
1310 chmod a+r ${LIB}/$file 2>/dev/null
1313 if [ -r ${LIB}/$file ]; then
1314 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1318 sed -e '/[ ]FLT_MIN[ ]/i\
1321 -e '/[ ]FLT_MIN[ ]/a\
1324 -e '/[ ]FLT_MAX[ ]/i\
1327 -e '/[ ]FLT_MAX[ ]/a\
1330 -e '/[ ]FLT_DIG[ ]/i\
1333 -e '/[ ]FLT_DIG[ ]/a\
1336 -e '/[ ]DBL_MIN[ ]/i\
1339 -e '/[ ]DBL_MIN[ ]/a\
1342 -e '/[ ]DBL_MAX[ ]/i\
1345 -e '/[ ]DBL_MAX[ ]/a\
1348 -e '/[ ]DBL_DIG[ ]/i\
1351 -e '/[ ]DBL_DIG[ ]/a\
1354 ${LIB}/$file > ${LIB}/${file}.sed
1355 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1357 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1358 echo Deleting ${LIB}/$file\; no fixes were needed.
1364 # In math.h, put #ifndefs around things that might be defined in a gcc
1365 # specific math-*.h file.
1367 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1368 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1369 chmod +w ${LIB}/$file 2>/dev/null
1370 chmod a+r ${LIB}/$file 2>/dev/null
1373 if [ -r ${LIB}/$file ]; then
1375 sed -e '/define[ ]HUGE_VAL[ ]/i\
1378 -e '/define[ ]HUGE_VAL[ ]/a\
1381 ${LIB}/$file > ${LIB}/${file}.sed
1382 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1383 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1384 echo Deleting ${LIB}/$file\; no fixes were needed.
1389 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1391 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1392 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1393 chmod +w ${LIB}/$file 2>/dev/null
1394 chmod a+r ${LIB}/$file 2>/dev/null
1397 if [ -r ${LIB}/$file ]; then
1399 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1400 ${LIB}/$file > ${LIB}/${file}.sed
1401 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1402 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1407 # Fix incorrect S_IF* definitions on m88k-sysv3.
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/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1418 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1419 ${LIB}/$file > ${LIB}/${file}.sed
1420 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1421 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1426 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
1427 for file in stdio.h stdlib.h; do
1428 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1429 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1430 chmod +w ${LIB}/$file 2>/dev/null
1431 chmod a+r ${LIB}/$file 2>/dev/null
1434 if [ -r ${LIB}/$file ]; then
1435 echo Fixing $file, getopt declaration
1436 sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
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
1445 # These two files on SunOS 4 are included by other files
1446 # in the same directory, using "...". So we must make sure they exist
1447 # in the same directory as the other fixed files.
1448 if [ -r ${INPUT}/multimedia/audio_errno.h ]
1450 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
1452 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
1454 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
1457 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1458 # need to fix some additional files. This is the same test for ISC that
1460 if test -d /etc/conf/kconfig.d \
1461 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1462 echo "Fixing ISC __STDC__ goof in several files..."
1463 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1465 if test -r ${LIB}/$name; then
1470 # On Interactive 2.2, certain traditional Unix definitions
1471 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1472 # defined, not just if _POSIX_SOURCE is defined. This makes it
1473 # impossible to compile any nontrivial program except with -posix.
1475 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1476 < $file > ${LIB}/$name.
1477 mv ${LIB}/$name. ${LIB}/$name
1480 echo "Fixing ISC fmod declaration"
1481 # This one's already been fixed for other things.
1483 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1486 echo "Fixing nested comments in ISC <sys/limits.h>"
1488 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1489 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1492 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1493 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1494 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1495 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1497 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1498 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1499 chmod +w ${LIB}/$file 2>/dev/null
1500 chmod a+r ${LIB}/$file 2>/dev/null
1503 if [ -r ${LIB}/$file ]; then
1504 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1505 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1506 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1512 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1513 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1514 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1516 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1517 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1518 chmod +w ${LIB}/$file 2>/dev/null
1519 chmod a+r ${LIB}/$file 2>/dev/null
1522 if [ -r ${LIB}/$file ]; then
1523 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1524 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1525 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1531 # This file on SunOS 4 has a very large macro. When the sed loop
1532 # tries pull it in, it overflows the pattern space size of the SunOS
1533 # sed (GNU sed does not have this problem). Since the file does not
1534 # require fixing, we remove it from the fixed directory.
1535 file=sundev/ipi_error.h
1536 if [ -r ${LIB}/$file ]; then
1537 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1541 echo 'Removing unneeded directories:'
1543 files=`find . -type d -print | sort -r`
1544 for file in $files; do
1545 rmdir $LIB/$file > /dev/null 2>&1
1549 echo 'Making internal symbolic non-directory links'
1551 files=`find . -type l -print`
1552 for file in $files; do
1553 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1554 if expr "$dest" : '[^/].*' > /dev/null; then
1555 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1556 if [ -f $target ]; then
1557 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1563 # Make sure that any include files referenced using double quotes
1564 # exist in the fixed directory. This comes last since otherwise
1565 # we might end up deleting some of these files "because they don't
1567 while [ -n "$required" ]; do
1571 while [ $# != 0 ]; do
1572 # $1 is the directory to copy from, $2 is the unfixed file,
1573 # $3 is the fixed file name.
1576 if [ -r $2 ] && [ ! -r $3 ]; then
1577 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1578 chmod +w $3 2>/dev/null
1579 chmod a+r $3 2>/dev/null
1581 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1582 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1583 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1584 newreq="$newreq $1 $dir/$include $dir2/$include"
1592 echo 'Cleaning up DONE files.'
1594 find . -name DONE -exec rm -f '{}' ';'