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 /bin/ex from failing if the EXINIT environment variable
22 # was set to something invalid.
26 # Directory in which to store the results.
27 LIB=${1?"fixincludes: output directory not specified"}
29 # Make sure it exists.
30 if [ ! -d $LIB ]; then
37 # Fail if no arg to specify a directory for the output.
39 then echo fixincludes: no output directory specified
43 echo Building fixed headers in ${LIB}
45 # Determine whether this system has symbolic links.
46 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
47 rm -f $LIB/ShouldNotExist
53 echo Finding directories and links to directories
55 # Find all directories and all symlinks that point to directories.
56 # Put the list in $files.
57 # Each time we find a symlink, add it to newdirs
58 # so that we do another find within the dir the link points to.
59 # Note that $files may have duplicates in it;
60 # later parts of this file are supposed to ignore them.
63 while [ -n "$dirs" ] && [ $levels -gt 0 ]
65 levels=`expr $levels - 1`
69 echo " Searching $INPUT/$d"
75 # Find all directories under $d, relative to $d, excluding $d itself.
76 files="$files `find $d -type d -print | \
77 sed -e '/\/\.$/d' -e '/^\.$/d'`"
78 # Find all links to directories.
79 # Using `-exec test -d' in find fails on some systems,
80 # and trying to run test via sh fails on others,
81 # so this is the simplest alternative left.
82 # First find all the links, then test each one.
85 theselinks=`find $d -type l -print`
86 for d1 in $theselinks --dummy--
88 # If the link points to a directory,
89 # add that dir to $newdirs
92 newdirs="$newdirs $d1"
97 files="$files $newdirs"
102 echo "All directories (including links to directories):"
105 for file in $files; do
107 if [ ! -d $LIB/$file ]
108 then mkdir $LIB/$file
113 # treetops gets an alternating list
114 # of old directories to copy
115 # and the new directories to copy to.
116 treetops="${INPUT} ${LIB}"
119 echo 'Making symbolic directory links'
120 for file in $files; do
121 dest=`ls -ld $file | sed -n 's/.*-> //p'`
124 # In case $dest is relative, get to $file's dir first.
126 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
127 # Check that the target directory exists.
128 # Redirections changed to avoid bug in sh on Ultrix.
129 (cd $dest) > /dev/null 2>&1
132 # X gets the dir that the link actually leads to.
134 # If a link points to ., make a similar link to .
135 if [ $x = $INPUT ]; then
136 echo $file '->' . ': Making link'
137 rm -fr ${LIB}/$file > /dev/null 2>&1
138 ln -s . ${LIB}/$file > /dev/null 2>&1
139 # If link leads back into ${INPUT},
140 # make a similar link here.
141 elif expr $x : "${INPUT}/.*" > /dev/null; then
142 # Y gets the actual target dir name, relative to ${INPUT}.
143 y=`echo $x | sed -n "s&${INPUT}/&&p"`
144 echo $file '->' $y ': Making link'
145 rm -fr ${LIB}/$file > /dev/null 2>&1
146 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
148 # If the link is to a dir $target outside ${INPUT},
149 # repoint the link at ${INPUT}/root$target
150 # and process $target into ${INPUT}/root$target
151 # treat this directory as if it actually contained the files.
152 echo $file '->' root$x ': Making link'
153 if [ -d $LIB/root$x ]
159 while [ x$dirname != x ]; do
160 component=`echo $dirname | sed -e 's|/.*$||'`
161 mkdir $component >/dev/null 2>&1
163 dirmade=$dirmade/$component
164 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
167 rm -fr ${LIB}/$file > /dev/null 2>&1
168 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
169 treetops="$treetops $x ${LIB}/root$x"
178 while [ $# != 0 ]; do
179 # $1 is an old directory to copy, and $2 is the new directory to copy to.
182 # The same dir can appear more than once in treetops.
183 # There's no need to scan it more than once.
189 echo Fixing directory $1 into $2
190 # Check .h files which are symlinks as well as those which are files.
191 # A link to a header file will not be processed by anything but this.
193 files=`find . -name '*.h' \( -type f -o -type l \) -print`
195 files=`find . -name '*.h' -type f -print`
197 echo Checking header files
199 # Note that BSD43_* are used on recent MIPS systems.
200 for file in $files; do
201 # This call to egrep is essential, since checking a file with egrep
202 # is much faster than actually trying to fix it.
203 # It is also essential that most files *not* match!
204 # Thus, matching every #endif is unacceptable.
205 # But the argument to egrep must be kept small, or many versions of egrep
206 # won't be able to handle it.
207 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
208 if egrep '[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
210 if [ -r $file ]; then
211 cp $file $2/$file >/dev/null 2>&1 \
212 || echo "Can't copy $file"
214 # Following two lines removed.
215 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
216 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
222 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
223 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
224 /#define._IO/ s/'\''x'\''/x/g
225 /#define.BSD43__IO/ s/'\''x'\''/x/g
226 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
227 /#define.CTRL/ s/'\''c'\''/c/g
228 /#define._CTRL/ s/'\''c'\''/c/g
229 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
230 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
231 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
232 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
233 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
234 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
235 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
236 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
237 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
238 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
239 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
240 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
241 /^#define.NULL[ ]/ i\
243 ' $2/$file > $2/$file.sed
244 mv $2/$file.sed $2/$file
245 if cmp $file $2/$file >/dev/null 2>&1; then
246 echo Deleting $2/$file\; no fixes were needed.
257 # Fix one other error in this file: a mismatched quote not inside a C comment.
258 file=sundev/vuid_event.h
259 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
260 mkdir ${LIB}/sundev 2>/dev/null
261 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
262 chmod +w ${LIB}/$file 2>/dev/null
265 if [ -r ${LIB}/$file ]; then
266 echo Fixing $file comment
267 ex ${LIB}/$file <<EOF
268 g/doesn't/s/doesn't/does not/
271 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
272 echo Deleting ${LIB}/$file\; no fixes were needed.
277 # Fix this Sun file to avoid interfering with stddef.h.
279 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
280 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
281 chmod +w ${LIB}/$file 2>/dev/null
284 if [ -r ${LIB}/$file ]; then
286 ex ${LIB}/$file <<EOF
298 #ifndef _GCC_PTRDIFF_T
299 #define _GCC_PTRDIFF_T
316 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
317 echo Deleting ${LIB}/$file\; no fixes were needed.
322 # Fix this file to avoid interfering with stddef.h.
324 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
325 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
326 chmod +w ${LIB}/$file 2>/dev/null
329 if [ -r ${LIB}/$file ]; then
331 ex ${LIB}/$file <<EOF
343 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
344 echo Deleting ${LIB}/$file\; no fixes were needed.
349 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
350 # structure definition.
352 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
353 mkdir ${LIB}/rpcsvc 2>/dev/null
354 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
355 chmod +w ${LIB}/$file 2>/dev/null
358 if [ -r ${LIB}/$file ]; then
359 echo Fixing $file, definition of statsswtch
360 ex ${LIB}/$file <<EOF
364 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
365 echo Deleting ${LIB}/$file\; no fixes were needed.
370 # Fix an error in this file: a missing semi-colon at the end of the nodeent
371 # structure definition.
372 file=netdnet/dnetdb.h
373 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
374 mkdir ${LIB}/netdnet 2>/dev/null
375 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
376 chmod +w ${LIB}/$file 2>/dev/null
379 if [ -r ${LIB}/$file ]; then
380 echo Fixing $file, definition of nodeent
381 ex ${LIB}/$file <<EOF
382 g/char.*na_addr *$/s//&;/
385 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
386 echo Deleting ${LIB}/$file\; no fixes were needed.
391 # Check for bad #ifdef line (in Ultrix 4.1)
393 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
394 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
395 chmod +w ${LIB}/$file 2>/dev/null
398 if [ -r ${LIB}/$file ]; then
399 echo Fixing $file, bad \#ifdef line
400 ex ${LIB}/$file <<EOF
401 g/^#ifdef KERNEL && !defined/
402 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
405 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
406 echo Deleting ${LIB}/$file\; no fixes were needed.
411 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
412 # Only needed if commenting out junk after #endif.
414 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
415 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
416 # chmod +w ${LIB}/$file 2>/dev/null
419 #if [ -r ${LIB}/$file ]; then
420 # echo Fixing $file, nested comments
421 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
422 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
423 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
424 # echo Deleting ${LIB}/$file\; no fixes were needed.
429 # Check for superfluous `static' (in Ultrix 4.2)
431 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
432 mkdir ${LIB}/machine 2>/dev/null
433 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
434 chmod +w ${LIB}/$file 2>/dev/null
437 if [ -r ${LIB}/$file ]; then
438 echo Fixing $file, superfluous static
439 ex ${LIB}/$file <<EOF
440 g/^static struct tlb_pid_state/
444 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
445 echo Deleting ${LIB}/$file\; no fixes were needed.
448 # This file has an alternative name, mips/cpu.h. Fix that name, too.
449 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
450 mkdir ${LIB}/mips 2>&-
451 ln ${LIB}/$file ${LIB}/mips/cpu.h
456 # Incorrect sprintf declaration in X11/Xmu.h
458 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
459 mkdir ${LIB}/X11 2>/dev/null
460 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
461 chmod +w ${LIB}/$file 2>/dev/null
464 if [ -r ${LIB}/$file ]; then
465 echo Fixing $file sprintf declaration
466 ex ${LIB}/$file <<EOF
467 /^extern char \* sprintf();$/c
469 extern char * sprintf();
470 #endif /* !defined __STDC__ */
474 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
475 echo Deleting ${LIB}/$file\; no fixes were needed.
480 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
481 # (It's not clear whether the right file name is this or X11/Xmu.h.)
483 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
484 mkdir ${LIB}/X11/Xmu 2>/dev/null
485 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
486 chmod +w ${LIB}/$file 2>/dev/null
489 if [ -r ${LIB}/$file ]; then
490 echo Fixing $file sprintf declaration
491 ex ${LIB}/$file <<EOF
492 /^extern char \* sprintf();$/c
494 extern char * sprintf();
495 #endif /* !defined __STDC__ */
499 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
500 echo Deleting ${LIB}/$file\; no fixes were needed.
505 # Check for missing ';' in struct
507 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
508 mkdir ${LIB}/netinet 2>/dev/null
509 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
510 chmod +w ${LIB}/$file 2>/dev/null
513 if [ -r ${LIB}/$file ]; then
515 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
516 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
517 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
518 echo Deleting ${LIB}/$file\; no fixes were needed.
523 # Fix the CAT macro in SunOS memvar.h.
524 file=pixrect/memvar.h
525 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
526 mkdir ${LIB}/pixrect 2>/dev/null
527 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
528 chmod +w ${LIB}/$file 2>/dev/null
531 if [ -r ${LIB}/$file ]; then
533 sed -e '/^#define.CAT(a,b)/ i\
535 #define CAT(a,b) a##b\
537 /^#define.CAT(a,b)/ a\
539 ' ${LIB}/$file > ${LIB}/${file}.sed
540 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
541 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
542 echo Deleting ${LIB}/$file\; no fixes were needed.
547 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
549 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
550 mkdir ${LIB}/rpcsvc 2>/dev/null
551 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
552 chmod +w ${LIB}/$file 2>/dev/null
555 if [ -r ${LIB}/$file ]; then
557 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
558 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
559 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
560 echo Deleting ${LIB}/$file\; no fixes were needed.
565 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
567 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
568 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
569 chmod +w ${LIB}/$file 2>/dev/null
572 if [ -r ${LIB}/$file ]; then
574 sed -e 's/int abort/void abort/g' \
575 -e 's/int free/void free/g' \
576 -e 's/char \* calloc/void \* calloc/g' \
577 -e 's/char \* malloc/void \* malloc/g' \
578 -e 's/char \* realloc/void \* realloc/g' \
579 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
580 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
581 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
582 echo Deleting ${LIB}/$file\; no fixes were needed.
587 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
589 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
590 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
591 chmod +w ${LIB}/$file 2>/dev/null
594 if [ -r ${LIB}/$file ]; then
596 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
597 -e 's/int[ ][ ]*free/void free/g' \
598 ${LIB}/$file > ${LIB}/${file}.sed
599 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
600 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
601 echo Deleting ${LIB}/$file\; no fixes were needed.
607 # Fix bogus comment in <locale.h> on SunOS 4.1.
609 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
610 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
611 chmod +w ${LIB}/$file 2>/dev/null
614 if [ -r ${LIB}/$file ]; then
616 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
617 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
618 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
619 echo Deleting ${LIB}/$file\; no fixes were needed.
624 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
625 file=hsfs/hsfs_spec.h
626 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
627 mkdir ${LIB}/hsfs 2>/dev/null
628 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
629 chmod +w ${LIB}/$file 2>/dev/null
632 if [ -r ${LIB}/$file ]; then
634 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
635 ${LIB}/$file > ${LIB}/${file}.sed
636 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
637 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
638 echo Deleting ${LIB}/$file\; no fixes were needed.
643 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
645 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
646 mkdir ${LIB}/hsfs 2>/dev/null
647 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
648 chmod +w ${LIB}/$file 2>/dev/null
651 if [ -r ${LIB}/$file ]; then
653 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
654 ${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
657 echo Deleting ${LIB}/$file\; no fixes were needed.
662 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
664 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
665 mkdir ${LIB}/hsfs 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
670 if [ -r ${LIB}/$file ]; then
672 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
673 ${LIB}/$file > ${LIB}/${file}.sed
674 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
675 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
676 echo Deleting ${LIB}/$file\; no fixes were needed.
681 # Incorrect #include in Sony News-OS 3.2.
682 file=machine/machparam.h
683 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
684 mkdir ${LIB}/machine 2>/dev/null
685 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
686 chmod +w ${LIB}/$file 2>/dev/null
689 if [ -r ${LIB}/$file ]; then
690 echo Fixing $file, incorrect \#include
691 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
692 ${LIB}/$file > ${LIB}/${file}.sed
693 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
694 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
695 echo Deleting ${LIB}/$file\; no fixes were needed.
700 # Multiline comment after typedef on IRIX 4.0.1.
702 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
703 mkdir ${LIB}/sys 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
708 if [ -r ${LIB}/$file ]; then
709 echo Fixing $file, comment in the middle of \#ifdef
710 sed -e 's@type of the result@type of the result */@' \
711 -e 's@of the sizeof@/* of the sizeof@' \
712 ${LIB}/$file > ${LIB}/${file}.sed
713 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
714 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
715 echo Deleting ${LIB}/$file\; no fixes were needed.
720 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
721 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
722 # many other systems have similar text but correct versions of the file.
723 # To ensure only Sun's is fixed, we grep for a likely unique string.
725 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
726 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
727 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
728 chmod +w ${LIB}/$file 2>/dev/null
730 if [ -r ${LIB}/$file ]; then
732 cat > ${LIB}/$file << EOF
733 /* This file was generated by fixincludes */
738 extern void *memccpy();
739 extern void *memchr();
740 extern void *memcpy();
741 extern void *memset();
743 extern char *memccpy();
744 extern char *memchr();
745 extern char *memcpy();
746 extern char *memset();
747 #endif /* __STDC__ */
756 # parameters not const on DECstation Ultrix V4.0.
758 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
759 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
760 chmod +w ${LIB}/$file 2>/dev/null
763 if [ -r ${LIB}/$file ]; then
764 echo Fixing $file, non-const arg
765 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
766 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
767 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
768 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
769 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
770 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
771 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
772 ${LIB}/$file > ${LIB}/${file}.sed
773 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
774 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
775 echo Deleting ${LIB}/$file\; no fixes were needed.
780 # Don't use or define the name va_list in stdio.h.
781 # This is for ANSI and also to interoperate properly with gvarargs.h.
783 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
784 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
785 chmod +w ${LIB}/$file 2>/dev/null
788 if [ -r ${LIB}/$file ]; then
789 echo Fixing $file, use of va_list
790 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
791 (echo "#define __need___va_list"
792 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
793 # Use __gnuc_va_list in arg types in place of va_list.
794 # Define __va_list__ (something harmless and unused) instead of va_list.
795 # Don't claim to have defined va_list.
796 sed -e 's@ va_list @ __gnuc_va_list @' \
797 -e 's@ va_list@ __va_list__@' \
798 -e 's@VA_LIST@DUMMY_VA_LIST@' \
799 ${LIB}/$file >> ${LIB}/${file}.sed
801 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
802 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
803 echo Deleting ${LIB}/$file\; no fixes were needed.
808 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
810 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
811 if grep -s ULTRIX $file; then
812 echo "/* This file intentionally left blank. */" > $LIB/$file
816 # parameter to atof not const on DECstation Ultrix V4.0.
818 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
819 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
820 chmod +w ${LIB}/$file 2>/dev/null
823 if [ -r ${LIB}/$file ]; then
824 echo Fixing $file, non-const arg
825 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
826 ${LIB}/$file > ${LIB}/${file}.sed
827 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
828 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
829 echo Deleting ${LIB}/$file\; no fixes were needed.
834 # These two files on SunOS 4 are included by other files
835 # in the same directory, using "...". So we must make sure they exist
836 # in the same directory as the other fixed files.
837 if [ -r ${INPUT}/multimedia/audio_errno.h ]
839 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
841 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
843 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
846 echo 'Removing unneeded directories:'
848 files=`find . -type d -print | sort -r`
849 for file in $files; do
850 rmdir $LIB/$file > /dev/null 2>&1
854 echo 'Making internal symbolic non-directory links'
856 files=`find . -type l -print`
857 for file in $files; do
858 dest=`ls -ld $file | sed -n 's/.*-> //p'`
859 if expr "$dest" : '[^/].*' > /dev/null; then
860 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
861 if [ -f $target ]; then
862 ln -s $dest ${LIB}/$file >/dev/null 2>&1