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
234 if [ -r $file ]; then
235 cp $file $2/$file >/dev/null 2>&1 \
236 || echo "Can't copy $file"
239 # Following two lines removed.
240 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
241 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
247 /\/\// s|//\(.*\)$|/*\1*/|
248 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
249 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
250 /#define._IO/ s/'\''x'\''/x/g
251 /#define.BSD43__IO/ s/'\''x'\''/x/g
252 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
253 /#define.CTRL/ s/'\''c'\''/c/g
254 /#define._CTRL/ s/'\''c'\''/c/g
255 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
256 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
257 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
258 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
259 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
260 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
261 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
262 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
263 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
264 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
265 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
266 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
267 /^#define.NULL[ ]/ i\
269 ' $2/$file > $2/$file.sed
270 mv $2/$file.sed $2/$file
271 if cmp $file $2/$file >/dev/null 2>&1; then
282 # Fix one other error in this file: a mismatched quote not inside a C comment.
283 file=sundev/vuid_event.h
284 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
285 mkdir ${LIB}/sundev 2>/dev/null
286 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
287 chmod +w ${LIB}/$file 2>/dev/null
288 chmod a+r ${LIB}/$file 2>/dev/null
291 if [ -r ${LIB}/$file ]; then
292 echo Fixing $file comment
293 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
294 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
295 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
300 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
301 file=sunwindow/win_cursor.h
302 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
303 # mkdir ${LIB}/sunwindow 2>/dev/null
304 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
305 chmod +w ${LIB}/$file 2>/dev/null
307 if [ -r ${LIB}/$file ]; then
309 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
310 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
311 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
315 file=sunwindow/win_lock.h
316 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
317 # mkdir ${LIB}/sunwindow 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
321 if [ -r ${LIB}/$file ]; then
323 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
324 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
325 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
330 # Fix this Sun file to avoid interfering with stddef.h.
332 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
333 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
334 chmod +w ${LIB}/$file 2>/dev/null
335 chmod a+r ${LIB}/$file 2>/dev/null
338 if [ -r ${LIB}/$file ]; then
340 sed -e '/size_t.*;/i\
342 #define _GCC_SIZE_T' \
346 #ifndef _GCC_PTRDIFF_T\
347 #define _GCC_PTRDIFF_T' \
351 #ifndef _GCC_WCHAR_T\
352 #define _GCC_WCHAR_T' \
354 #endif' ${LIB}/$file > ${LIB}/${file}.sed
355 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
356 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
361 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
362 # match e.g. ssize_t present in AIX for the ps/2.
364 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
365 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
366 chmod +w ${LIB}/$file 2>/dev/null
367 chmod a+r ${LIB}/$file 2>/dev/null
370 if [ -r ${LIB}/$file ]; then
372 sed -e '/size_t.*;/i\
374 #define _GCC_SIZE_T' \
376 #endif' ${LIB}/$file > ${LIB}/${file}.sed
377 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
378 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
383 # Fix an error in this file: the #if says _cplusplus, not the double
384 # underscore __cplusplus that it should be
386 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
387 mkdir ${LIB}/rpcsvc 2>/dev/null
388 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
389 chmod +w ${LIB}/$file 2>/dev/null
390 chmod a+r ${LIB}/$file 2>/dev/null
393 if [ -r ${LIB}/$file ]; then
394 echo Fixing $file, __cplusplus macro
395 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
396 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
397 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
402 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
403 # structure definition.
405 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
406 mkdir ${LIB}/rpcsvc 2>/dev/null
407 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
408 chmod +w ${LIB}/$file 2>/dev/null
409 chmod a+r ${LIB}/$file 2>/dev/null
412 if [ -r ${LIB}/$file ]; then
413 echo Fixing $file, definition of statsswtch
414 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
415 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
416 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
421 # Fix an error in this file: a missing semi-colon at the end of the nodeent
422 # structure definition.
423 file=netdnet/dnetdb.h
424 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
425 mkdir ${LIB}/netdnet 2>/dev/null
426 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
427 chmod +w ${LIB}/$file 2>/dev/null
428 chmod a+r ${LIB}/$file 2>/dev/null
431 if [ -r ${LIB}/$file ]; then
432 echo Fixing $file, definition of nodeent
433 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
434 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
435 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
440 # Check for bad #ifdef line (in Ultrix 4.1)
442 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
443 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
444 chmod +w ${LIB}/$file 2>/dev/null
445 chmod a+r ${LIB}/$file 2>/dev/null
448 if [ -r ${LIB}/$file ]; then
449 echo Fixing $file, bad \#ifdef line
450 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
451 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
452 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
457 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
458 # Only needed if commenting out junk after #endif.
460 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
461 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
462 # chmod +w ${LIB}/$file 2>/dev/null
463 # chmod a+r ${LIB}/$file 2>/dev/null
466 #if [ -r ${LIB}/$file ]; then
467 # echo Fixing $file, nested comments
468 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
469 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
470 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
475 # Check for superfluous `static' (in Ultrix 4.2)
477 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
478 mkdir ${LIB}/machine 2>/dev/null
479 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
480 chmod +w ${LIB}/$file 2>/dev/null
481 chmod a+r ${LIB}/$file 2>/dev/null
484 if [ -r ${LIB}/$file ]; then
485 echo Fixing $file, superfluous static
486 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
487 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
488 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
491 # This file has an alternative name, mips/cpu.h. Fix that name, too.
492 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
493 mkdir ${LIB}/mips 2>&-
494 ln ${LIB}/$file ${LIB}/mips/cpu.h
499 # Incorrect sprintf declaration in X11/Xmu.h
501 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
502 mkdir ${LIB}/X11 2>/dev/null
503 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
504 chmod +w ${LIB}/$file 2>/dev/null
505 chmod a+r ${LIB}/$file 2>/dev/null
508 if [ -r ${LIB}/$file ]; then
509 echo Fixing $file sprintf declaration
510 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
511 extern char * sprintf();\
512 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
513 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
514 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
519 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
520 # (It's not clear whether the right file name is this or X11/Xmu.h.)
522 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
523 mkdir ${LIB}/X11/Xmu 2>/dev/null
524 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
525 chmod +w ${LIB}/$file 2>/dev/null
526 chmod a+r ${LIB}/$file 2>/dev/null
529 if [ -r ${LIB}/$file ]; then
530 echo Fixing $file sprintf declaration
531 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
532 extern char * sprintf();\
533 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
534 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
535 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
540 # Check for missing ';' in struct
542 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
543 mkdir ${LIB}/netinet 2>/dev/null
544 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
545 chmod +w ${LIB}/$file 2>/dev/null
546 chmod a+r ${LIB}/$file 2>/dev/null
549 if [ -r ${LIB}/$file ]; then
551 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
552 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
553 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
558 # Fix the CAT macro in SunOS memvar.h.
559 file=pixrect/memvar.h
560 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
561 mkdir ${LIB}/pixrect 2>/dev/null
562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
563 chmod +w ${LIB}/$file 2>/dev/null
564 chmod a+r ${LIB}/$file 2>/dev/null
567 if [ -r ${LIB}/$file ]; then
569 sed -e '/^#define.CAT(a,b)/ i\
571 #define CAT(a,b) a##b\
573 /^#define.CAT(a,b)/ a\
575 ' ${LIB}/$file > ${LIB}/${file}.sed
576 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
577 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
582 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
584 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
585 mkdir ${LIB}/rpcsvc 2>/dev/null
586 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
587 chmod +w ${LIB}/$file 2>/dev/null
588 chmod a+r ${LIB}/$file 2>/dev/null
591 if [ -r ${LIB}/$file ]; then
593 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
594 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
595 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
600 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
602 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
603 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
604 chmod +w ${LIB}/$file 2>/dev/null
605 chmod a+r ${LIB}/$file 2>/dev/null
608 if [ -r ${LIB}/$file ]; then
610 sed -e 's/int abort/void abort/g' \
611 -e 's/int free/void free/g' \
612 -e 's/char \* calloc/void \* calloc/g' \
613 -e 's/char \* malloc/void \* malloc/g' \
614 -e 's/char \* realloc/void \* realloc/g' \
615 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
616 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
617 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
622 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
624 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
625 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
626 chmod +w ${LIB}/$file 2>/dev/null
627 chmod a+r ${LIB}/$file 2>/dev/null
630 if [ -r ${LIB}/$file ]; then
632 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
633 -e 's/int[ ][ ]*free/void free/g' \
634 ${LIB}/$file > ${LIB}/${file}.sed
635 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
636 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
642 # Fix bogus comment in <locale.h> on SunOS 4.1.
644 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
645 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
646 chmod +w ${LIB}/$file 2>/dev/null
647 chmod a+r ${LIB}/$file 2>/dev/null
650 if [ -r ${LIB}/$file ]; then
652 sed -e 's%#endif / \*%#endif /\* %g' ${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
659 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
660 file=hsfs/hsfs_spec.h
661 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
662 mkdir ${LIB}/hsfs 2>/dev/null
663 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
664 chmod +w ${LIB}/$file 2>/dev/null
665 chmod a+r ${LIB}/$file 2>/dev/null
668 if [ -r ${LIB}/$file ]; then
670 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
671 ${LIB}/$file > ${LIB}/${file}.sed
672 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
673 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
678 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
680 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
681 mkdir ${LIB}/hsfs 2>/dev/null
682 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
683 chmod +w ${LIB}/$file 2>/dev/null
684 chmod a+r ${LIB}/$file 2>/dev/null
687 if [ -r ${LIB}/$file ]; then
689 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
690 ${LIB}/$file > ${LIB}/${file}.sed
691 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
692 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
697 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
699 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
700 mkdir ${LIB}/hsfs 2>/dev/null
701 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
702 chmod +w ${LIB}/$file 2>/dev/null
703 chmod a+r ${LIB}/$file 2>/dev/null
706 if [ -r ${LIB}/$file ]; then
708 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
709 ${LIB}/$file > ${LIB}/${file}.sed
710 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
711 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
716 # Incorrect #include in Sony News-OS 3.2.
717 file=machine/machparam.h
718 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
719 mkdir ${LIB}/machine 2>/dev/null
720 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
721 chmod +w ${LIB}/$file 2>/dev/null
722 chmod a+r ${LIB}/$file 2>/dev/null
725 if [ -r ${LIB}/$file ]; then
726 echo Fixing $file, incorrect \#include
727 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
728 ${LIB}/$file > ${LIB}/${file}.sed
729 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
730 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
735 # Multiline comment after typedef on IRIX 4.0.1.
737 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
738 mkdir ${LIB}/sys 2>/dev/null
739 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
740 chmod +w ${LIB}/$file 2>/dev/null
741 chmod a+r ${LIB}/$file 2>/dev/null
744 if [ -r ${LIB}/$file ]; then
745 echo Fixing $file, comment in the middle of \#ifdef
746 sed -e 's@type of the result@type of the result */@' \
747 -e 's@of the sizeof@/* of the sizeof@' \
748 ${LIB}/$file > ${LIB}/${file}.sed
749 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
750 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
755 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
756 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
757 # many other systems have similar text but correct versions of the file.
758 # To ensure only Sun's is fixed, we grep for a likely unique string.
760 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
761 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
762 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
763 chmod +w ${LIB}/$file 2>/dev/null
764 chmod a+r ${LIB}/$file 2>/dev/null
766 if [ -r ${LIB}/$file ]; then
768 cat > ${LIB}/$file << EOF
769 /* This file was generated by fixincludes */
774 extern void *memccpy();
775 extern void *memchr();
776 extern void *memcpy();
777 extern void *memset();
779 extern char *memccpy();
780 extern char *memchr();
781 extern char *memcpy();
782 extern char *memset();
783 #endif /* __STDC__ */
792 # parameters not const on DECstation Ultrix V4.0.
794 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
795 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
796 chmod +w ${LIB}/$file 2>/dev/null
797 chmod a+r ${LIB}/$file 2>/dev/null
800 if [ -r ${LIB}/$file ]; then
801 echo Fixing $file, non-const arg
802 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
803 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
804 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
805 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
806 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
807 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
808 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
809 ${LIB}/$file > ${LIB}/${file}.sed
810 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
811 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
816 # parameters conflict with C++ new on rs/6000
818 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
819 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
820 chmod +w ${LIB}/$file 2>/dev/null
823 if [ -r ${LIB}/$file ]; then
824 echo Fixing $file, parameter name conflicts
825 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
826 ${LIB}/$file > ${LIB}/${file}.sed
827 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
828 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
833 # Don't use or define the name va_list in stdio.h.
834 # This is for ANSI and also to interoperate properly with gvarargs.h.
836 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
837 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
838 chmod +w ${LIB}/$file 2>/dev/null
839 chmod a+r ${LIB}/$file 2>/dev/null
842 if [ -r ${LIB}/$file ]; then
843 echo Fixing $file, use of va_list
844 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
845 (echo "#define __need___va_list"
846 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
847 # Use __gnuc_va_list in arg types in place of va_list.
848 # Define __va_list__ (something harmless and unused) instead of va_list.
849 # Don't claim to have defined va_list.
850 sed -e 's@ va_list @ __gnuc_va_list @' \
851 -e 's@ va_list@ __va_list__@' \
852 -e 's@\*va_list@*__va_list__@' \
853 -e 's@VA_LIST@DUMMY_VA_LIST@' \
854 ${LIB}/$file >> ${LIB}/${file}.sed
856 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
857 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
862 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
864 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
865 if grep -s ULTRIX $file; then
866 echo "/* This file intentionally left blank. */" > $LIB/$file
870 # parameter to atof not const on DECstation Ultrix V4.0.
871 # also get rid of bogus inline definitions in HP-UX 8.0
873 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
874 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
875 chmod +w ${LIB}/$file 2>/dev/null
876 chmod a+r ${LIB}/$file 2>/dev/null
879 if [ -r ${LIB}/$file ]; then
880 echo Fixing $file, non-const arg
881 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
882 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
883 -e 's@inline double abs(double d) { return fabs(d); }@@' \
884 ${LIB}/$file > ${LIB}/${file}.sed
885 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
886 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
891 # In limits.h, put #ifndefs around things that are supposed to be defined
892 # in float.h to avoid redefinition errors if float.h is included first.
894 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
895 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
896 chmod +w ${LIB}/$file 2>/dev/null
897 chmod a+r ${LIB}/$file 2>/dev/null
900 if [ -r ${LIB}/$file ]; then
902 sed -e '/[ ]FLT_MIN[ ]/i\
904 -e '/[ ]FLT_MIN[ ]/a\
906 -e '/[ ]FLT_MAX[ ]/i\
908 -e '/[ ]FLT_MAX[ ]/a\
910 -e '/[ ]FLT_DIG[ ]/i\
912 -e '/[ ]FLT_DIG[ ]/a\
914 -e '/[ ]DBL_MIN[ ]/i\
916 -e '/[ ]DBL_MIN[ ]/a\
918 -e '/[ ]DBL_MAX[ ]/i\
920 -e '/[ ]DBL_MAX[ ]/a\
922 -e '/[ ]DBL_DIG[ ]/i\
924 -e '/[ ]DBL_DIG[ ]/a\
926 ${LIB}/$file > ${LIB}/${file}.sed
927 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
928 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
929 echo Deleting ${LIB}/$file\; no fixes were needed.
934 # These two files on SunOS 4 are included by other files
935 # in the same directory, using "...". So we must make sure they exist
936 # in the same directory as the other fixed files.
937 if [ -r ${INPUT}/multimedia/audio_errno.h ]
939 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
941 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
943 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
946 echo 'Removing unneeded directories:'
948 files=`find . -type d -print | sort -r`
949 for file in $files; do
950 rmdir $LIB/$file > /dev/null 2>&1
954 echo 'Making internal symbolic non-directory links'
956 files=`find . -type l -print`
957 for file in $files; do
958 dest=`ls -ld $file | sed -n 's/.*-> //p'`
959 if expr "$dest" : '[^/].*' > /dev/null; then
960 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
961 if [ -f $target ]; then
962 ln -s $dest ${LIB}/$file >/dev/null 2>&1