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 fixincludes 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 'Making 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`
70 # Find all directories under $d, relative to $d, excluding $d itself.
71 files="$files `find $d -type d -print | \
72 sed -e '/\/\.$/d' -e '/^\.$/d'`"
73 # Find all links to directories.
74 # Using `-exec test -d' in find fails on some systems,
75 # and trying to run test via sh fails on others,
76 # so this is the simplest alternative left.
77 # First find all the links, then test each one.
80 theselinks=`find $d -type l -print`
81 for d1 in $theselinks --dummy--
83 # If it is a directory, add it to $newdirs
86 newdirs="$newdirs $d1"
91 files="$files $newdirs"
99 for file in $files; do
101 if [ ! -d $LIB/$file ]
102 then mkdir $LIB/$file
106 # treetops gets an alternating list
107 # of old directories to copy
108 # and the new directories to copy to.
109 treetops="${INPUT} ${LIB}"
112 echo 'Making internal symbolic directory links'
113 for file in $files; do
114 dest=`ls -ld $file | sed -n 's/.*-> //p'`
117 # In case $dest is relative, get to $file's dir first.
119 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
120 # Check that the target directory exists.
121 # Redirections changed to avoid bug in sh on Ultrix.
122 (cd $dest) > /dev/null 2>&1
125 # X gets the dir that the link actually leads to.
127 # If link leads back into ${INPUT},
128 # make a similar link here.
129 if expr $x : "${INPUT}/.*" > /dev/null; then
130 # Y gets the actual target dir name, relative to ${INPUT}.
131 y=`echo $x | sed -n "s&${INPUT}/&&p"`
132 echo $file '->' $y ': Making link'
133 rm -fr ${LIB}/$file > /dev/null 2>&1
134 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
136 # If the link is to outside ${INPUT},
137 # treat this directory as if it actually contained the files.
138 # This line used to have $dest instead of $x.
139 # $dest seemed to be wrong for links found in subdirectories
140 # of ${INPUT}. Does this change break anything?
141 treetops="$treetops $x ${LIB}/$file"
150 while [ $# != 0 ]; do
151 # $1 is an old directory to copy, and $2 is the new directory to copy to.
152 echo "Finding header files in $1:"
155 # Check .h files which are symlinks as well as those which are files.
156 # A link to a header file will not be processed by anything but this.
157 files=`find . -name '*.h' \( -type f -o -type l \) -print`
158 echo 'Checking header files:'
159 # Note that BSD43_* are used on recent MIPS systems.
160 for file in $files; do
161 # This call to egrep is essential, since checking a file with egrep
162 # is much faster than actually trying to fix it.
163 # It is also essential that most files *not* match!
164 # Thus, matching every #endif is unacceptable.
165 # But the argument to egrep must be kept small, or many versions of egrep
166 # won't be able to handle it.
167 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
168 if egrep '[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
170 if [ -r $file ]; then
171 cp $file $2/$file >/dev/null 2>&1 \
172 || echo "Can't copy $file"
174 # Following two lines removed.
175 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
176 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
182 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
183 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
184 /#define._IO/ s/'\''x'\''/x/g
185 /#define.BSD43__IO/ s/'\''x'\''/x/g
186 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
187 /#define.CTRL/ s/'\''c'\''/c/g
188 /#define._CTRL/ s/'\''c'\''/c/g
189 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
190 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
191 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
192 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
193 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
194 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
195 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
196 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
197 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
198 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
199 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
200 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
201 /^#define.NULL[ ]/ i\
203 ' $2/$file > $2/$file.sed
204 mv $2/$file.sed $2/$file
205 if cmp $file $2/$file >/dev/null 2>&1; then
206 echo Deleting $2/$file\; no fixes were needed.
217 # Fix one other error in this file: a mismatched quote not inside a C comment.
218 file=sundev/vuid_event.h
219 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
220 mkdir ${LIB}/sundev 2>/dev/null
221 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
222 chmod +w ${LIB}/$file 2>/dev/null
225 if [ -r ${LIB}/$file ]; then
226 echo Fixing $file comment
227 ex ${LIB}/$file <<EOF
228 g/doesn't/s/doesn't/does not/
231 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
232 echo Deleting ${LIB}/$file\; no fixes were needed.
237 # Fix this Sun file to avoid interfering with stddef.h.
239 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
240 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
241 chmod +w ${LIB}/$file 2>/dev/null
244 if [ -r ${LIB}/$file ]; then
246 ex ${LIB}/$file <<EOF
258 #ifndef _GCC_PTRDIFF_T
259 #define _GCC_PTRDIFF_T
276 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
277 echo Deleting ${LIB}/$file\; no fixes were needed.
282 # Fix this file to avoid interfering with stddef.h.
284 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
285 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
286 chmod +w ${LIB}/$file 2>/dev/null
289 if [ -r ${LIB}/$file ]; then
291 ex ${LIB}/$file <<EOF
303 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
304 echo Deleting ${LIB}/$file\; no fixes were needed.
309 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
310 # structure definition.
312 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
313 mkdir ${LIB}/rpcsvc 2>/dev/null
314 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
315 chmod +w ${LIB}/$file 2>/dev/null
318 if [ -r ${LIB}/$file ]; then
319 echo Fixing $file, definition of statsswtch
320 ex ${LIB}/$file <<EOF
324 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
325 echo Deleting ${LIB}/$file\; no fixes were needed.
330 # Fix an error in this file: a missing semi-colon at the end of the nodeent
331 # structure definition.
332 file=netdnet/dnetdb.h
333 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
334 mkdir ${LIB}/netdnet 2>/dev/null
335 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
336 chmod +w ${LIB}/$file 2>/dev/null
339 if [ -r ${LIB}/$file ]; then
340 echo Fixing $file, definition of nodeent
341 ex ${LIB}/$file <<EOF
342 g/char.*na_addr *$/s//&;/
345 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
346 echo Deleting ${LIB}/$file\; no fixes were needed.
351 # Check for bad #ifdef line (in Ultrix 4.1)
353 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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, bad \#ifdef line
360 ex ${LIB}/$file <<EOF
361 g/^#ifdef KERNEL && !defined/
362 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
365 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
366 echo Deleting ${LIB}/$file\; no fixes were needed.
371 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
372 # Only needed if commenting out junk after #endif.
374 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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, nested comments
381 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
382 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
383 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
384 # echo Deleting ${LIB}/$file\; no fixes were needed.
389 # Check for superfluous `static' (in Ultrix 4.2)
391 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
392 mkdir ${LIB}/machine 2>/dev/null
393 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
394 chmod +w ${LIB}/$file 2>/dev/null
397 if [ -r ${LIB}/$file ]; then
398 echo Fixing $file, superfluous static
399 ex ${LIB}/$file <<EOF
400 g/^static struct tlb_pid_state/
404 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
405 echo Deleting ${LIB}/$file\; no fixes were needed.
408 # This file has an alternative name, mips/cpu.h. Fix that name, too.
409 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
410 mkdir ${LIB}/mips 2>&-
411 ln ${LIB}/$file ${LIB}/mips/cpu.h
416 # Incorrect sprintf declaration in X11/Xmu.h
418 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
419 mkdir ${LIB}/X11 2>/dev/null
420 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
421 chmod +w ${LIB}/$file 2>/dev/null
424 if [ -r ${LIB}/$file ]; then
425 echo Fixing $file sprintf declaration
426 ex ${LIB}/$file <<EOF
427 /^extern char \* sprintf();$/c
429 extern char * sprintf();
430 #endif /* !defined __STDC__ */
434 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
435 echo Deleting ${LIB}/$file\; no fixes were needed.
440 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
441 # (It's not clear whether the right file name is this or X11/Xmu.h.)
443 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
444 mkdir ${LIB}/X11/Xmu 2>/dev/null
445 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
446 chmod +w ${LIB}/$file 2>/dev/null
449 if [ -r ${LIB}/$file ]; then
450 echo Fixing $file sprintf declaration
451 ex ${LIB}/$file <<EOF
452 /^extern char \* sprintf();$/c
454 extern char * sprintf();
455 #endif /* !defined __STDC__ */
459 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
460 echo Deleting ${LIB}/$file\; no fixes were needed.
465 # Check for missing ';' in struct
467 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
468 mkdir ${LIB}/netinet 2>/dev/null
469 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
470 chmod +w ${LIB}/$file 2>/dev/null
473 if [ -r ${LIB}/$file ]; then
475 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
476 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
477 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
478 echo Deleting ${LIB}/$file\; no fixes were needed.
483 # Fix the CAT macro in SunOS memvar.h.
484 file=pixrect/memvar.h
485 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
486 mkdir ${LIB}/pixrect 2>/dev/null
487 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
488 chmod +w ${LIB}/$file 2>/dev/null
491 if [ -r ${LIB}/$file ]; then
493 sed -e '/^#define.CAT(a,b)/ i\
495 #define CAT(a,b) a##b\
497 /^#define.CAT(a,b)/ a\
499 ' ${LIB}/$file > ${LIB}/${file}.sed
500 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
501 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
502 echo Deleting ${LIB}/$file\; no fixes were needed.
507 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
509 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
510 mkdir ${LIB}/rpcsvc 2>/dev/null
511 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
512 chmod +w ${LIB}/$file 2>/dev/null
515 if [ -r ${LIB}/$file ]; then
517 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
518 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
519 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
520 echo Deleting ${LIB}/$file\; no fixes were needed.
525 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
527 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
528 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
529 chmod +w ${LIB}/$file 2>/dev/null
532 if [ -r ${LIB}/$file ]; then
534 sed -e 's/int abort/void abort/g' \
535 -e 's/int free/void free/g' \
536 -e 's/char \* calloc/void \* calloc/g' \
537 -e 's/char \* malloc/void \* malloc/g' \
538 -e 's/char \* realloc/void \* realloc/g' \
539 -e 's/int exit/void exit/g' ${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 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
549 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
550 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
551 chmod +w ${LIB}/$file 2>/dev/null
554 if [ -r ${LIB}/$file ]; then
556 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
557 -e 's/int[ ][ ]*free/void free/g' \
558 ${LIB}/$file > ${LIB}/${file}.sed
559 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
560 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
561 echo Deleting ${LIB}/$file\; no fixes were needed.
567 # Fix bogus comment in <locale.h> on SunOS 4.1.
569 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
570 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
571 chmod +w ${LIB}/$file 2>/dev/null
574 if [ -r ${LIB}/$file ]; then
576 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
577 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
578 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
579 echo Deleting ${LIB}/$file\; no fixes were needed.
584 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
585 file=hsfs/hsfs_spec.h
586 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
587 mkdir ${LIB}/hsfs 2>/dev/null
588 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
589 chmod +w ${LIB}/$file 2>/dev/null
592 if [ -r ${LIB}/$file ]; then
594 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
595 ${LIB}/$file > ${LIB}/${file}.sed
596 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
597 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
598 echo Deleting ${LIB}/$file\; no fixes were needed.
603 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
605 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
606 mkdir ${LIB}/hsfs 2>/dev/null
607 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
608 chmod +w ${LIB}/$file 2>/dev/null
611 if [ -r ${LIB}/$file ]; then
613 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
614 ${LIB}/$file > ${LIB}/${file}.sed
615 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
616 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
617 echo Deleting ${LIB}/$file\; no fixes were needed.
622 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
624 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
625 mkdir ${LIB}/hsfs 2>/dev/null
626 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
627 chmod +w ${LIB}/$file 2>/dev/null
630 if [ -r ${LIB}/$file ]; then
632 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
633 ${LIB}/$file > ${LIB}/${file}.sed
634 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
635 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
636 echo Deleting ${LIB}/$file\; no fixes were needed.
641 # Incorrect #include in Sony News-OS 3.2.
642 file=machine/machparam.h
643 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
644 mkdir ${LIB}/machine 2>/dev/null
645 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
646 chmod +w ${LIB}/$file 2>/dev/null
649 if [ -r ${LIB}/$file ]; then
650 echo Fixing $file, incorrect \#include
651 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
652 ${LIB}/$file > ${LIB}/${file}.sed
653 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
654 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
655 echo Deleting ${LIB}/$file\; no fixes were needed.
660 # Multiline comment after typedef on IRIX 4.0.1.
662 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
663 mkdir ${LIB}/sys 2>/dev/null
664 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
665 chmod +w ${LIB}/$file 2>/dev/null
668 if [ -r ${LIB}/$file ]; then
669 echo Fixing $file, comment in the middle of \#ifdef
670 sed -e 's@type of the result@type of the result */@' \
671 -e 's@of the sizeof@/* of the sizeof@' \
672 ${LIB}/$file > ${LIB}/${file}.sed
673 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
674 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
675 echo Deleting ${LIB}/$file\; no fixes were needed.
680 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
681 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
682 # many other systems have similar text but correct versions of the file.
683 # To ensure only Sun's is fixed, we grep for a likely unique string.
685 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
686 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
687 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
688 chmod +w ${LIB}/$file 2>/dev/null
690 if [ -r ${LIB}/$file ]; then
692 cat > ${LIB}/$file << EOF
693 /* This file was generated by fixincludes */
698 extern void *memccpy();
699 extern void *memchr();
700 extern void *memcpy();
701 extern void *memset();
703 extern char *memccpy();
704 extern char *memchr();
705 extern char *memcpy();
706 extern char *memset();
707 #endif /* __STDC__ */
716 # parameters not const on DECstation Ultrix V4.0.
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
723 if [ -r ${LIB}/$file ]; then
724 echo Fixing $file, non-const arg
725 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
726 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
727 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
728 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
729 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
730 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
731 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
732 ${LIB}/$file > ${LIB}/${file}.sed
733 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
734 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
735 echo Deleting ${LIB}/$file\; no fixes were needed.
740 # parameter to atof not const on DECstation Ultrix V4.0.
742 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
743 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
744 chmod +w ${LIB}/$file 2>/dev/null
747 if [ -r ${LIB}/$file ]; then
748 echo Fixing $file, non-const arg
749 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
750 ${LIB}/$file > ${LIB}/${file}.sed
751 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
752 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
753 echo Deleting ${LIB}/$file\; no fixes were needed.
758 # These two files on SunOS 4 are included by other files
759 # in the same directory, using "...". So we must make sure they exist
760 # in the same directory as the other fixed files.
761 if [ -r ${INPUT}/multimedia/audio_errno.h ]
763 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
765 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
767 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
770 echo 'Removing unneeded directories:'
772 files=`find . -type d -print | sort -r`
773 for file in $files; do
774 rmdir $LIB/$file > /dev/null 2>&1
778 echo 'Making internal symbolic non-directory links'
780 files=`find . -type l -print`
781 for file in $files; do
782 dest=`ls -ld $file | sed -n 's/.*-> //p'`
783 if expr "$dest" : '[^/].*' > /dev/null; then
784 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
785 if [ -f $target ]; then
786 ln -s $dest ${LIB}/$file >/dev/null 2>&1