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
22 # Directory in which to store the results.
23 LIB=${1?"fixincludes: output directory not specified"}
25 # Make sure it exists.
26 if [ ! -d $LIB ]; then
33 # Fail if no arg to specify a directory for the output.
35 then echo fixincludes: no output directory specified
39 echo Building fixed headers in ${LIB}
41 # Determine whether this system has symbolic links.
42 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
43 rm -f $LIB/ShouldNotExist
49 echo Finding directories and links to directories
51 # Find all directories and all symlinks that point to directories.
52 # Put the list in $files.
53 # Each time we find a symlink, add it to newdirs
54 # so that we do another find within the dir the link points to.
55 # Note that $files may have duplicates in it;
56 # later parts of this file are supposed to ignore them.
59 while [ -n "$dirs" ] && [ $levels -gt 0 ]
61 levels=`expr $levels - 1`
65 echo " Searching $INPUT/$d"
71 # Find all directories under $d, relative to $d, excluding $d itself.
72 files="$files `find $d -type d -print | \
73 sed -e '/\/\.$/d' -e '/^\.$/d'`"
74 # Find all links to directories.
75 # Using `-exec test -d' in find fails on some systems,
76 # and trying to run test via sh fails on others,
77 # so this is the simplest alternative left.
78 # First find all the links, then test each one.
81 theselinks=`find $d -type l -print`
82 for d1 in $theselinks --dummy--
84 # If the link points to a directory,
85 # add that dir to $newdirs
88 newdirs="$newdirs $d1"
93 files="$files $newdirs"
98 echo "All directories (including links to directories):"
101 for file in $files; do
103 if [ ! -d $LIB/$file ]
104 then mkdir $LIB/$file
109 # treetops gets an alternating list
110 # of old directories to copy
111 # and the new directories to copy to.
112 treetops="${INPUT} ${LIB}"
115 echo 'Making symbolic directory links'
116 for file in $files; do
117 dest=`ls -ld $file | sed -n 's/.*-> //p'`
120 # In case $dest is relative, get to $file's dir first.
122 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
123 # Check that the target directory exists.
124 # Redirections changed to avoid bug in sh on Ultrix.
125 (cd $dest) > /dev/null 2>&1
128 # X gets the dir that the link actually leads to.
130 # If a link points to ., make a similar link to .
131 if [ $x = $INPUT ]; then
132 echo $file '->' . ': Making link'
133 rm -fr ${LIB}/$file > /dev/null 2>&1
134 ln -s . ${LIB}/$file > /dev/null 2>&1
135 # If link leads back into ${INPUT},
136 # make a similar link here.
137 elif expr $x : "${INPUT}/.*" > /dev/null; then
138 # Y gets the actual target dir name, relative to ${INPUT}.
139 y=`echo $x | sed -n "s&${INPUT}/&&p"`
140 echo $file '->' $y ': Making link'
141 rm -fr ${LIB}/$file > /dev/null 2>&1
142 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
144 # If the link is to a dir $target outside ${INPUT},
145 # repoint the link at ${INPUT}/root$target
146 # and process $target into ${INPUT}/root$target
147 # treat this directory as if it actually contained the files.
148 echo $file '->' root$x ': Making link'
149 if [ -d $LIB/root$x ]
155 while [ x$dirname != x ]; do
156 component=`echo $dirname | sed -e 's|/.*$||'`
157 mkdir $component >/dev/null 2>&1
159 dirmade=$dirmade/$component
160 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
163 rm -fr ${LIB}/$file > /dev/null 2>&1
164 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
165 treetops="$treetops $x ${LIB}/root$x"
174 while [ $# != 0 ]; do
175 # $1 is an old directory to copy, and $2 is the new directory to copy to.
178 # The same dir can appear more than once in treetops.
179 # There's no need to scan it more than once.
185 echo Fixing directory $1 into $2
186 # Check .h files which are symlinks as well as those which are files.
187 # A link to a header file will not be processed by anything but this.
188 files=`find . -name '*.h' \( -type f -o -type l \) -print`
189 echo Checking header files
191 # Note that BSD43_* are used on recent MIPS systems.
192 for file in $files; do
193 # This call to egrep is essential, since checking a file with egrep
194 # is much faster than actually trying to fix it.
195 # It is also essential that most files *not* match!
196 # Thus, matching every #endif is unacceptable.
197 # But the argument to egrep must be kept small, or many versions of egrep
198 # won't be able to handle it.
199 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
200 if egrep '[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
202 if [ -r $file ]; then
203 cp $file $2/$file >/dev/null 2>&1 \
204 || echo "Can't copy $file"
206 # Following two lines removed.
207 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
208 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
214 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
215 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
216 /#define._IO/ s/'\''x'\''/x/g
217 /#define.BSD43__IO/ s/'\''x'\''/x/g
218 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
219 /#define.CTRL/ s/'\''c'\''/c/g
220 /#define._CTRL/ s/'\''c'\''/c/g
221 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
222 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
223 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
224 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
225 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
226 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
227 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
228 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
229 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
230 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
231 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
232 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
233 /^#define.NULL[ ]/ i\
235 ' $2/$file > $2/$file.sed
236 mv $2/$file.sed $2/$file
237 if cmp $file $2/$file >/dev/null 2>&1; then
238 echo Deleting $2/$file\; no fixes were needed.
249 # Fix one other error in this file: a mismatched quote not inside a C comment.
250 file=sundev/vuid_event.h
251 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
252 mkdir ${LIB}/sundev 2>/dev/null
253 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
254 chmod +w ${LIB}/$file 2>/dev/null
257 if [ -r ${LIB}/$file ]; then
258 echo Fixing $file comment
259 ex ${LIB}/$file <<EOF
260 g/doesn't/s/doesn't/does not/
263 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
264 echo Deleting ${LIB}/$file\; no fixes were needed.
269 # Fix this Sun file to avoid interfering with stddef.h.
271 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
272 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
273 chmod +w ${LIB}/$file 2>/dev/null
276 if [ -r ${LIB}/$file ]; then
278 ex ${LIB}/$file <<EOF
290 #ifndef _GCC_PTRDIFF_T
291 #define _GCC_PTRDIFF_T
308 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
309 echo Deleting ${LIB}/$file\; no fixes were needed.
314 # Fix this file to avoid interfering with stddef.h.
316 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
317 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
318 chmod +w ${LIB}/$file 2>/dev/null
321 if [ -r ${LIB}/$file ]; then
323 ex ${LIB}/$file <<EOF
335 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
336 echo Deleting ${LIB}/$file\; no fixes were needed.
341 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
342 # structure definition.
344 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
345 mkdir ${LIB}/rpcsvc 2>/dev/null
346 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
347 chmod +w ${LIB}/$file 2>/dev/null
350 if [ -r ${LIB}/$file ]; then
351 echo Fixing $file, definition of statsswtch
352 ex ${LIB}/$file <<EOF
356 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
357 echo Deleting ${LIB}/$file\; no fixes were needed.
362 # Fix an error in this file: a missing semi-colon at the end of the nodeent
363 # structure definition.
364 file=netdnet/dnetdb.h
365 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
366 mkdir ${LIB}/netdnet 2>/dev/null
367 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
368 chmod +w ${LIB}/$file 2>/dev/null
371 if [ -r ${LIB}/$file ]; then
372 echo Fixing $file, definition of nodeent
373 ex ${LIB}/$file <<EOF
374 g/char.*na_addr *$/s//&;/
377 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
378 echo Deleting ${LIB}/$file\; no fixes were needed.
383 # Check for bad #ifdef line (in Ultrix 4.1)
385 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
386 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
387 chmod +w ${LIB}/$file 2>/dev/null
390 if [ -r ${LIB}/$file ]; then
391 echo Fixing $file, bad \#ifdef line
392 ex ${LIB}/$file <<EOF
393 g/^#ifdef KERNEL && !defined/
394 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
397 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
398 echo Deleting ${LIB}/$file\; no fixes were needed.
403 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
404 # Only needed if commenting out junk after #endif.
406 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
407 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
408 # chmod +w ${LIB}/$file 2>/dev/null
411 #if [ -r ${LIB}/$file ]; then
412 # echo Fixing $file, nested comments
413 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
414 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
415 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
416 # echo Deleting ${LIB}/$file\; no fixes were needed.
421 # Check for superfluous `static' (in Ultrix 4.2)
423 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
424 mkdir ${LIB}/machine 2>/dev/null
425 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
426 chmod +w ${LIB}/$file 2>/dev/null
429 if [ -r ${LIB}/$file ]; then
430 echo Fixing $file, superfluous static
431 ex ${LIB}/$file <<EOF
432 g/^static struct tlb_pid_state/
436 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
437 echo Deleting ${LIB}/$file\; no fixes were needed.
440 # This file has an alternative name, mips/cpu.h. Fix that name, too.
441 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
442 mkdir ${LIB}/mips 2>&-
443 ln ${LIB}/$file ${LIB}/mips/cpu.h
448 # Incorrect sprintf declaration in X11/Xmu.h
450 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
451 mkdir ${LIB}/X11 2>/dev/null
452 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
453 chmod +w ${LIB}/$file 2>/dev/null
456 if [ -r ${LIB}/$file ]; then
457 echo Fixing $file sprintf declaration
458 ex ${LIB}/$file <<EOF
459 /^extern char \* sprintf();$/c
461 extern char * sprintf();
462 #endif /* !defined __STDC__ */
466 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
467 echo Deleting ${LIB}/$file\; no fixes were needed.
472 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
473 # (It's not clear whether the right file name is this or X11/Xmu.h.)
475 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
476 mkdir ${LIB}/X11/Xmu 2>/dev/null
477 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
478 chmod +w ${LIB}/$file 2>/dev/null
481 if [ -r ${LIB}/$file ]; then
482 echo Fixing $file sprintf declaration
483 ex ${LIB}/$file <<EOF
484 /^extern char \* sprintf();$/c
486 extern char * sprintf();
487 #endif /* !defined __STDC__ */
491 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
492 echo Deleting ${LIB}/$file\; no fixes were needed.
497 # Check for missing ';' in struct
499 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
500 mkdir ${LIB}/netinet 2>/dev/null
501 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
502 chmod +w ${LIB}/$file 2>/dev/null
505 if [ -r ${LIB}/$file ]; then
507 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
508 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
509 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
510 echo Deleting ${LIB}/$file\; no fixes were needed.
515 # Fix the CAT macro in SunOS memvar.h.
516 file=pixrect/memvar.h
517 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
518 mkdir ${LIB}/pixrect 2>/dev/null
519 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
520 chmod +w ${LIB}/$file 2>/dev/null
523 if [ -r ${LIB}/$file ]; then
525 sed -e '/^#define.CAT(a,b)/ i\
527 #define CAT(a,b) a##b\
529 /^#define.CAT(a,b)/ a\
531 ' ${LIB}/$file > ${LIB}/${file}.sed
532 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
533 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
534 echo Deleting ${LIB}/$file\; no fixes were needed.
539 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
541 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
542 mkdir ${LIB}/rpcsvc 2>/dev/null
543 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
544 chmod +w ${LIB}/$file 2>/dev/null
547 if [ -r ${LIB}/$file ]; then
549 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
550 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
551 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
552 echo Deleting ${LIB}/$file\; no fixes were needed.
557 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
559 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
560 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
561 chmod +w ${LIB}/$file 2>/dev/null
564 if [ -r ${LIB}/$file ]; then
566 sed -e 's/int abort/void abort/g' \
567 -e 's/int free/void free/g' \
568 -e 's/char \* calloc/void \* calloc/g' \
569 -e 's/char \* malloc/void \* malloc/g' \
570 -e 's/char \* realloc/void \* realloc/g' \
571 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
572 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
573 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
574 echo Deleting ${LIB}/$file\; no fixes were needed.
579 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
581 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
582 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
583 chmod +w ${LIB}/$file 2>/dev/null
586 if [ -r ${LIB}/$file ]; then
588 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
589 -e 's/int[ ][ ]*free/void free/g' \
590 ${LIB}/$file > ${LIB}/${file}.sed
591 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
592 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
593 echo Deleting ${LIB}/$file\; no fixes were needed.
599 # Fix bogus comment in <locale.h> on SunOS 4.1.
601 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
602 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
603 chmod +w ${LIB}/$file 2>/dev/null
606 if [ -r ${LIB}/$file ]; then
608 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
609 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
610 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
611 echo Deleting ${LIB}/$file\; no fixes were needed.
616 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
617 file=hsfs/hsfs_spec.h
618 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
619 mkdir ${LIB}/hsfs 2>/dev/null
620 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
621 chmod +w ${LIB}/$file 2>/dev/null
624 if [ -r ${LIB}/$file ]; then
626 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
627 ${LIB}/$file > ${LIB}/${file}.sed
628 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
629 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
630 echo Deleting ${LIB}/$file\; no fixes were needed.
635 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
637 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
638 mkdir ${LIB}/hsfs 2>/dev/null
639 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
640 chmod +w ${LIB}/$file 2>/dev/null
643 if [ -r ${LIB}/$file ]; then
645 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
646 ${LIB}/$file > ${LIB}/${file}.sed
647 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
648 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
649 echo Deleting ${LIB}/$file\; no fixes were needed.
654 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
656 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
657 mkdir ${LIB}/hsfs 2>/dev/null
658 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
659 chmod +w ${LIB}/$file 2>/dev/null
662 if [ -r ${LIB}/$file ]; then
664 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
665 ${LIB}/$file > ${LIB}/${file}.sed
666 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
667 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
668 echo Deleting ${LIB}/$file\; no fixes were needed.
673 # Incorrect #include in Sony News-OS 3.2.
674 file=machine/machparam.h
675 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
676 mkdir ${LIB}/machine 2>/dev/null
677 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
678 chmod +w ${LIB}/$file 2>/dev/null
681 if [ -r ${LIB}/$file ]; then
682 echo Fixing $file, incorrect \#include
683 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
684 ${LIB}/$file > ${LIB}/${file}.sed
685 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
686 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
687 echo Deleting ${LIB}/$file\; no fixes were needed.
692 # Multiline comment after typedef on IRIX 4.0.1.
694 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
695 mkdir ${LIB}/sys 2>/dev/null
696 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
697 chmod +w ${LIB}/$file 2>/dev/null
700 if [ -r ${LIB}/$file ]; then
701 echo Fixing $file, comment in the middle of \#ifdef
702 sed -e 's@type of the result@type of the result */@' \
703 -e 's@of the sizeof@/* of the sizeof@' \
704 ${LIB}/$file > ${LIB}/${file}.sed
705 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
706 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
707 echo Deleting ${LIB}/$file\; no fixes were needed.
712 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
713 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
714 # many other systems have similar text but correct versions of the file.
715 # To ensure only Sun's is fixed, we grep for a likely unique string.
717 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
718 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
719 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
720 chmod +w ${LIB}/$file 2>/dev/null
722 if [ -r ${LIB}/$file ]; then
724 cat > ${LIB}/$file << EOF
725 /* This file was generated by fixincludes */
730 extern void *memccpy();
731 extern void *memchr();
732 extern void *memcpy();
733 extern void *memset();
735 extern char *memccpy();
736 extern char *memchr();
737 extern char *memcpy();
738 extern char *memset();
739 #endif /* __STDC__ */
748 # parameters not const on DECstation Ultrix V4.0.
750 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
751 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
752 chmod +w ${LIB}/$file 2>/dev/null
755 if [ -r ${LIB}/$file ]; then
756 echo Fixing $file, non-const arg
757 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
758 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
759 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
760 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
761 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
762 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
763 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
764 ${LIB}/$file > ${LIB}/${file}.sed
765 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
766 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
767 echo Deleting ${LIB}/$file\; no fixes were needed.
772 # Don't use or define the name va_list in stdio.h.
773 # This is for ANSI and also to interoperate properly with gvarargs.h.
775 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
776 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
777 chmod +w ${LIB}/$file 2>/dev/null
780 if [ -r ${LIB}/$file ]; then
781 echo Fixing $file, use of va_list
782 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
783 (echo "#define __need___va_list"
784 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
785 # Use __gnuc_va_list in arg types in place of va_list.
786 # Define __va_list__ (something harmless and unused) instead of va_list.
787 # Don't claim to have defined va_list.
788 sed -e 's@ va_list @ __gnuc_va_list @' \
789 -e 's@ va_list@ __va_list__@' \
790 -e 's@VA_LIST@DUMMY_VA_LIST@' \
791 ${LIB}/$file >> ${LIB}/${file}.sed
793 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
794 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
795 echo Deleting ${LIB}/$file\; no fixes were needed.
800 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
802 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
803 if grep -s ULTRIX $file; then
804 echo "/* This file intentionally left blank. */" > $LIB/$file
808 # parameter to atof not const on DECstation Ultrix V4.0.
810 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
811 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
812 chmod +w ${LIB}/$file 2>/dev/null
815 if [ -r ${LIB}/$file ]; then
816 echo Fixing $file, non-const arg
817 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
818 ${LIB}/$file > ${LIB}/${file}.sed
819 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
820 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
821 echo Deleting ${LIB}/$file\; no fixes were needed.
826 # These two files on SunOS 4 are included by other files
827 # in the same directory, using "...". So we must make sure they exist
828 # in the same directory as the other fixed files.
829 if [ -r ${INPUT}/multimedia/audio_errno.h ]
831 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
833 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
835 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
838 echo 'Removing unneeded directories:'
840 files=`find . -type d -print | sort -r`
841 for file in $files; do
842 rmdir $LIB/$file > /dev/null 2>&1
846 echo 'Making internal symbolic non-directory links'
848 files=`find . -type l -print`
849 for file in $files; do
850 dest=`ls -ld $file | sed -n 's/.*-> //p'`
851 if expr "$dest" : '[^/].*' > /dev/null; then
852 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
853 if [ -f $target ]; then
854 ln -s $dest ${LIB}/$file >/dev/null 2>&1