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 # This prevents /bin/ex from failing if the current terminal type is
21 # This prevents two problems:
22 # Either ex might find a .exrc file and get confused,
23 # or ex might complain if the EXINIT variable is invalid.
24 # We know there is no .exrc in the GCC source.
25 # `set' is a no-op ex command.
29 # Define PWDCMD as a command to use to get the working dir
30 # in the form that we want.
34 # On an Apollo, discard everything before `/usr'.
35 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
39 # Directory in which to store the results.
40 LIB=${1?"fixincludes: output directory not specified"}
42 # Make sure it exists.
43 if [ ! -d $LIB ]; then
48 cd $LIB; LIB=`${PWDCMD}`
50 # Fail if no arg to specify a directory for the output.
52 then echo fixincludes: no output directory specified
56 echo Building fixed headers in ${LIB}
58 # Determine whether this system has symbolic links.
59 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
60 rm -f $LIB/ShouldNotExist
66 echo Finding directories and links to directories
68 # Find all directories and all symlinks that point to directories.
69 # Put the list in $files.
70 # Each time we find a symlink, add it to newdirs
71 # so that we do another find within the dir the link points to.
72 # Note that $files may have duplicates in it;
73 # later parts of this file are supposed to ignore them.
76 while [ -n "$dirs" ] && [ $levels -gt 0 ]
78 levels=`expr $levels - 1`
82 echo " Searching $INPUT/$d"
88 # Find all directories under $d, relative to $d, excluding $d itself.
89 files="$files `find $d -type d -print | \
90 sed -e '/\/\.$/d' -e '/^\.$/d'`"
91 # Find all links to directories.
92 # Using `-exec test -d' in find fails on some systems,
93 # and trying to run test via sh fails on others,
94 # so this is the simplest alternative left.
95 # First find all the links, then test each one.
98 theselinks=`find $d -type l -print`
99 for d1 in $theselinks --dummy--
101 # If the link points to a directory,
102 # add that dir to $newdirs
105 newdirs="$newdirs $d1"
110 files="$files $newdirs"
115 echo "All directories (including links to directories):"
118 for file in $files; do
120 if [ ! -d $LIB/$file ]
121 then mkdir $LIB/$file
126 # treetops gets an alternating list
127 # of old directories to copy
128 # and the new directories to copy to.
129 treetops="${INPUT} ${LIB}"
132 echo 'Making symbolic directory links'
133 for file in $files; do
134 dest=`ls -ld $file | sed -n 's/.*-> //p'`
137 # In case $dest is relative, get to $file's dir first.
139 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
140 # Check that the target directory exists.
141 # Redirections changed to avoid bug in sh on Ultrix.
142 (cd $dest) > /dev/null 2>&1
145 # X gets the dir that the link actually leads to.
147 # If a link points to ., make a similar link to .
148 if [ $x = $INPUT ]; then
149 echo $file '->' . ': Making link'
150 rm -fr ${LIB}/$file > /dev/null 2>&1
151 ln -s . ${LIB}/$file > /dev/null 2>&1
152 # If link leads back into ${INPUT},
153 # make a similar link here.
154 elif expr $x : "${INPUT}/.*" > /dev/null; then
155 # Y gets the actual target dir name, relative to ${INPUT}.
156 y=`echo $x | sed -n "s&${INPUT}/&&p"`
157 echo $file '->' $y ': Making link'
158 rm -fr ${LIB}/$file > /dev/null 2>&1
159 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
161 # If the link is to a dir $target outside ${INPUT},
162 # repoint the link at ${INPUT}/root$target
163 # and process $target into ${INPUT}/root$target
164 # treat this directory as if it actually contained the files.
165 echo $file '->' root$x ': Making link'
166 if [ -d $LIB/root$x ]
172 while [ x$dirname != x ]; do
173 component=`echo $dirname | sed -e 's|/.*$||'`
174 mkdir $component >/dev/null 2>&1
176 dirmade=$dirmade/$component
177 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
180 rm -fr ${LIB}/$file > /dev/null 2>&1
181 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
182 treetops="$treetops $x ${LIB}/root$x"
191 while [ $# != 0 ]; do
192 # $1 is an old directory to copy, and $2 is the new directory to copy to.
195 # The same dir can appear more than once in treetops.
196 # There's no need to scan it more than once.
202 echo Fixing directory $1 into $2
203 # Check .h files which are symlinks as well as those which are files.
204 # A link to a header file will not be processed by anything but this.
206 files=`find . -name '*.h' \( -type f -o -type l \) -print`
208 files=`find . -name '*.h' -type f -print`
210 echo Checking header files
212 # Note that BSD43_* are used on recent MIPS systems.
213 for file in $files; do
214 # This call to egrep is essential, since checking a file with egrep
215 # is much faster than actually trying to fix it.
216 # It is also essential that most files *not* match!
217 # Thus, matching every #endif is unacceptable.
218 # But the argument to egrep must be kept small, or many versions of egrep
219 # won't be able to handle it.
220 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
221 if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
223 if [ -r $file ]; then
224 cp $file $2/$file >/dev/null 2>&1 \
225 || echo "Can't copy $file"
227 # Following two lines removed.
228 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
229 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
235 /\/\// s|//\(.*\)$|/*\1*/|
236 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
237 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
238 /#define._IO/ s/'\''x'\''/x/g
239 /#define.BSD43__IO/ s/'\''x'\''/x/g
240 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
241 /#define.CTRL/ s/'\''c'\''/c/g
242 /#define._CTRL/ s/'\''c'\''/c/g
243 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
244 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
245 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
246 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
247 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
248 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
249 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
250 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
251 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
252 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
253 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
254 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
255 /^#define.NULL[ ]/ i\
257 ' $2/$file > $2/$file.sed
258 mv $2/$file.sed $2/$file
259 if cmp $file $2/$file >/dev/null 2>&1; then
260 echo Deleting $2/$file\; no fixes were needed.
271 # Fix one other error in this file: a mismatched quote not inside a C comment.
272 file=sundev/vuid_event.h
273 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
274 mkdir ${LIB}/sundev 2>/dev/null
275 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
276 chmod +w ${LIB}/$file 2>/dev/null
279 if [ -r ${LIB}/$file ]; then
280 echo Fixing $file comment
281 ex ${LIB}/$file <<EOF
282 g/doesn't/s/doesn't/does not/
285 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
286 echo Deleting ${LIB}/$file\; no fixes were needed.
291 # Fix this Sun file to avoid interfering with stddef.h.
293 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
294 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
295 chmod +w ${LIB}/$file 2>/dev/null
298 if [ -r ${LIB}/$file ]; then
300 ex ${LIB}/$file <<EOF
312 #ifndef _GCC_PTRDIFF_T
313 #define _GCC_PTRDIFF_T
330 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
331 echo Deleting ${LIB}/$file\; no fixes were needed.
336 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
337 # match e.g. ssize_t present in AIX for the ps/2.
339 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
340 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
341 chmod +w ${LIB}/$file 2>/dev/null
344 if [ -r ${LIB}/$file ]; then
346 ex ${LIB}/$file <<EOF
347 /typedef.*[ ]size_t.*;/
358 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
359 echo Deleting ${LIB}/$file\; no fixes were needed.
364 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
365 # structure definition.
367 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
368 mkdir ${LIB}/rpcsvc 2>/dev/null
369 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
370 chmod +w ${LIB}/$file 2>/dev/null
373 if [ -r ${LIB}/$file ]; then
374 echo Fixing $file, definition of statsswtch
375 ex ${LIB}/$file <<EOF
379 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
380 echo Deleting ${LIB}/$file\; no fixes were needed.
385 # Fix an error in this file: a missing semi-colon at the end of the nodeent
386 # structure definition.
387 file=netdnet/dnetdb.h
388 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
389 mkdir ${LIB}/netdnet 2>/dev/null
390 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
391 chmod +w ${LIB}/$file 2>/dev/null
394 if [ -r ${LIB}/$file ]; then
395 echo Fixing $file, definition of nodeent
396 ex ${LIB}/$file <<EOF
397 g/char.*na_addr *$/s//&;/
400 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
401 echo Deleting ${LIB}/$file\; no fixes were needed.
406 # Check for bad #ifdef line (in Ultrix 4.1)
408 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
409 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
410 chmod +w ${LIB}/$file 2>/dev/null
413 if [ -r ${LIB}/$file ]; then
414 echo Fixing $file, bad \#ifdef line
415 ex ${LIB}/$file <<EOF
416 g/^#ifdef KERNEL && !defined/
417 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
420 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
421 echo Deleting ${LIB}/$file\; no fixes were needed.
426 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
427 # Only needed if commenting out junk after #endif.
429 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
430 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
431 # chmod +w ${LIB}/$file 2>/dev/null
434 #if [ -r ${LIB}/$file ]; then
435 # echo Fixing $file, nested comments
436 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
437 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
438 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
439 # echo Deleting ${LIB}/$file\; no fixes were needed.
444 # Check for superfluous `static' (in Ultrix 4.2)
446 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
447 mkdir ${LIB}/machine 2>/dev/null
448 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
449 chmod +w ${LIB}/$file 2>/dev/null
452 if [ -r ${LIB}/$file ]; then
453 echo Fixing $file, superfluous static
454 ex ${LIB}/$file <<EOF
455 g/^static struct tlb_pid_state/
459 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
460 echo Deleting ${LIB}/$file\; no fixes were needed.
463 # This file has an alternative name, mips/cpu.h. Fix that name, too.
464 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
465 mkdir ${LIB}/mips 2>&-
466 ln ${LIB}/$file ${LIB}/mips/cpu.h
471 # Incorrect sprintf declaration in X11/Xmu.h
473 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
474 mkdir ${LIB}/X11 2>/dev/null
475 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
476 chmod +w ${LIB}/$file 2>/dev/null
479 if [ -r ${LIB}/$file ]; then
480 echo Fixing $file sprintf declaration
481 ex ${LIB}/$file <<EOF
482 /^extern char \* sprintf();$/c
484 extern char * sprintf();
485 #endif /* !defined __STDC__ */
489 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
490 echo Deleting ${LIB}/$file\; no fixes were needed.
495 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
496 # (It's not clear whether the right file name is this or X11/Xmu.h.)
498 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
499 mkdir ${LIB}/X11/Xmu 2>/dev/null
500 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
501 chmod +w ${LIB}/$file 2>/dev/null
504 if [ -r ${LIB}/$file ]; then
505 echo Fixing $file sprintf declaration
506 ex ${LIB}/$file <<EOF
507 /^extern char \* sprintf();$/c
509 extern char * sprintf();
510 #endif /* !defined __STDC__ */
514 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
515 echo Deleting ${LIB}/$file\; no fixes were needed.
520 # Check for missing ';' in struct
522 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
523 mkdir ${LIB}/netinet 2>/dev/null
524 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
525 chmod +w ${LIB}/$file 2>/dev/null
528 if [ -r ${LIB}/$file ]; then
530 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
531 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
532 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
533 echo Deleting ${LIB}/$file\; no fixes were needed.
538 # Fix the CAT macro in SunOS memvar.h.
539 file=pixrect/memvar.h
540 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
541 mkdir ${LIB}/pixrect 2>/dev/null
542 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
543 chmod +w ${LIB}/$file 2>/dev/null
546 if [ -r ${LIB}/$file ]; then
548 sed -e '/^#define.CAT(a,b)/ i\
550 #define CAT(a,b) a##b\
552 /^#define.CAT(a,b)/ a\
554 ' ${LIB}/$file > ${LIB}/${file}.sed
555 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
556 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
557 echo Deleting ${LIB}/$file\; no fixes were needed.
562 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
564 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
565 mkdir ${LIB}/rpcsvc 2>/dev/null
566 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
567 chmod +w ${LIB}/$file 2>/dev/null
570 if [ -r ${LIB}/$file ]; then
572 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
573 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
574 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
575 echo Deleting ${LIB}/$file\; no fixes were needed.
580 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
582 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
583 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
584 chmod +w ${LIB}/$file 2>/dev/null
587 if [ -r ${LIB}/$file ]; then
589 sed -e 's/int abort/void abort/g' \
590 -e 's/int free/void free/g' \
591 -e 's/char \* calloc/void \* calloc/g' \
592 -e 's/char \* malloc/void \* malloc/g' \
593 -e 's/char \* realloc/void \* realloc/g' \
594 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
595 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
596 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
597 echo Deleting ${LIB}/$file\; no fixes were needed.
602 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
604 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
605 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
606 chmod +w ${LIB}/$file 2>/dev/null
609 if [ -r ${LIB}/$file ]; then
611 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
612 -e 's/int[ ][ ]*free/void free/g' \
613 ${LIB}/$file > ${LIB}/${file}.sed
614 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
615 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
616 echo Deleting ${LIB}/$file\; no fixes were needed.
622 # Fix bogus comment in <locale.h> on SunOS 4.1.
624 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
625 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
626 chmod +w ${LIB}/$file 2>/dev/null
629 if [ -r ${LIB}/$file ]; then
631 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
632 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
633 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
634 echo Deleting ${LIB}/$file\; no fixes were needed.
639 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
640 file=hsfs/hsfs_spec.h
641 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
642 mkdir ${LIB}/hsfs 2>/dev/null
643 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
644 chmod +w ${LIB}/$file 2>/dev/null
647 if [ -r ${LIB}/$file ]; then
649 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
650 ${LIB}/$file > ${LIB}/${file}.sed
651 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
652 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
653 echo Deleting ${LIB}/$file\; no fixes were needed.
658 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
660 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
661 mkdir ${LIB}/hsfs 2>/dev/null
662 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
663 chmod +w ${LIB}/$file 2>/dev/null
666 if [ -r ${LIB}/$file ]; then
668 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
669 ${LIB}/$file > ${LIB}/${file}.sed
670 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
671 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
672 echo Deleting ${LIB}/$file\; no fixes were needed.
677 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
679 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
680 mkdir ${LIB}/hsfs 2>/dev/null
681 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
682 chmod +w ${LIB}/$file 2>/dev/null
685 if [ -r ${LIB}/$file ]; then
687 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
688 ${LIB}/$file > ${LIB}/${file}.sed
689 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
690 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
691 echo Deleting ${LIB}/$file\; no fixes were needed.
696 # Incorrect #include in Sony News-OS 3.2.
697 file=machine/machparam.h
698 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
699 mkdir ${LIB}/machine 2>/dev/null
700 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
701 chmod +w ${LIB}/$file 2>/dev/null
704 if [ -r ${LIB}/$file ]; then
705 echo Fixing $file, incorrect \#include
706 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
707 ${LIB}/$file > ${LIB}/${file}.sed
708 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
709 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
710 echo Deleting ${LIB}/$file\; no fixes were needed.
715 # Multiline comment after typedef on IRIX 4.0.1.
717 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
718 mkdir ${LIB}/sys 2>/dev/null
719 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
720 chmod +w ${LIB}/$file 2>/dev/null
723 if [ -r ${LIB}/$file ]; then
724 echo Fixing $file, comment in the middle of \#ifdef
725 sed -e 's@type of the result@type of the result */@' \
726 -e 's@of the sizeof@/* of the sizeof@' \
727 ${LIB}/$file > ${LIB}/${file}.sed
728 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
729 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
730 echo Deleting ${LIB}/$file\; no fixes were needed.
735 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
736 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
737 # many other systems have similar text but correct versions of the file.
738 # To ensure only Sun's is fixed, we grep for a likely unique string.
740 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
741 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
742 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
743 chmod +w ${LIB}/$file 2>/dev/null
745 if [ -r ${LIB}/$file ]; then
747 cat > ${LIB}/$file << EOF
748 /* This file was generated by fixincludes */
753 extern void *memccpy();
754 extern void *memchr();
755 extern void *memcpy();
756 extern void *memset();
758 extern char *memccpy();
759 extern char *memchr();
760 extern char *memcpy();
761 extern char *memset();
762 #endif /* __STDC__ */
771 # parameters not const on DECstation Ultrix V4.0.
773 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
774 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
775 chmod +w ${LIB}/$file 2>/dev/null
778 if [ -r ${LIB}/$file ]; then
779 echo Fixing $file, non-const arg
780 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
781 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
782 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
783 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
784 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
785 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
786 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
787 ${LIB}/$file > ${LIB}/${file}.sed
788 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
789 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
790 echo Deleting ${LIB}/$file\; no fixes were needed.
795 # Don't use or define the name va_list in stdio.h.
796 # This is for ANSI and also to interoperate properly with gvarargs.h.
798 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
799 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
800 chmod +w ${LIB}/$file 2>/dev/null
803 if [ -r ${LIB}/$file ]; then
804 echo Fixing $file, use of va_list
805 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
806 (echo "#define __need___va_list"
807 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
808 # Use __gnuc_va_list in arg types in place of va_list.
809 # Define __va_list__ (something harmless and unused) instead of va_list.
810 # Don't claim to have defined va_list.
811 sed -e 's@ va_list @ __gnuc_va_list @' \
812 -e 's@ va_list@ __va_list__@' \
813 -e 's@\*va_list@*__va_list__@' \
814 -e 's@VA_LIST@DUMMY_VA_LIST@' \
815 ${LIB}/$file >> ${LIB}/${file}.sed
817 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
818 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
819 echo Deleting ${LIB}/$file\; no fixes were needed.
824 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
826 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
827 if grep -s ULTRIX $file; then
828 echo "/* This file intentionally left blank. */" > $LIB/$file
832 # parameter to atof not const on DECstation Ultrix V4.0.
833 # also get rid of bogus inline definitions in HP-UX 8.0
835 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
836 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
837 chmod +w ${LIB}/$file 2>/dev/null
840 if [ -r ${LIB}/$file ]; then
841 echo Fixing $file, non-const arg
842 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
843 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
844 -e 's@inline double abs(double d) { return fabs(d); }@@' \
845 ${LIB}/$file > ${LIB}/${file}.sed
846 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
847 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
848 echo Deleting ${LIB}/$file\; no fixes were needed.
853 # These two files on SunOS 4 are included by other files
854 # in the same directory, using "...". So we must make sure they exist
855 # in the same directory as the other fixed files.
856 if [ -r ${INPUT}/multimedia/audio_errno.h ]
858 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
860 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
862 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
865 echo 'Removing unneeded directories:'
867 files=`find . -type d -print | sort -r`
868 for file in $files; do
869 rmdir $LIB/$file > /dev/null 2>&1
873 echo 'Making internal symbolic non-directory links'
875 files=`find . -type l -print`
876 for file in $files; do
877 dest=`ls -ld $file | sed -n 's/.*-> //p'`
878 if expr "$dest" : '[^/].*' > /dev/null; then
879 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
880 if [ -f $target ]; then
881 ln -s $dest ${LIB}/$file >/dev/null 2>&1