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.
69 # Find all directories under $d, relative to $d, including $d itself.
70 # Get rid of ./ at the end!
71 files="$files `find $d -type d -print | sed '/^.$/d' | sed '/\/\.$/ s|/\.$||'`"
73 newdirs="$newdirs `find $d -type l -exec test -d '{}' \; -print`"
84 for file in $files; do
86 if [ ! -d $LIB/$file ]
91 # treetops gets an alternating list
92 # of old directories to copy
93 # and the new directories to copy to.
94 treetops="${INPUT} ${LIB}"
97 echo 'Making internal symbolic directory links'
98 for file in $files; do
99 dest=`ls -ld $file | sed -n 's/.*-> //p'`
102 # In case $dest is relative, get to $file's dir first.
104 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
105 # Check that the target directory exists.
106 # Redirections changed to avoid bug in sh on Ultrix.
107 (cd $dest) > /dev/null 2>&1
110 # X gets the dir that the link actually leads to.
112 # If link leads back into ${INPUT},
113 # make a similar link here.
114 if expr $x : "${INPUT}/.*" > /dev/null; then
115 # Y gets the actual target dir name, relative to ${INPUT}.
116 y=`echo $x | sed -n "s&${INPUT}/&&p"`
117 echo $file '->' $y ': Making link'
118 rm -fr ${LIB}/$file > /dev/null 2>&1
119 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
121 # If the link is to outside ${INPUT},
122 # treat this directory as if it actually contained the files.
123 # This line used to have $dest instead of $x.
124 # $dest seemed to be wrong for links found in subdirectories
125 # of ${INPUT}. Does this change break anything?
126 treetops="$treetops $x ${LIB}/$file"
135 while [ $# != 0 ]; do
136 # $1 is an old directory to copy, and $2 is the new directory to copy to.
137 echo "Finding header files in $1:"
140 files=`find . -name '*.h' -type f -print`
141 echo 'Checking header files:'
142 # Note that BSD43_* are used on recent MIPS systems.
143 for file in $files; do
144 # This call to egrep is essential, since checking a file with egrep
145 # is much faster than actually trying to fix it.
146 # It is also essential that most files *not* match!
147 # Thus, matching every #endif is unacceptable.
148 # But the argument to egrep must be kept small, or many versions of egrep
149 # won't be able to handle it.
150 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
151 if egrep '[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
153 if [ -r $file ]; then
154 cp $file $2/$file >/dev/null 2>&1 \
155 || echo "Can't copy $file"
157 # Following two lines removed.
158 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
159 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
165 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
166 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
167 /#define._IO/ s/'\''x'\''/x/g
168 /#define.BSD43__IO/ s/'\''x'\''/x/g
169 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
170 /#define.CTRL/ s/'\''c'\''/c/g
171 /#define._CTRL/ s/'\''c'\''/c/g
172 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
173 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
174 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
175 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
176 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
177 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
178 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
179 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
180 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
181 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
182 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
183 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
184 /^#define.NULL[ ]/ i\
186 ' $2/$file > $2/$file.sed
187 mv $2/$file.sed $2/$file
188 if cmp $file $2/$file >/dev/null 2>&1; then
189 echo Deleting $2/$file\; no fixes were needed.
200 # Fix one other error in this file: a mismatched quote not inside a C comment.
201 file=sundev/vuid_event.h
202 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
203 mkdir ${LIB}/sundev 2>/dev/null
204 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
205 chmod +w ${LIB}/$file 2>/dev/null
208 if [ -r ${LIB}/$file ]; then
209 echo Fixing $file comment
210 ex ${LIB}/$file <<EOF
211 g/doesn't/s/doesn't/does not/
214 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
215 echo Deleting ${LIB}/$file\; no fixes were needed.
220 # Fix this Sun file to avoid interfering with stddef.h.
222 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
223 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
224 chmod +w ${LIB}/$file 2>/dev/null
227 if [ -r ${LIB}/$file ]; then
229 ex ${LIB}/$file <<EOF
241 #ifndef _GCC_PTRDIFF_T
242 #define _GCC_PTRDIFF_T
259 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
260 echo Deleting ${LIB}/$file\; no fixes were needed.
265 # Fix this file to avoid interfering with stddef.h.
267 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
268 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
269 chmod +w ${LIB}/$file 2>/dev/null
272 if [ -r ${LIB}/$file ]; then
274 ex ${LIB}/$file <<EOF
286 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
287 echo Deleting ${LIB}/$file\; no fixes were needed.
292 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
293 # structure definition.
295 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
296 mkdir ${LIB}/rpcsvc 2>/dev/null
297 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
298 chmod +w ${LIB}/$file 2>/dev/null
301 if [ -r ${LIB}/$file ]; then
302 echo Fixing $file, definition of statsswtch
303 ex ${LIB}/$file <<EOF
307 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
308 echo Deleting ${LIB}/$file\; no fixes were needed.
313 # Fix an error in this file: a missing semi-colon at the end of the nodeent
314 # structure definition.
315 file=netdnet/dnetdb.h
316 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
317 mkdir ${LIB}/netdnet 2>/dev/null
318 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
319 chmod +w ${LIB}/$file 2>/dev/null
322 if [ -r ${LIB}/$file ]; then
323 echo Fixing $file, definition of nodeent
324 ex ${LIB}/$file <<EOF
325 g/char.*na_addr *$/s//&;/
328 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
329 echo Deleting ${LIB}/$file\; no fixes were needed.
334 # Check for bad #ifdef line (in Ultrix 4.1)
336 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
337 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
338 chmod +w ${LIB}/$file 2>/dev/null
341 if [ -r ${LIB}/$file ]; then
342 echo Fixing $file, bad \#ifdef line
343 ex ${LIB}/$file <<EOF
344 g/^#ifdef KERNEL && !defined/
345 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
348 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
349 echo Deleting ${LIB}/$file\; no fixes were needed.
354 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
355 # Only needed if commenting out junk after #endif.
357 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
358 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
359 # chmod +w ${LIB}/$file 2>/dev/null
362 #if [ -r ${LIB}/$file ]; then
363 # echo Fixing $file, nested comments
364 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
365 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
366 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
367 # echo Deleting ${LIB}/$file\; no fixes were needed.
372 # Check for superfluous `static' (in Ultrix 4.2)
374 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
375 mkdir ${LIB}/machine 2>/dev/null
376 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
377 chmod +w ${LIB}/$file 2>/dev/null
380 if [ -r ${LIB}/$file ]; then
381 echo Fixing $file, superfluous static
382 ex ${LIB}/$file <<EOF
383 g/^static struct tlb_pid_state/
387 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
388 echo Deleting ${LIB}/$file\; no fixes were needed.
391 # This file has an alternative name, mips/cpu.h. Fix that name, too.
392 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
393 mkdir ${LIB}/mips 2>&-
394 ln ${LIB}/$file ${LIB}/mips/cpu.h
399 # Incorrect sprintf declaration in X11/Xmu.h
401 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
402 mkdir ${LIB}/X11 2>/dev/null
403 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
404 chmod +w ${LIB}/$file 2>/dev/null
407 if [ -r ${LIB}/$file ]; then
408 echo Fixing $file sprintf declaration
409 ex ${LIB}/$file <<EOF
410 /^extern char \* sprintf();$/c
412 extern char * sprintf();
413 #endif /* !defined __STDC__ */
417 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
418 echo Deleting ${LIB}/$file\; no fixes were needed.
423 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
424 # (It's not clear whether the right file name is this or X11/Xmu.h.)
426 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
427 mkdir ${LIB}/X11/Xmu 2>/dev/null
428 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
429 chmod +w ${LIB}/$file 2>/dev/null
432 if [ -r ${LIB}/$file ]; then
433 echo Fixing $file sprintf declaration
434 ex ${LIB}/$file <<EOF
435 /^extern char \* sprintf();$/c
437 extern char * sprintf();
438 #endif /* !defined __STDC__ */
442 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
443 echo Deleting ${LIB}/$file\; no fixes were needed.
448 # Check for missing ';' in struct
450 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
451 mkdir ${LIB}/netinet 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
458 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
459 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
460 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
461 echo Deleting ${LIB}/$file\; no fixes were needed.
466 # Fix the CAT macro in SunOS memvar.h.
467 file=pixrect/memvar.h
468 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
469 mkdir ${LIB}/pixrect 2>/dev/null
470 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
471 chmod +w ${LIB}/$file 2>/dev/null
474 if [ -r ${LIB}/$file ]; then
476 sed -e '/^#define.CAT(a,b)/ i\
478 #define CAT(a,b) a##b\
480 /^#define.CAT(a,b)/ a\
482 ' ${LIB}/$file > ${LIB}/${file}.sed
483 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
484 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
485 echo Deleting ${LIB}/$file\; no fixes were needed.
490 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
492 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
493 mkdir ${LIB}/rpcsvc 2>/dev/null
494 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
495 chmod +w ${LIB}/$file 2>/dev/null
498 if [ -r ${LIB}/$file ]; then
500 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
501 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
502 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
503 echo Deleting ${LIB}/$file\; no fixes were needed.
508 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
510 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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 's/int abort/void abort/g' \
518 -e 's/int free/void free/g' \
519 -e 's/char \* calloc/void \* calloc/g' \
520 -e 's/char \* malloc/void \* malloc/g' \
521 -e 's/char \* realloc/void \* realloc/g' \
522 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
523 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
524 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
525 echo Deleting ${LIB}/$file\; no fixes were needed.
530 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
532 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
533 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
534 chmod +w ${LIB}/$file 2>/dev/null
537 if [ -r ${LIB}/$file ]; then
539 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
540 -e 's/int[ ][ ]*free/void free/g' \
541 ${LIB}/$file > ${LIB}/${file}.sed
542 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
543 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
544 echo Deleting ${LIB}/$file\; no fixes were needed.
550 # Fix bogus comment in <locale.h> on SunOS 4.1.
552 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
553 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
554 chmod +w ${LIB}/$file 2>/dev/null
557 if [ -r ${LIB}/$file ]; then
559 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
560 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
561 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
562 echo Deleting ${LIB}/$file\; no fixes were needed.
567 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
568 file=hsfs/hsfs_spec.h
569 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
570 mkdir ${LIB}/hsfs 2>/dev/null
571 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
572 chmod +w ${LIB}/$file 2>/dev/null
575 if [ -r ${LIB}/$file ]; then
577 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
578 ${LIB}/$file > ${LIB}/${file}.sed
579 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
580 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
581 echo Deleting ${LIB}/$file\; no fixes were needed.
586 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
588 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
589 mkdir ${LIB}/hsfs 2>/dev/null
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/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
597 ${LIB}/$file > ${LIB}/${file}.sed
598 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
599 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
600 echo Deleting ${LIB}/$file\; no fixes were needed.
605 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
607 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
608 mkdir ${LIB}/hsfs 2>/dev/null
609 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
610 chmod +w ${LIB}/$file 2>/dev/null
613 if [ -r ${LIB}/$file ]; then
615 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
616 ${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 # Incorrect #include in Sony News-OS 3.2.
625 file=machine/machparam.h
626 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
627 mkdir ${LIB}/machine 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
633 echo Fixing $file, incorrect \#include
634 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
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 # Multiline comment after typedef on IRIX 4.0.1.
645 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
646 mkdir ${LIB}/sys 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
652 echo Fixing $file, comment in the middle of \#ifdef
653 sed -e 's@type of the result@type of the result */@' \
654 -e 's@of the sizeof@/* of the sizeof@' \
655 ${LIB}/$file > ${LIB}/${file}.sed
656 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
657 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
658 echo Deleting ${LIB}/$file\; no fixes were needed.
663 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
664 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
665 # many other systems have similar text but correct versions of the file.
666 # To ensure only Sun's is fixed, we grep for a likely unique string.
668 if egrep '/\* @\(#\)memory.h 1.4 88/08/19 SMI; from S5R2 1.2 \*/' $file > /dev/null; then
669 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
670 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
671 chmod +w ${LIB}/$file 2>/dev/null
673 if [ -r ${LIB}/$file ]; then
675 cat > ${LIB}/$file << EOF
676 /* This file was generated by fixincludes */
681 extern void *memccpy();
682 extern void *memchr();
683 extern void *memcpy();
684 extern void *memset();
686 extern char *memccpy();
687 extern char *memchr();
688 extern char *memcpy();
689 extern char *memset();
690 #endif /* __STDC__ */
699 # parameters not const on DECstation Ultrix V4.0.
701 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
702 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
703 chmod +w ${LIB}/$file 2>/dev/null
706 if [ -r ${LIB}/$file ]; then
707 echo Fixing $file, non-const arg
708 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
709 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
710 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
711 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
712 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
713 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
714 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
715 ${LIB}/$file > ${LIB}/${file}.sed
716 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
717 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
718 echo Deleting ${LIB}/$file\; no fixes were needed.
723 # parameter to atof not const on DECstation Ultrix V4.0.
725 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
726 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
727 chmod +w ${LIB}/$file 2>/dev/null
730 if [ -r ${LIB}/$file ]; then
731 echo Fixing $file, non-const arg
732 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
733 ${LIB}/$file > ${LIB}/${file}.sed
734 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
735 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
736 echo Deleting ${LIB}/$file\; no fixes were needed.
741 # These two files on SunOS 4 are included by other files
742 # in the same directory, using "...". So we must make sure they exist
743 # in the same directory as the other fixed files.
744 if [ -r ${INPUT}/multimedia/audio_errno.h ]
746 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
748 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
750 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
753 echo 'Removing unneeded directories:'
755 files=`find . -type d -print | sort -r`
756 for file in $files; do
757 rmdir $LIB/$file > /dev/null 2>&1
761 echo 'Making internal symbolic non-directory links'
763 files=`find . -type l -print`
764 for file in $files; do
765 dest=`ls -ld $file | sed -n 's/.*-> //p'`
766 if expr "$dest" : '[^/].*' > /dev/null; then
767 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
768 if [ -f $target ]; then
769 ln -s $dest ${LIB}/$file >/dev/null 2>&1