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
35 # Make LIB absolute only if needed to avoid problems with the amd.
40 cd $LIB; LIB=`${PWDCMD}`
44 # Fail if no arg to specify a directory for the output.
46 then echo fixincludes: no output directory specified
50 echo Building fixed headers in ${LIB}
52 # Determine whether this system has symbolic links.
53 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
54 rm -f $LIB/ShouldNotExist
60 echo Finding directories and links to directories
62 # Find all directories and all symlinks that point to directories.
63 # Put the list in $files.
64 # Each time we find a symlink, add it to newdirs
65 # so that we do another find within the dir the link points to.
66 # Note that $files may have duplicates in it;
67 # later parts of this file are supposed to ignore them.
70 while [ -n "$dirs" ] && [ $levels -gt 0 ]
72 levels=`expr $levels - 1`
76 echo " Searching $INPUT/$d"
82 # Find all directories under $d, relative to $d, excluding $d itself.
83 files="$files `find $d -type d -print | \
84 sed -e '/\/\.$/d' -e '/^\.$/d'`"
85 # Find all links to directories.
86 # Using `-exec test -d' in find fails on some systems,
87 # and trying to run test via sh fails on others,
88 # so this is the simplest alternative left.
89 # First find all the links, then test each one.
92 theselinks=`find $d -type l -print`
93 for d1 in $theselinks --dummy--
95 # If the link points to a directory,
96 # add that dir to $newdirs
99 newdirs="$newdirs $d1"
104 files="$files $newdirs"
109 echo "All directories (including links to directories):"
112 for file in $files; do
114 if [ ! -d $LIB/$file ]
115 then mkdir $LIB/$file
120 # treetops gets an alternating list
121 # of old directories to copy
122 # and the new directories to copy to.
123 treetops="${INPUT} ${LIB}"
126 echo 'Making symbolic directory links'
127 for file in $files; do
128 dest=`ls -ld $file | sed -n 's/.*-> //p'`
131 # In case $dest is relative, get to $file's dir first.
133 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
134 # Check that the target directory exists.
135 # Redirections changed to avoid bug in sh on Ultrix.
136 (cd $dest) > /dev/null 2>&1
139 # X gets the dir that the link actually leads to.
141 # If a link points to ., make a similar link to .
142 if [ $x = $INPUT ]; then
143 echo $file '->' . ': Making link'
144 rm -fr ${LIB}/$file > /dev/null 2>&1
145 ln -s . ${LIB}/$file > /dev/null 2>&1
146 # If link leads back into ${INPUT},
147 # make a similar link here.
148 elif expr $x : "${INPUT}/.*" > /dev/null; then
149 # Y gets the actual target dir name, relative to ${INPUT}.
150 y=`echo $x | sed -n "s&${INPUT}/&&p"`
151 echo $file '->' $y ': Making link'
152 rm -fr ${LIB}/$file > /dev/null 2>&1
153 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
155 # If the link is to a dir $target outside ${INPUT},
156 # repoint the link at ${INPUT}/root$target
157 # and process $target into ${INPUT}/root$target
158 # treat this directory as if it actually contained the files.
159 echo $file '->' root$x ': Making link'
160 if [ -d $LIB/root$x ]
166 while [ x$dirname != x ]; do
167 component=`echo $dirname | sed -e 's|/.*$||'`
168 mkdir $component >/dev/null 2>&1
170 dirmade=$dirmade/$component
171 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
174 # Duplicate directory structure created in ${LIB}/$file in new
176 for file2 in $files; do
181 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
182 echo "Duplicating ${file}'s ${dupdir}"
191 rm -fr ${LIB}/$file > /dev/null 2>&1
192 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
193 treetops="$treetops $x ${LIB}/root$x"
202 while [ $# != 0 ]; do
203 # $1 is an old directory to copy, and $2 is the new directory to copy to.
206 # The same dir can appear more than once in treetops.
207 # There's no need to scan it more than once.
213 echo Fixing directory $1 into $2
214 # Check .h files which are symlinks as well as those which are files.
215 # A link to a header file will not be processed by anything but this.
217 files=`find . -name '*.h' \( -type f -o -type l \) -print`
219 files=`find . -name '*.h' -type f -print`
221 echo Checking header files
223 # Note that BSD43_* are used on recent MIPS systems.
224 for file in $files; do
225 # This call to egrep is essential, since checking a file with egrep
226 # is much faster than actually trying to fix it.
227 # It is also essential that most files *not* match!
228 # Thus, matching every #endif is unacceptable.
229 # But the argument to egrep must be kept small, or many versions of egrep
230 # won't be able to handle it.
231 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
232 if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
233 if [ -r $file ]; then
234 cp $file $2/$file >/dev/null 2>&1 \
235 || echo "Can't copy $file"
238 # Following two lines removed.
239 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
240 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
246 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
247 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
248 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
249 /#define._IO/ s/'\''x'\''/x/g
250 /#define.BSD43__IO/ s/'\''x'\''/x/g
251 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
252 /#define.CTRL/ s/'\''c'\''/c/g
253 /#define._CTRL/ s/'\''c'\''/c/g
254 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
255 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
256 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
257 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
258 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
259 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
260 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
261 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
262 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
263 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
264 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
265 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
266 /^#define.NULL[ ]/ i\
268 ' $2/$file > $2/$file.sed
269 mv $2/$file.sed $2/$file
270 if cmp $file $2/$file >/dev/null 2>&1; then
283 # Fix one other error in this file: a mismatched quote not inside a C comment.
284 file=sundev/vuid_event.h
285 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
286 mkdir ${LIB}/sundev 2>/dev/null
287 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
288 chmod +w ${LIB}/$file 2>/dev/null
289 chmod a+r ${LIB}/$file 2>/dev/null
292 if [ -r ${LIB}/$file ]; then
293 echo Fixing $file comment
294 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
295 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
296 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
301 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
302 file=sunwindow/win_cursor.h
303 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
304 # mkdir ${LIB}/sunwindow 2>/dev/null
305 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
306 chmod +w ${LIB}/$file 2>/dev/null
308 if [ -r ${LIB}/$file ]; then
310 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
311 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
312 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
316 file=sunwindow/win_lock.h
317 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
318 # mkdir ${LIB}/sunwindow 2>/dev/null
319 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
320 chmod +w ${LIB}/$file 2>/dev/null
322 if [ -r ${LIB}/$file ]; then
324 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
325 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
326 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
331 # Fix this Sun file to avoid interfering with stddef.h.
333 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
334 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
335 chmod +w ${LIB}/$file 2>/dev/null
336 chmod a+r ${LIB}/$file 2>/dev/null
339 if [ -r ${LIB}/$file ]; then
341 sed -e '/size_t.*;/i\
343 #define _GCC_SIZE_T' \
347 #ifndef _GCC_PTRDIFF_T\
348 #define _GCC_PTRDIFF_T' \
352 #ifndef _GCC_WCHAR_T\
353 #define _GCC_WCHAR_T' \
355 #endif' ${LIB}/$file > ${LIB}/${file}.sed
356 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
357 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
362 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
363 # match e.g. ssize_t present in AIX for the ps/2.
365 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
366 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
367 chmod +w ${LIB}/$file 2>/dev/null
368 chmod a+r ${LIB}/$file 2>/dev/null
371 if [ -r ${LIB}/$file ]; then
373 sed -e '/size_t.*;/i\
375 #define _GCC_SIZE_T' \
377 #endif' ${LIB}/$file > ${LIB}/${file}.sed
378 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
379 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
384 # Fix an error in this file: the #if says _cplusplus, not the double
385 # underscore __cplusplus that it should be
387 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
388 mkdir ${LIB}/rpcsvc 2>/dev/null
389 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
390 chmod +w ${LIB}/$file 2>/dev/null
391 chmod a+r ${LIB}/$file 2>/dev/null
394 if [ -r ${LIB}/$file ]; then
395 echo Fixing $file, __cplusplus macro
396 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
397 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
398 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
403 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
404 # structure definition.
406 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
407 mkdir ${LIB}/rpcsvc 2>/dev/null
408 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
409 chmod +w ${LIB}/$file 2>/dev/null
410 chmod a+r ${LIB}/$file 2>/dev/null
413 if [ -r ${LIB}/$file ]; then
414 echo Fixing $file, definition of statsswtch
415 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
416 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
417 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
422 # Fix an error in this file: a missing semi-colon at the end of the nodeent
423 # structure definition.
424 file=netdnet/dnetdb.h
425 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
426 mkdir ${LIB}/netdnet 2>/dev/null
427 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
428 chmod +w ${LIB}/$file 2>/dev/null
429 chmod a+r ${LIB}/$file 2>/dev/null
432 if [ -r ${LIB}/$file ]; then
433 echo Fixing $file, definition of nodeent
434 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
435 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
436 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
441 # Check for bad #ifdef line (in Ultrix 4.1)
443 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
444 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
445 chmod +w ${LIB}/$file 2>/dev/null
446 chmod a+r ${LIB}/$file 2>/dev/null
449 if [ -r ${LIB}/$file ]; then
450 echo Fixing $file, bad \#ifdef line
451 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
452 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
453 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
458 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
459 # Only needed if commenting out junk after #endif.
461 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
462 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
463 # chmod +w ${LIB}/$file 2>/dev/null
464 # chmod a+r ${LIB}/$file 2>/dev/null
467 #if [ -r ${LIB}/$file ]; then
468 # echo Fixing $file, nested comments
469 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
470 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
471 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
476 # Check for superfluous `static' (in Ultrix 4.2)
478 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
479 mkdir ${LIB}/machine 2>/dev/null
480 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
481 chmod +w ${LIB}/$file 2>/dev/null
482 chmod a+r ${LIB}/$file 2>/dev/null
485 if [ -r ${LIB}/$file ]; then
486 echo Fixing $file, superfluous static
487 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
488 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
489 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
492 # This file has an alternative name, mips/cpu.h. Fix that name, too.
493 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
494 mkdir ${LIB}/mips 2>&-
495 ln ${LIB}/$file ${LIB}/mips/cpu.h
500 # Incorrect sprintf declaration in X11/Xmu.h
502 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
503 mkdir ${LIB}/X11 2>/dev/null
504 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
505 chmod +w ${LIB}/$file 2>/dev/null
506 chmod a+r ${LIB}/$file 2>/dev/null
509 if [ -r ${LIB}/$file ]; then
510 echo Fixing $file sprintf declaration
511 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
512 extern char * sprintf();\
513 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
514 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
515 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
520 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
521 # (It's not clear whether the right file name is this or X11/Xmu.h.)
523 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
524 mkdir ${LIB}/X11/Xmu 2>/dev/null
525 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
526 chmod +w ${LIB}/$file 2>/dev/null
527 chmod a+r ${LIB}/$file 2>/dev/null
530 if [ -r ${LIB}/$file ]; then
531 echo Fixing $file sprintf declaration
532 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
533 extern char * sprintf();\
534 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
535 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
536 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
541 # Check for missing ';' in struct
543 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
544 mkdir ${LIB}/netinet 2>/dev/null
545 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
546 chmod +w ${LIB}/$file 2>/dev/null
547 chmod a+r ${LIB}/$file 2>/dev/null
550 if [ -r ${LIB}/$file ]; then
552 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
553 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
554 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
559 # Fix the CAT macro in SunOS memvar.h.
560 file=pixrect/memvar.h
561 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
562 mkdir ${LIB}/pixrect 2>/dev/null
563 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
564 chmod +w ${LIB}/$file 2>/dev/null
565 chmod a+r ${LIB}/$file 2>/dev/null
568 if [ -r ${LIB}/$file ]; then
570 sed -e '/^#define.CAT(a,b)/ i\
572 #define CAT(a,b) a##b\
574 /^#define.CAT(a,b)/ a\
576 ' ${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
583 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
585 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
586 mkdir ${LIB}/rpcsvc 2>/dev/null
587 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
588 chmod +w ${LIB}/$file 2>/dev/null
589 chmod a+r ${LIB}/$file 2>/dev/null
592 if [ -r ${LIB}/$file ]; then
594 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
595 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
596 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
601 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
603 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
604 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
605 chmod +w ${LIB}/$file 2>/dev/null
606 chmod a+r ${LIB}/$file 2>/dev/null
609 if [ -r ${LIB}/$file ]; then
611 sed -e 's/int abort/void abort/g' \
612 -e 's/int free/void free/g' \
613 -e 's/char \* calloc/void \* calloc/g' \
614 -e 's/char \* malloc/void \* malloc/g' \
615 -e 's/char \* realloc/void \* realloc/g' \
616 -e 's/int exit/void exit/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
623 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
625 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
626 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
627 chmod +w ${LIB}/$file 2>/dev/null
628 chmod a+r ${LIB}/$file 2>/dev/null
631 if [ -r ${LIB}/$file ]; then
633 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
634 -e 's/int[ ][ ]*free/void free/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
643 # Fix bogus comment in <locale.h> on SunOS 4.1.
645 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
646 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
647 chmod +w ${LIB}/$file 2>/dev/null
648 chmod a+r ${LIB}/$file 2>/dev/null
651 if [ -r ${LIB}/$file ]; then
653 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
654 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
655 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
660 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
661 file=hsfs/hsfs_spec.h
662 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
663 mkdir ${LIB}/hsfs 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
666 chmod a+r ${LIB}/$file 2>/dev/null
669 if [ -r ${LIB}/$file ]; then
671 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
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
679 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
681 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
682 mkdir ${LIB}/hsfs 2>/dev/null
683 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
684 chmod +w ${LIB}/$file 2>/dev/null
685 chmod a+r ${LIB}/$file 2>/dev/null
688 if [ -r ${LIB}/$file ]; then
690 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
691 ${LIB}/$file > ${LIB}/${file}.sed
692 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
693 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
698 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
700 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
701 mkdir ${LIB}/hsfs 2>/dev/null
702 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
703 chmod +w ${LIB}/$file 2>/dev/null
704 chmod a+r ${LIB}/$file 2>/dev/null
707 if [ -r ${LIB}/$file ]; then
709 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
710 ${LIB}/$file > ${LIB}/${file}.sed
711 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
712 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
717 # Incorrect #include in Sony News-OS 3.2.
718 file=machine/machparam.h
719 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
720 mkdir ${LIB}/machine 2>/dev/null
721 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
722 chmod +w ${LIB}/$file 2>/dev/null
723 chmod a+r ${LIB}/$file 2>/dev/null
726 if [ -r ${LIB}/$file ]; then
727 echo Fixing $file, incorrect \#include
728 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
729 ${LIB}/$file > ${LIB}/${file}.sed
730 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
731 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
736 # Multiline comment after typedef on IRIX 4.0.1.
738 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
739 mkdir ${LIB}/sys 2>/dev/null
740 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
741 chmod +w ${LIB}/$file 2>/dev/null
742 chmod a+r ${LIB}/$file 2>/dev/null
745 if [ -r ${LIB}/$file ]; then
746 echo Fixing $file, comment in the middle of \#ifdef
747 sed -e 's@type of the result@type of the result */@' \
748 -e 's@of the sizeof@/* of the sizeof@' \
749 ${LIB}/$file > ${LIB}/${file}.sed
750 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
751 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
756 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
757 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
758 # many other systems have similar text but correct versions of the file.
759 # To ensure only Sun's is fixed, we grep for a likely unique string.
761 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
762 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
763 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
764 chmod +w ${LIB}/$file 2>/dev/null
765 chmod a+r ${LIB}/$file 2>/dev/null
767 if [ -r ${LIB}/$file ]; then
769 cat > ${LIB}/$file << EOF
770 /* This file was generated by fixincludes */
775 extern void *memccpy();
776 extern void *memchr();
777 extern void *memcpy();
778 extern void *memset();
780 extern char *memccpy();
781 extern char *memchr();
782 extern char *memcpy();
783 extern char *memset();
784 #endif /* __STDC__ */
793 # parameters not const on DECstation Ultrix V4.0.
795 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
796 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
797 chmod +w ${LIB}/$file 2>/dev/null
798 chmod a+r ${LIB}/$file 2>/dev/null
801 if [ -r ${LIB}/$file ]; then
802 echo Fixing $file, non-const arg
803 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
804 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
805 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
806 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
807 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
808 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
809 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
810 ${LIB}/$file > ${LIB}/${file}.sed
811 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
812 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
817 # parameters conflict with C++ new on rs/6000
819 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
820 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
821 chmod +w ${LIB}/$file 2>/dev/null
824 if [ -r ${LIB}/$file ]; then
825 echo Fixing $file, parameter name conflicts
826 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
827 ${LIB}/$file > ${LIB}/${file}.sed
828 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
829 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
834 # Don't use or define the name va_list in stdio.h.
835 # This is for ANSI and also to interoperate properly with gvarargs.h.
837 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
838 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
839 chmod +w ${LIB}/$file 2>/dev/null
840 chmod a+r ${LIB}/$file 2>/dev/null
843 if [ -r ${LIB}/$file ]; then
844 echo Fixing $file, use of va_list
845 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
846 (echo "#define __need___va_list"
847 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
848 # Use __gnuc_va_list in arg types in place of va_list.
849 # Define __va_list__ (something harmless and unused) instead of va_list.
850 # Don't claim to have defined va_list.
851 sed -e 's@ va_list @ __gnuc_va_list @' \
852 -e 's@ va_list@ __va_list__@' \
853 -e 's@\*va_list@*__va_list__@' \
854 -e 's@VA_LIST@DUMMY_VA_LIST@' \
855 ${LIB}/$file >> ${LIB}/${file}.sed
857 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
858 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
863 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
865 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
866 if grep -s ULTRIX $file; then
867 echo "/* This file intentionally left blank. */" > $LIB/$file
871 # parameter to atof not const on DECstation Ultrix V4.0.
872 # also get rid of bogus inline definitions in HP-UX 8.0
874 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
875 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
876 chmod +w ${LIB}/$file 2>/dev/null
877 chmod a+r ${LIB}/$file 2>/dev/null
880 if [ -r ${LIB}/$file ]; then
881 echo Fixing $file, non-const arg
882 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
883 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
884 -e 's@inline double abs(double d) { return fabs(d); }@@' \
885 ${LIB}/$file > ${LIB}/${file}.sed
886 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
887 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
892 # In limits.h, put #ifndefs around things that are supposed to be defined
893 # in float.h to avoid redefinition errors if float.h is included first.
895 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
896 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
897 chmod +w ${LIB}/$file 2>/dev/null
898 chmod a+r ${LIB}/$file 2>/dev/null
901 if [ -r ${LIB}/$file ]; then
903 sed -e '/[ ]FLT_MIN[ ]/i\
905 -e '/[ ]FLT_MIN[ ]/a\
907 -e '/[ ]FLT_MAX[ ]/i\
909 -e '/[ ]FLT_MAX[ ]/a\
911 -e '/[ ]FLT_DIG[ ]/i\
913 -e '/[ ]FLT_DIG[ ]/a\
915 -e '/[ ]DBL_MIN[ ]/i\
917 -e '/[ ]DBL_MIN[ ]/a\
919 -e '/[ ]DBL_MAX[ ]/i\
921 -e '/[ ]DBL_MAX[ ]/a\
923 -e '/[ ]DBL_DIG[ ]/i\
925 -e '/[ ]DBL_DIG[ ]/a\
927 ${LIB}/$file > ${LIB}/${file}.sed
928 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
929 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
930 echo Deleting ${LIB}/$file\; no fixes were needed.
935 # These two files on SunOS 4 are included by other files
936 # in the same directory, using "...". So we must make sure they exist
937 # in the same directory as the other fixed files.
938 if [ -r ${INPUT}/multimedia/audio_errno.h ]
940 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
942 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
944 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
947 echo 'Removing unneeded directories:'
949 files=`find . -type d -print | sort -r`
950 for file in $files; do
951 rmdir $LIB/$file > /dev/null 2>&1
955 echo 'Making internal symbolic non-directory links'
957 files=`find . -type l -print`
958 for file in $files; do
959 dest=`ls -ld $file | sed -n 's/.*-> //p'`
960 if expr "$dest" : '[^/].*' > /dev/null; then
961 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
962 if [ -f $target ]; then
963 ln -s $dest ${LIB}/$file >/dev/null 2>&1