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/,'"
33 # Make sure it exists.
34 if [ ! -d $LIB ]; then
38 # Make LIB absolute only if needed to avoid problems with the amd.
43 cd $LIB; LIB
=`${PWDCMD}`
47 # Make SRCDIR absolute only if needed to avoid problems with the amd.
53 cd $SRCDIR; SRCDIR
=`${PWDCMD}`
57 # Fail if no arg to specify a directory for the output.
59 then echo fixincludes
: no output directory specified
63 echo Building fixed headers
in ${LIB}
65 # Determine whether this system has symbolic links.
66 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
67 rm -f $LIB/ShouldNotExist
73 echo Finding directories and links to directories
75 # Find all directories and all symlinks that point to directories.
76 # Put the list in $files.
77 # Each time we find a symlink, add it to newdirs
78 # so that we do another find within the dir the link points to.
79 # Note that $files may have duplicates in it;
80 # later parts of this file are supposed to ignore them.
83 while [ -n "$dirs" ] && [ $levels -gt 0 ]
85 levels
=`expr $levels - 1`
89 echo " Searching $INPUT/$d"
95 # Find all directories under $d, relative to $d, excluding $d itself.
96 files
="$files `find $d -type d -print | \
97 sed -e '/\/\.$/d' -e '/^\.$/d'`"
98 # Find all links to directories.
99 # Using `-exec test -d' in find fails on some systems,
100 # and trying to run test via sh fails on others,
101 # so this is the simplest alternative left.
102 # First find all the links, then test each one.
105 theselinks
=`find $d -type l -print`
106 for d1
in $theselinks --dummy--
108 # If the link points to a directory,
109 # add that dir to $newdirs
112 newdirs
="$newdirs $d1"
117 files
="$files $newdirs"
122 echo "All directories (including links to directories):"
125 for file in $files; do
127 if [ ! -d $LIB/$file ]
128 then mkdir
$LIB/$file
133 # treetops gets an alternating list
134 # of old directories to copy
135 # and the new directories to copy to.
136 treetops
="${INPUT} ${LIB}"
139 echo 'Making symbolic directory links'
140 for file in $files; do
141 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
144 # In case $dest is relative, get to $file's dir first.
146 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
147 # Check that the target directory exists.
148 # Redirections changed to avoid bug in sh on Ultrix.
149 (cd $dest) > /dev
/null
2>&1
152 # X gets the dir that the link actually leads to.
154 # If a link points to ., make a similar link to .
155 if [ $x = $INPUT ]; then
156 echo $file '->' .
': Making link'
157 rm -fr ${LIB}/$file > /dev
/null
2>&1
158 ln -s .
${LIB}/$file > /dev
/null
2>&1
159 # If link leads back into ${INPUT},
160 # make a similar link here.
161 elif expr $x : "${INPUT}/.*" > /dev
/null
; then
162 # Y gets the actual target dir name, relative to ${INPUT}.
163 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
164 echo $file '->' $y ': Making link'
165 rm -fr ${LIB}/$file > /dev
/null
2>&1
166 ln -s ${LIB}/$y ${LIB}/$file > /dev
/null
2>&1
168 # If the link is to a dir $target outside ${INPUT},
169 # repoint the link at ${INPUT}/root$target
170 # and process $target into ${INPUT}/root$target
171 # treat this directory as if it actually contained the files.
172 echo $file '->' root
$x ': Making link'
173 if [ -d $LIB/root
$x ]
179 while [ x
$dirname != x
]; do
180 component
=`echo $dirname | sed -e 's|/.*$||'`
181 mkdir
$component >/dev
/null
2>&1
183 dirmade
=$dirmade/$component
184 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
187 # Duplicate directory structure created in ${LIB}/$file in new
189 for file2
in $files; do
192 dupdir
=${LIB}/root
$x/`echo $file2 | sed -n "s|^${file}/||p"`
193 echo "Duplicating ${file}'s ${dupdir}"
204 rm -fr ${LIB}/$file > /dev
/null
2>&1
205 ln -s ${LIB}/root
$x ${LIB}/$file > /dev
/null
2>&1
206 treetops
="$treetops $x ${LIB}/root$x"
216 while [ $# != 0 ]; do
217 # $1 is an old directory to copy, and $2 is the new directory to copy to.
220 # The same dir can appear more than once in treetops.
221 # There's no need to scan it more than once.
227 echo Fixing directory
$1 into
$2
228 # Check .h files which are symlinks as well as those which are files.
229 # A link to a header file will not be processed by anything but this.
231 files
=`find . -name '*.h' \( -type f -o -type l \) -print`
233 files
=`find . -name '*.h' -type f -print`
235 echo Checking header files
237 # Note that BSD43_* are used on recent MIPS systems.
238 for file in $files; do
239 # This call to egrep is essential, since checking a file with egrep
240 # is much faster than actually trying to fix it.
241 # It is also essential that most files *not* match!
242 # Thus, matching every #endif is unacceptable.
243 # But the argument to egrep must be kept small, or many versions of egrep
244 # won't be able to handle it.
246 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
247 # following #else or #endif because some buggy egreps think [^/] matches
248 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
250 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
251 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
252 # in this pattern lacks `d' and `l'; this means we don't worry about
253 # identifiers starting with `d' or `l'. This is OK, since none of the
254 # identifiers below start with `d' or `l'. It also greatly improves
255 # performance, since many files contain lines of the form `#if ... defined ...'
257 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev
/null
; then
258 if [ -r $file ]; then
259 cp $file $2/$file >/dev
/null
2>&1 \
260 ||
echo "Can't copy $file"
263 # Here is how the sed commands in braces work.
264 # (It doesn't work to put the comments inside the sed commands.)
265 # Surround each word with spaces, to simplify matching below.
266 # ANSIfy each pre-ANSI machine-dependent symbol
267 # by surrounding it with __ __.
268 # Remove the spaces that we inserted around each word.
273 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
274 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
275 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
276 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
277 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
278 /#define._IO/ s/'\''\([cgx]\)'\''/\1/g
279 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
280 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
281 /#define.CTRL/ s/'\''\([cgx]\)'\''/\1/g
282 /#define._CTRL/ s/'\''\([cgx]\)'\''/\1/g
283 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
285 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
287 s/ bsd4\([0-9]\) / __bsd4\1__ /g
288 s/ _*i386 / __i386__ /g
289 s/ is68k / __is68k__ /g
290 s/ m68k / __m68k__ /g
291 s/ mc680\([0-9]\)0 / __mc680\10__ /g
292 s/ news\([0-9]*\) / __news\1__ /g
293 s/ ns32000 / __ns32000__ /g
295 s/ sony_news / __sony_news__ /g
296 s/ sparc / __sparc__ /g
297 s/ sun\([a-z0-9]*\) / __sun\1__ /g
298 s/ unix / __unix__ /g
301 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
303 /^#define.NULL[ ]/ i\
305 ' $2/$file > $2/$file.
sed
306 mv $2/$file.
sed $2/$file
307 if cmp $file $2/$file >/dev
/null
2>&1; then
320 # Install the proper definition of size_t in header files that it comes from.
321 for file in sys
/types.h sys
/stdtypes.h
;
323 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
324 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
325 chmod +w
${LIB}/$file 2>/dev
/null
326 chmod a
+r
${LIB}/$file 2>/dev
/null
329 if [ -r ${LIB}/$file ]; then
330 echo Fixing
$file comment
331 # Extract the definition of SIZE_TYPE, if any.
332 # (This file must be called something.c).
333 echo "#include \"tm.h\"
334 gobblegobble SIZE_TYPE" > ${LIB}/types.c
335 foo
=`cc -E -I${ORIGDIR} -I${SRCDIR} -I${SRCDIR}/config ${LIB}/types.c | grep gobblegobble | sed -e "s/gobblegobble[ ]*//"`
337 # Default to our preferred type.
338 if [ "$foo" = SIZE_TYPE
]; then foo
="unsigned long int"; else foo
=`echo $foo | sed -e 's/^.*"\(.*\)".*$/\1/'`; fi
339 sed -e "s/typedef[ a-z_]*[ ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.
sed
340 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
341 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
347 # Fix one other error in this file: a mismatched quote not inside a C comment.
348 file=sundev
/vuid_event.h
349 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
350 mkdir
${LIB}/sundev
2>/dev
/null
351 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
352 chmod +w
${LIB}/$file 2>/dev
/null
353 chmod a
+r
${LIB}/$file 2>/dev
/null
356 if [ -r ${LIB}/$file ]; then
357 echo Fixing
$file comment
358 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.
sed
359 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
360 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
365 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
366 file=sunwindow
/win_cursor.h
367 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
368 # mkdir ${LIB}/sunwindow 2>/dev/null
369 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
370 chmod +w
${LIB}/$file 2>/dev
/null
372 if [ -r ${LIB}/$file ]; then
374 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.
sed
375 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
376 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
380 file=sunwindow
/win_lock.h
381 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
382 # mkdir ${LIB}/sunwindow 2>/dev/null
383 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
384 chmod +w
${LIB}/$file 2>/dev
/null
386 if [ -r ${LIB}/$file ]; then
388 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.
sed
389 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
390 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
395 # Fix this Sun file to avoid interfering with stddef.h.
397 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
398 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
399 chmod +w
${LIB}/$file 2>/dev
/null
400 chmod a
+r
${LIB}/$file 2>/dev
/null
403 if [ -r ${LIB}/$file ]; then
405 sed -e '/size_t.*;/i\
407 #define _GCC_SIZE_T' \
411 #ifndef _GCC_PTRDIFF_T\
412 #define _GCC_PTRDIFF_T' \
416 #ifndef _GCC_WCHAR_T\
417 #define _GCC_WCHAR_T' \
419 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
420 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
421 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
426 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
427 # match e.g. ssize_t present in AIX for the ps/2.
429 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
430 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
431 chmod +w
${LIB}/$file 2>/dev
/null
432 chmod a
+r
${LIB}/$file 2>/dev
/null
435 if [ -r ${LIB}/$file ]; then
437 sed -e '/[ ]size_t.*;/i\
439 #define _GCC_SIZE_T' \
441 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
442 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
443 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
448 # Fix an error in this file: the #if says _cplusplus, not the double
449 # underscore __cplusplus that it should be
451 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
452 mkdir
${LIB}/rpcsvc
2>/dev
/null
453 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
454 chmod +w
${LIB}/$file 2>/dev
/null
455 chmod a
+r
${LIB}/$file 2>/dev
/null
458 if [ -r ${LIB}/$file ]; then
459 echo Fixing
$file, __cplusplus macro
460 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.
sed
461 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
462 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
467 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
468 # structure definition.
470 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
471 mkdir
${LIB}/rpcsvc
2>/dev
/null
472 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
473 chmod +w
${LIB}/$file 2>/dev
/null
474 chmod a
+r
${LIB}/$file 2>/dev
/null
477 if [ -r ${LIB}/$file ]; then
478 echo Fixing
$file, definition of statsswtch
479 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.
sed
480 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
481 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
486 # Fix an error in this file: a missing semi-colon at the end of the nodeent
487 # structure definition.
488 file=netdnet
/dnetdb.h
489 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
490 mkdir
${LIB}/netdnet
2>/dev
/null
491 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
492 chmod +w
${LIB}/$file 2>/dev
/null
493 chmod a
+r
${LIB}/$file 2>/dev
/null
496 if [ -r ${LIB}/$file ]; then
497 echo Fixing
$file, definition of nodeent
498 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.
sed
499 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
500 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
505 # Check for bad #ifdef line (in Ultrix 4.1)
507 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
508 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
509 chmod +w
${LIB}/$file 2>/dev
/null
510 chmod a
+r
${LIB}/$file 2>/dev
/null
513 if [ -r ${LIB}/$file ]; then
514 echo Fixing
$file, bad \
#ifdef line
515 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.
sed
516 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
517 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
522 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
523 # Only needed if commenting out junk after #endif.
525 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
526 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
527 chmod +w
${LIB}/$file 2>/dev
/null
528 chmod a
+r
${LIB}/$file 2>/dev
/null
531 if [ -r ${LIB}/$file ]; then
532 echo Fixing
$file, nested comments
533 sed -e 's/#endif.*/#endif/' ${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 superfluous `static' (in Ultrix 4.2)
542 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
543 mkdir
${LIB}/machine
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
550 echo Fixing
$file, superfluous static
551 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${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
556 # This file has an alternative name, mips/cpu.h. Fix that name, too.
557 if cmp machine
/cpu.h mips
/cpu.h
> /dev
/null
2>& 1; then
558 mkdir
${LIB}/mips
2>&-
559 ln ${LIB}/$file ${LIB}/mips
/cpu.h
564 # Incorrect sprintf declaration in X11/Xmu.h
566 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
567 mkdir
${LIB}/X11
2>/dev
/null
568 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
569 chmod +w
${LIB}/$file 2>/dev
/null
570 chmod a
+r
${LIB}/$file 2>/dev
/null
573 if [ -r ${LIB}/$file ]; then
574 echo Fixing
$file sprintf declaration
575 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
576 extern char * sprintf();\
577 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.
sed
578 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
579 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
584 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
585 # (It's not clear whether the right file name is this or X11/Xmu.h.)
587 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
588 mkdir
${LIB}/X11
/Xmu
2>/dev
/null
589 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
590 chmod +w
${LIB}/$file 2>/dev
/null
591 chmod a
+r
${LIB}/$file 2>/dev
/null
594 if [ -r ${LIB}/$file ]; then
595 echo Fixing
$file sprintf declaration
596 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
597 extern char * sprintf();\
598 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.
sed
599 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
600 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
605 # Check for missing ';' in struct
607 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
608 mkdir
${LIB}/netinet
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
611 chmod a
+r
${LIB}/$file 2>/dev
/null
614 if [ -r ${LIB}/$file ]; then
616 sed -e '/^struct/,/^};/s/}$/};/' ${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 the CAT macro in SunOS memvar.h.
624 file=pixrect
/memvar.h
625 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
626 mkdir
${LIB}/pixrect
2>/dev
/null
627 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
628 chmod +w
${LIB}/$file 2>/dev
/null
629 chmod a
+r
${LIB}/$file 2>/dev
/null
632 if [ -r ${LIB}/$file ]; then
634 sed -e '/^#define.CAT(a,b)/ i\
636 #define CAT(a,b) a##b\
638 /^#define.CAT(a,b)/ a\
640 ' ${LIB}/$file > ${LIB}/${file}.
sed
641 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
642 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
647 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
649 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
650 mkdir
${LIB}/rpcsvc
2>/dev
/null
651 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
652 chmod +w
${LIB}/$file 2>/dev
/null
653 chmod a
+r
${LIB}/$file 2>/dev
/null
656 if [ -r ${LIB}/$file ]; then
658 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.
sed
659 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
660 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
665 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
667 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
668 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
669 chmod +w
${LIB}/$file 2>/dev
/null
670 chmod a
+r
${LIB}/$file 2>/dev
/null
673 if [ -r ${LIB}/$file ]; then
675 sed -e 's/int abort/void abort/g' \
676 -e 's/int free/void free/g' \
677 -e 's/char \* calloc/void \* calloc/g' \
678 -e 's/char \* malloc/void \* malloc/g' \
679 -e 's/char \* realloc/void \* realloc/g' \
680 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.
sed
681 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
682 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
687 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
689 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
690 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
691 chmod +w
${LIB}/$file 2>/dev
/null
692 chmod a
+r
${LIB}/$file 2>/dev
/null
695 if [ -r ${LIB}/$file ]; then
697 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
698 -e 's/int[ ][ ]*free/void free/g' \
699 ${LIB}/$file > ${LIB}/${file}.
sed
700 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
701 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
707 # Fix bogus comment in <locale.h> on SunOS 4.1.
709 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
710 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
711 chmod +w
${LIB}/$file 2>/dev
/null
712 chmod a
+r
${LIB}/$file 2>/dev
/null
715 if [ -r ${LIB}/$file ]; then
717 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.
sed
718 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
719 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
724 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
725 file=hsfs
/hsfs_spec.h
726 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
727 mkdir
${LIB}/hsfs
2>/dev
/null
728 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
729 chmod +w
${LIB}/$file 2>/dev
/null
730 chmod a
+r
${LIB}/$file 2>/dev
/null
733 if [ -r ${LIB}/$file ]; then
735 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
736 ${LIB}/$file > ${LIB}/${file}.
sed
737 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
738 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
743 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
745 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
746 mkdir
${LIB}/hsfs
2>/dev
/null
747 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
748 chmod +w
${LIB}/$file 2>/dev
/null
749 chmod a
+r
${LIB}/$file 2>/dev
/null
752 if [ -r ${LIB}/$file ]; then
754 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
755 ${LIB}/$file > ${LIB}/${file}.
sed
756 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
757 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
762 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
764 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
765 mkdir
${LIB}/hsfs
2>/dev
/null
766 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
767 chmod +w
${LIB}/$file 2>/dev
/null
768 chmod a
+r
${LIB}/$file 2>/dev
/null
771 if [ -r ${LIB}/$file ]; then
773 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
774 ${LIB}/$file > ${LIB}/${file}.
sed
775 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
776 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
781 # Incorrect #include in Sony News-OS 3.2.
782 file=machine
/machparam.h
783 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
784 mkdir
${LIB}/machine
2>/dev
/null
785 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
786 chmod +w
${LIB}/$file 2>/dev
/null
787 chmod a
+r
${LIB}/$file 2>/dev
/null
790 if [ -r ${LIB}/$file ]; then
791 echo Fixing
$file, incorrect \
#include
792 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
793 ${LIB}/$file > ${LIB}/${file}.
sed
794 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
795 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
800 # Multiline comment after typedef on IRIX 4.0.1.
802 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
803 mkdir
${LIB}/sys
2>/dev
/null
804 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
805 chmod +w
${LIB}/$file 2>/dev
/null
806 chmod a
+r
${LIB}/$file 2>/dev
/null
809 if [ -r ${LIB}/$file ]; then
810 echo Fixing
$file, comment
in the middle of \
#ifdef
811 sed -e 's@type of the result@type of the result */@' \
812 -e 's@of the sizeof@/* of the sizeof@' \
813 ${LIB}/$file > ${LIB}/${file}.
sed
814 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
815 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
820 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
821 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
822 # many other systems have similar text but correct versions of the file.
823 # To ensure only Sun's is fixed, we grep for a likely unique string.
825 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev
/null
; then
826 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
827 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
828 chmod +w
${LIB}/$file 2>/dev
/null
829 chmod a
+r
${LIB}/$file 2>/dev
/null
831 if [ -r ${LIB}/$file ]; then
833 cat > ${LIB}/$file << EOF
834 /* This file was generated by fixincludes */
839 extern void *memccpy();
840 extern void *memchr();
841 extern void *memcpy();
842 extern void *memset();
844 extern char *memccpy();
845 extern char *memchr();
846 extern char *memcpy();
847 extern char *memset();
848 #endif /* __STDC__ */
852 #endif /* __memory_h__ */
857 # parameters not const on DECstation Ultrix V4.0.
859 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
860 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
861 chmod +w
${LIB}/$file 2>/dev
/null
862 chmod a
+r
${LIB}/$file 2>/dev
/null
865 if [ -r ${LIB}/$file ]; then
866 echo Fixing
$file, non-const arg
867 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
868 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
869 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
870 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
871 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
872 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
873 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
874 ${LIB}/$file > ${LIB}/${file}.
sed
875 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
876 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
881 # parameters conflict with C++ new on rs/6000
883 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
884 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
885 chmod +w
${LIB}/$file 2>/dev
/null
888 if [ -r ${LIB}/$file ]; then
889 echo Fixing
$file, parameter name conflicts
890 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
891 ${LIB}/$file > ${LIB}/${file}.
sed
892 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
893 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
898 # Don't use or define the name va_list in stdio.h.
899 # This is for ANSI and also to interoperate properly with gvarargs.h.
901 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
902 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
903 chmod +w
${LIB}/$file 2>/dev
/null
904 chmod a
+r
${LIB}/$file 2>/dev
/null
907 if [ -r ${LIB}/$file ]; then
908 echo Fixing
$file, use of va_list
909 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
910 (echo "#define __need___va_list"
911 echo "#include <stdarg.h>") > ${LIB}/${file}.
sed
912 # Use __gnuc_va_list in arg types in place of va_list.
913 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
914 # trailing parentheses and semicolon save all other systems from this.
915 # Define __va_list__ (something harmless and unused) instead of va_list.
916 # Don't claim to have defined va_list.
917 sed -e 's@ va_list @ __gnuc_va_list @' \
918 -e 's@ va_list)@ __gnuc_va_list)@' \
919 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
920 -e 's@ va_list@ __va_list__@' \
921 -e 's@\*va_list@*__va_list__@' \
922 -e 's@VA_LIST@DUMMY_VA_LIST@' \
923 ${LIB}/$file >> ${LIB}/${file}.
sed
925 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
926 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
931 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
933 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
934 if grep -s ULTRIX
$file; then
935 echo "/* This file intentionally left blank. */" > $LIB/$file
939 # parameter to atof not const on DECstation Ultrix V4.0.
940 # also get rid of bogus inline definitions in HP-UX 8.0
942 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
943 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
944 chmod +w
${LIB}/$file 2>/dev
/null
945 chmod a
+r
${LIB}/$file 2>/dev
/null
948 if [ -r ${LIB}/$file ]; then
949 echo Fixing
$file, non-const arg
950 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
951 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
952 -e 's@inline double abs(double d) { return fabs(d); }@@' \
953 ${LIB}/$file > ${LIB}/${file}.
sed
954 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
955 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
960 # In limits.h, put #ifndefs around things that are supposed to be defined
961 # in float.h to avoid redefinition errors if float.h is included first.
963 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
964 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
965 chmod +w
${LIB}/$file 2>/dev
/null
966 chmod a
+r
${LIB}/$file 2>/dev
/null
969 if [ -r ${LIB}/$file ]; then
971 sed -e '/[ ]FLT_MIN[ ]/i\
973 -e '/[ ]FLT_MIN[ ]/a\
975 -e '/[ ]FLT_MAX[ ]/i\
977 -e '/[ ]FLT_MAX[ ]/a\
979 -e '/[ ]FLT_DIG[ ]/i\
981 -e '/[ ]FLT_DIG[ ]/a\
983 -e '/[ ]DBL_MIN[ ]/i\
985 -e '/[ ]DBL_MIN[ ]/a\
987 -e '/[ ]DBL_MAX[ ]/i\
989 -e '/[ ]DBL_MAX[ ]/a\
991 -e '/[ ]DBL_DIG[ ]/i\
993 -e '/[ ]DBL_DIG[ ]/a\
995 ${LIB}/$file > ${LIB}/${file}.
sed
996 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
997 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
998 echo Deleting
${LIB}/$file\
; no fixes were needed.
1003 # These two files on SunOS 4 are included by other files
1004 # in the same directory, using "...". So we must make sure they exist
1005 # in the same directory as the other fixed files.
1006 if [ -r ${INPUT}/multimedia
/audio_errno.h
]
1008 ln -s ${INPUT}/multimedia
/audio_errno.h
${LIB}/multimedia
2>/dev
/null
1010 if [ -r ${INPUT}/multimedia
/audio_hdr.h
]
1012 ln -s ${INPUT}/multimedia
/audio_hdr.h
${LIB}/multimedia
2>/dev
/null
1015 echo 'Removing unneeded directories:'
1017 files
=`find . -type d -print | sort -r`
1018 for file in $files; do
1019 rmdir $LIB/$file > /dev
/null
2>&1
1023 echo 'Making internal symbolic non-directory links'
1025 files
=`find . -type l -print`
1026 for file in $files; do
1027 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1028 if expr "$dest" : '[^/].*' > /dev
/null
; then
1029 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1030 if [ -f $target ]; then
1031 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1037 echo 'Cleaning up DONE files.'
1039 find .
-name DONE
-exec rm -f {} ';'