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 # Directory in which to store the results.
18 LIB=${1?"fixincludes: output directory not specified"}
20 # Define PWDCMD as a command to use to get the working dir
21 # in the form that we want.
25 # On an Apollo, discard everything before `/usr'.
26 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
30 # Make sure it exists.
31 if [ ! -d $LIB ]; then
36 cd $LIB; LIB=`${PWDCMD}`
38 # Fail if no arg to specify a directory for the output.
40 then echo fixincludes: no output directory specified
44 echo Building fixed headers in ${LIB}
46 # Determine whether this system has symbolic links.
47 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
48 rm -f $LIB/ShouldNotExist
54 echo Finding directories and links to directories
56 # Find all directories and all symlinks that point to directories.
57 # Put the list in $files.
58 # Each time we find a symlink, add it to newdirs
59 # so that we do another find within the dir the link points to.
60 # Note that $files may have duplicates in it;
61 # later parts of this file are supposed to ignore them.
64 while [ -n "$dirs" ] && [ $levels -gt 0 ]
66 levels=`expr $levels - 1`
70 echo " Searching $INPUT/$d"
76 # Find all directories under $d, relative to $d, excluding $d itself.
77 files="$files `find $d -type d -print | \
78 sed -e '/\/\.$/d' -e '/^\.$/d'`"
79 # Find all links to directories.
80 # Using `-exec test -d' in find fails on some systems,
81 # and trying to run test via sh fails on others,
82 # so this is the simplest alternative left.
83 # First find all the links, then test each one.
86 theselinks=`find $d -type l -print`
87 for d1 in $theselinks --dummy--
89 # If the link points to a directory,
90 # add that dir to $newdirs
93 newdirs="$newdirs $d1"
98 files="$files $newdirs"
103 echo "All directories (including links to directories):"
106 for file in $files; do
108 if [ ! -d $LIB/$file ]
109 then mkdir $LIB/$file
114 # treetops gets an alternating list
115 # of old directories to copy
116 # and the new directories to copy to.
117 treetops="${INPUT} ${LIB}"
120 echo 'Making symbolic directory links'
121 for file in $files; do
122 dest=`ls -ld $file | sed -n 's/.*-> //p'`
125 # In case $dest is relative, get to $file's dir first.
127 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
128 # Check that the target directory exists.
129 # Redirections changed to avoid bug in sh on Ultrix.
130 (cd $dest) > /dev/null 2>&1
133 # X gets the dir that the link actually leads to.
135 # If a link points to ., make a similar link to .
136 if [ $x = $INPUT ]; then
137 echo $file '->' . ': Making link'
138 rm -fr ${LIB}/$file > /dev/null 2>&1
139 ln -s . ${LIB}/$file > /dev/null 2>&1
140 # If link leads back into ${INPUT},
141 # make a similar link here.
142 elif expr $x : "${INPUT}/.*" > /dev/null; then
143 # Y gets the actual target dir name, relative to ${INPUT}.
144 y=`echo $x | sed -n "s&${INPUT}/&&p"`
145 echo $file '->' $y ': Making link'
146 rm -fr ${LIB}/$file > /dev/null 2>&1
147 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
149 # If the link is to a dir $target outside ${INPUT},
150 # repoint the link at ${INPUT}/root$target
151 # and process $target into ${INPUT}/root$target
152 # treat this directory as if it actually contained the files.
153 echo $file '->' root$x ': Making link'
154 if [ -d $LIB/root$x ]
160 while [ x$dirname != x ]; do
161 component=`echo $dirname | sed -e 's|/.*$||'`
162 mkdir $component >/dev/null 2>&1
164 dirmade=$dirmade/$component
165 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
168 # Duplicate directory structure created in ${LIB}/$file in new
170 for file2 in $files; do
175 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
176 echo "Duplicating ${file}'s ${dupdir}"
185 rm -fr ${LIB}/$file > /dev/null 2>&1
186 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
187 treetops="$treetops $x ${LIB}/root$x"
196 while [ $# != 0 ]; do
197 # $1 is an old directory to copy, and $2 is the new directory to copy to.
200 # The same dir can appear more than once in treetops.
201 # There's no need to scan it more than once.
207 echo Fixing directory $1 into $2
208 # Check .h files which are symlinks as well as those which are files.
209 # A link to a header file will not be processed by anything but this.
211 files=`find . -name '*.h' \( -type f -o -type l \) -print`
213 files=`find . -name '*.h' -type f -print`
215 echo Checking header files
217 # Note that BSD43_* are used on recent MIPS systems.
218 for file in $files; do
219 # This call to egrep is essential, since checking a file with egrep
220 # is much faster than actually trying to fix it.
221 # It is also essential that most files *not* match!
222 # Thus, matching every #endif is unacceptable.
223 # But the argument to egrep must be kept small, or many versions of egrep
224 # won't be able to handle it.
225 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
226 if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
228 if [ -r $file ]; then
229 cp $file $2/$file >/dev/null 2>&1 \
230 || echo "Can't copy $file"
233 # Following two lines removed.
234 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
235 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
241 /\/\// s|//\(.*\)$|/*\1*/|
242 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
243 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
244 /#define._IO/ s/'\''x'\''/x/g
245 /#define.BSD43__IO/ s/'\''x'\''/x/g
246 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
247 /#define.CTRL/ s/'\''c'\''/c/g
248 /#define._CTRL/ s/'\''c'\''/c/g
249 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
250 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
251 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
252 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
253 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
254 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
255 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
256 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
257 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
258 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
259 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
260 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
261 /^#define.NULL[ ]/ i\
263 ' $2/$file > $2/$file.sed
264 mv $2/$file.sed $2/$file
265 if cmp $file $2/$file >/dev/null 2>&1; then
276 # Fix one other error in this file: a mismatched quote not inside a C comment.
277 file=sundev/vuid_event.h
278 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
279 mkdir ${LIB}/sundev 2>/dev/null
280 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
281 chmod +w ${LIB}/$file 2>/dev/null
282 chmod a+r ${LIB}/$file 2>/dev/null
285 if [ -r ${LIB}/$file ]; then
286 echo Fixing $file comment
287 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
288 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
289 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
294 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
295 file=sunwindow/win_cursor.h
296 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
297 # mkdir ${LIB}/sunwindow 2>/dev/null
298 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
299 chmod +w ${LIB}/$file 2>/dev/null
301 if [ -r ${LIB}/$file ]; then
303 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
304 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
305 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
309 file=sunwindow/win_lock.h
310 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
311 # mkdir ${LIB}/sunwindow 2>/dev/null
312 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
313 chmod +w ${LIB}/$file 2>/dev/null
315 if [ -r ${LIB}/$file ]; then
317 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
318 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
319 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
324 # Fix this Sun file to avoid interfering with stddef.h.
326 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
327 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
328 chmod +w ${LIB}/$file 2>/dev/null
329 chmod a+r ${LIB}/$file 2>/dev/null
332 if [ -r ${LIB}/$file ]; then
334 sed -e '/size_t.*;/i\
336 #define _GCC_SIZE_T' \
340 #ifndef _GCC_PTRDIFF_T\
341 #define _GCC_PTRDIFF_T' \
345 #ifndef _GCC_WCHAR_T\
346 #define _GCC_WCHAR_T' \
348 #endif' ${LIB}/$file > ${LIB}/${file}.sed
349 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
350 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
355 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
356 # match e.g. ssize_t present in AIX for the ps/2.
358 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
359 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
360 chmod +w ${LIB}/$file 2>/dev/null
361 chmod a+r ${LIB}/$file 2>/dev/null
364 if [ -r ${LIB}/$file ]; then
366 sed -e '/size_t.*;/i\
368 #define _GCC_SIZE_T' \
370 #endif' ${LIB}/$file > ${LIB}/${file}.sed
371 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
372 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
377 # Fix an error in this file: the #if says _cplusplus, not the double
378 # underscore __cplusplus that it should be
380 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
381 mkdir ${LIB}/rpcsvc 2>/dev/null
382 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
383 chmod +w ${LIB}/$file 2>/dev/null
384 chmod a+r ${LIB}/$file 2>/dev/null
387 if [ -r ${LIB}/$file ]; then
388 echo Fixing $file, __cplusplus macro
389 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
390 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
391 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
396 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
397 # structure definition.
399 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
400 mkdir ${LIB}/rpcsvc 2>/dev/null
401 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
402 chmod +w ${LIB}/$file 2>/dev/null
403 chmod a+r ${LIB}/$file 2>/dev/null
406 if [ -r ${LIB}/$file ]; then
407 echo Fixing $file, definition of statsswtch
408 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
409 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
410 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
415 # Fix an error in this file: a missing semi-colon at the end of the nodeent
416 # structure definition.
417 file=netdnet/dnetdb.h
418 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
419 mkdir ${LIB}/netdnet 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
422 chmod a+r ${LIB}/$file 2>/dev/null
425 if [ -r ${LIB}/$file ]; then
426 echo Fixing $file, definition of nodeent
427 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
428 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
429 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
434 # Check for bad #ifdef line (in Ultrix 4.1)
436 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
437 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
438 chmod +w ${LIB}/$file 2>/dev/null
439 chmod a+r ${LIB}/$file 2>/dev/null
442 if [ -r ${LIB}/$file ]; then
443 echo Fixing $file, bad \#ifdef line
444 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
445 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
446 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
451 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
452 # Only needed if commenting out junk after #endif.
454 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
455 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
456 # chmod +w ${LIB}/$file 2>/dev/null
457 # chmod a+r ${LIB}/$file 2>/dev/null
460 #if [ -r ${LIB}/$file ]; then
461 # echo Fixing $file, nested comments
462 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
463 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
464 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
469 # Check for superfluous `static' (in Ultrix 4.2)
471 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
472 mkdir ${LIB}/machine 2>/dev/null
473 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
474 chmod +w ${LIB}/$file 2>/dev/null
475 chmod a+r ${LIB}/$file 2>/dev/null
478 if [ -r ${LIB}/$file ]; then
479 echo Fixing $file, superfluous static
480 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
481 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
482 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
485 # This file has an alternative name, mips/cpu.h. Fix that name, too.
486 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
487 mkdir ${LIB}/mips 2>&-
488 ln ${LIB}/$file ${LIB}/mips/cpu.h
493 # Incorrect sprintf declaration in X11/Xmu.h
495 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
496 mkdir ${LIB}/X11 2>/dev/null
497 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
498 chmod +w ${LIB}/$file 2>/dev/null
499 chmod a+r ${LIB}/$file 2>/dev/null
502 if [ -r ${LIB}/$file ]; then
503 echo Fixing $file sprintf declaration
504 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
505 extern char * sprintf();\
506 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
507 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
508 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
513 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
514 # (It's not clear whether the right file name is this or X11/Xmu.h.)
516 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
517 mkdir ${LIB}/X11/Xmu 2>/dev/null
518 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
519 chmod +w ${LIB}/$file 2>/dev/null
520 chmod a+r ${LIB}/$file 2>/dev/null
523 if [ -r ${LIB}/$file ]; then
524 echo Fixing $file sprintf declaration
525 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
526 extern char * sprintf();\
527 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
528 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
529 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
534 # Check for missing ';' in struct
536 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
537 mkdir ${LIB}/netinet 2>/dev/null
538 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
539 chmod +w ${LIB}/$file 2>/dev/null
540 chmod a+r ${LIB}/$file 2>/dev/null
543 if [ -r ${LIB}/$file ]; then
545 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
546 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
547 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
552 # Fix the CAT macro in SunOS memvar.h.
553 file=pixrect/memvar.h
554 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
555 mkdir ${LIB}/pixrect 2>/dev/null
556 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
557 chmod +w ${LIB}/$file 2>/dev/null
558 chmod a+r ${LIB}/$file 2>/dev/null
561 if [ -r ${LIB}/$file ]; then
563 sed -e '/^#define.CAT(a,b)/ i\
565 #define CAT(a,b) a##b\
567 /^#define.CAT(a,b)/ a\
569 ' ${LIB}/$file > ${LIB}/${file}.sed
570 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
571 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
576 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
578 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
579 mkdir ${LIB}/rpcsvc 2>/dev/null
580 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
581 chmod +w ${LIB}/$file 2>/dev/null
582 chmod a+r ${LIB}/$file 2>/dev/null
585 if [ -r ${LIB}/$file ]; then
587 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
588 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
589 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
594 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
596 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
597 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
598 chmod +w ${LIB}/$file 2>/dev/null
599 chmod a+r ${LIB}/$file 2>/dev/null
602 if [ -r ${LIB}/$file ]; then
604 sed -e 's/int abort/void abort/g' \
605 -e 's/int free/void free/g' \
606 -e 's/char \* calloc/void \* calloc/g' \
607 -e 's/char \* malloc/void \* malloc/g' \
608 -e 's/char \* realloc/void \* realloc/g' \
609 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
610 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
611 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
616 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
618 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
619 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
620 chmod +w ${LIB}/$file 2>/dev/null
621 chmod a+r ${LIB}/$file 2>/dev/null
624 if [ -r ${LIB}/$file ]; then
626 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
627 -e 's/int[ ][ ]*free/void free/g' \
628 ${LIB}/$file > ${LIB}/${file}.sed
629 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
630 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
636 # Fix bogus comment in <locale.h> on SunOS 4.1.
638 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
639 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
640 chmod +w ${LIB}/$file 2>/dev/null
641 chmod a+r ${LIB}/$file 2>/dev/null
644 if [ -r ${LIB}/$file ]; then
646 sed -e 's%#endif / \*%#endif /\* %g' ${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
653 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
654 file=hsfs/hsfs_spec.h
655 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
656 mkdir ${LIB}/hsfs 2>/dev/null
657 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
658 chmod +w ${LIB}/$file 2>/dev/null
659 chmod a+r ${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
672 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
674 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
675 mkdir ${LIB}/hsfs 2>/dev/null
676 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
677 chmod +w ${LIB}/$file 2>/dev/null
678 chmod a+r ${LIB}/$file 2>/dev/null
681 if [ -r ${LIB}/$file ]; then
683 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
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
691 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
693 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
694 mkdir ${LIB}/hsfs 2>/dev/null
695 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
696 chmod +w ${LIB}/$file 2>/dev/null
697 chmod a+r ${LIB}/$file 2>/dev/null
700 if [ -r ${LIB}/$file ]; then
702 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
703 ${LIB}/$file > ${LIB}/${file}.sed
704 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
705 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
710 # Incorrect #include in Sony News-OS 3.2.
711 file=machine/machparam.h
712 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
713 mkdir ${LIB}/machine 2>/dev/null
714 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
715 chmod +w ${LIB}/$file 2>/dev/null
716 chmod a+r ${LIB}/$file 2>/dev/null
719 if [ -r ${LIB}/$file ]; then
720 echo Fixing $file, incorrect \#include
721 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
722 ${LIB}/$file > ${LIB}/${file}.sed
723 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
724 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
729 # Multiline comment after typedef on IRIX 4.0.1.
731 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
732 mkdir ${LIB}/sys 2>/dev/null
733 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
734 chmod +w ${LIB}/$file 2>/dev/null
735 chmod a+r ${LIB}/$file 2>/dev/null
738 if [ -r ${LIB}/$file ]; then
739 echo Fixing $file, comment in the middle of \#ifdef
740 sed -e 's@type of the result@type of the result */@' \
741 -e 's@of the sizeof@/* of the sizeof@' \
742 ${LIB}/$file > ${LIB}/${file}.sed
743 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
744 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
749 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
750 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
751 # many other systems have similar text but correct versions of the file.
752 # To ensure only Sun's is fixed, we grep for a likely unique string.
754 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
755 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
756 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
757 chmod +w ${LIB}/$file 2>/dev/null
758 chmod a+r ${LIB}/$file 2>/dev/null
760 if [ -r ${LIB}/$file ]; then
762 cat > ${LIB}/$file << EOF
763 /* This file was generated by fixincludes */
768 extern void *memccpy();
769 extern void *memchr();
770 extern void *memcpy();
771 extern void *memset();
773 extern char *memccpy();
774 extern char *memchr();
775 extern char *memcpy();
776 extern char *memset();
777 #endif /* __STDC__ */
786 # parameters not const on DECstation Ultrix V4.0.
788 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
789 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
790 chmod +w ${LIB}/$file 2>/dev/null
791 chmod a+r ${LIB}/$file 2>/dev/null
794 if [ -r ${LIB}/$file ]; then
795 echo Fixing $file, non-const arg
796 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
797 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
798 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
799 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
800 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
801 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
802 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
803 ${LIB}/$file > ${LIB}/${file}.sed
804 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
805 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
810 # Don't use or define the name va_list in stdio.h.
811 # This is for ANSI and also to interoperate properly with gvarargs.h.
813 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
814 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
815 chmod +w ${LIB}/$file 2>/dev/null
816 chmod a+r ${LIB}/$file 2>/dev/null
819 if [ -r ${LIB}/$file ]; then
820 echo Fixing $file, use of va_list
821 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
822 (echo "#define __need___va_list"
823 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
824 # Use __gnuc_va_list in arg types in place of va_list.
825 # Define __va_list__ (something harmless and unused) instead of va_list.
826 # Don't claim to have defined va_list.
827 sed -e 's@ va_list @ __gnuc_va_list @' \
828 -e 's@ va_list@ __va_list__@' \
829 -e 's@\*va_list@*__va_list__@' \
830 -e 's@VA_LIST@DUMMY_VA_LIST@' \
831 ${LIB}/$file >> ${LIB}/${file}.sed
833 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
834 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
839 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
841 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
842 if grep -s ULTRIX $file; then
843 echo "/* This file intentionally left blank. */" > $LIB/$file
847 # parameter to atof not const on DECstation Ultrix V4.0.
848 # also get rid of bogus inline definitions in HP-UX 8.0
850 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
851 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
852 chmod +w ${LIB}/$file 2>/dev/null
853 chmod a+r ${LIB}/$file 2>/dev/null
856 if [ -r ${LIB}/$file ]; then
857 echo Fixing $file, non-const arg
858 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
859 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
860 -e 's@inline double abs(double d) { return fabs(d); }@@' \
861 ${LIB}/$file > ${LIB}/${file}.sed
862 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
863 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
868 # In limits.h, put #ifndefs around things that are supposed to be defined
869 # in float.h to avoid redefinition errors if float.h is included first.
871 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
872 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
873 chmod +w ${LIB}/$file 2>/dev/null
874 chmod a+r ${LIB}/$file 2>/dev/null
877 if [ -r ${LIB}/$file ]; then
879 sed -e '/[ ]FLT_MIN[ ]/i\
881 -e '/[ ]FLT_MIN[ ]/a\
883 -e '/[ ]FLT_MAX[ ]/i\
885 -e '/[ ]FLT_MAX[ ]/a\
887 -e '/[ ]FLT_DIG[ ]/i\
889 -e '/[ ]FLT_DIG[ ]/a\
891 -e '/[ ]DBL_MIN[ ]/i\
893 -e '/[ ]DBL_MIN[ ]/a\
895 -e '/[ ]DBL_MAX[ ]/i\
897 -e '/[ ]DBL_MAX[ ]/a\
899 -e '/[ ]DBL_DIG[ ]/i\
901 -e '/[ ]DBL_DIG[ ]/a\
903 ${LIB}/$file > ${LIB}/${file}.sed
904 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
905 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
906 echo Deleting ${LIB}/$file\; no fixes were needed.
911 # These two files on SunOS 4 are included by other files
912 # in the same directory, using "...". So we must make sure they exist
913 # in the same directory as the other fixed files.
914 if [ -r ${INPUT}/multimedia/audio_errno.h ]
916 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
918 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
920 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
923 echo 'Removing unneeded directories:'
925 files=`find . -type d -print | sort -r`
926 for file in $files; do
927 rmdir $LIB/$file > /dev/null 2>&1
931 echo 'Making internal symbolic non-directory links'
933 files=`find . -type l -print`
934 for file in $files; do
935 dest=`ls -ld $file | sed -n 's/.*-> //p'`
936 if expr "$dest" : '[^/].*' > /dev/null; then
937 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
938 if [ -f $target ]; then
939 ln -s $dest ${LIB}/$file >/dev/null 2>&1