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 containing the original header files.
9 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
10 INPUT=${2-${INPUT-/usr/include}}
12 # Directory in which to store the results.
13 LIB=${1?"fixincludes: output directory not specified"}
15 # Define PWDCMD as a command to use to get the working dir
16 # in the form that we want.
20 # On an Apollo, discard everything before `/usr'.
21 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
33 # Make LIB absolute only if needed to avoid problems with the amd.
38 cd $LIB; LIB=`${PWDCMD}`
42 # Fail if no arg to specify a directory for the output.
44 then echo fixincludes: no output directory specified
48 echo Building fixed headers in ${LIB}
50 # Determine whether this system has symbolic links.
51 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
52 rm -f $LIB/ShouldNotExist
54 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
55 rm -f /tmp/ShouldNotExist
61 echo Finding directories and links to directories
63 # Find all directories and all symlinks that point to directories.
64 # Put the list in $files.
65 # Each time we find a symlink, add it to newdirs
66 # so that we do another find within the dir the link points to.
67 # Note that $files may have duplicates in it;
68 # later parts of this file are supposed to ignore them.
71 while [ -n "$dirs" ] && [ $levels -gt 0 ]
73 levels=`expr $levels - 1`
77 echo " Searching $INPUT/$d"
83 # Find all directories under $d, relative to $d, excluding $d itself.
84 files="$files `find $d -type d -print | \
85 sed -e '/\/\.$/d' -e '/^\.$/d'`"
86 # Find all links to directories.
87 # Using `-exec test -d' in find fails on some systems,
88 # and trying to run test via sh fails on others,
89 # so this is the simplest alternative left.
90 # First find all the links, then test each one.
93 theselinks=`find $d -type l -print`
94 for d1 in $theselinks --dummy--
96 # If the link points to a directory,
97 # add that dir to $newdirs
101 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
103 newdirs="$newdirs $d1"
113 echo "All directories (including links to directories):"
116 for file in $files; do
118 if [ ! -d $LIB/$file ]
119 then mkdir $LIB/$file
124 # treetops gets an alternating list
125 # of old directories to copy
126 # and the new directories to copy to.
127 treetops="${INPUT} ${LIB}"
130 echo 'Making symbolic directory links'
131 for file in $files; do
132 dest=`ls -ld $file | sed -n 's/.*-> //p'`
135 # In case $dest is relative, get to $file's dir first.
137 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
138 # Check that the target directory exists.
139 # Redirections changed to avoid bug in sh on Ultrix.
140 (cd $dest) > /dev/null 2>&1
143 # X gets the dir that the link actually leads to.
145 # Canonicalize ${INPUT} now to minimize the time an
146 # automounter has to change the result of ${PWDCMD}.
147 cinput=`cd ${INPUT}; ${PWDCMD}`
148 # If a link points to ., make a similar link to .
149 if [ $x = ${cinput} ]; then
150 echo $file '->' . ': Making link'
151 rm -fr ${LIB}/$file > /dev/null 2>&1
152 ln -s . ${LIB}/$file > /dev/null 2>&1
153 # If link leads back into ${INPUT},
154 # make a similar link here.
155 elif expr $x : "${cinput}/.*" > /dev/null; then
156 # Y gets the actual target dir name, relative to ${INPUT}.
157 y=`echo $x | sed -n "s&${cinput}/&&p"`
158 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
160 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
161 echo $file '->' $dots$y ': Making link'
162 rm -fr ${LIB}/$file > /dev/null 2>&1
163 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
165 # If the link is to a dir $target outside ${INPUT},
166 # repoint the link at ${INPUT}/root$target
167 # and process $target into ${INPUT}/root$target
168 # treat this directory as if it actually contained the files.
169 echo $file '->' root$x ': Making link'
170 if [ -d $LIB/root$x ]
176 while [ x$dirname != x ]; do
177 component=`echo $dirname | sed -e 's|/.*$||'`
178 mkdir $component >/dev/null 2>&1
180 dirmade=$dirmade/$component
181 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
184 # Duplicate directory structure created in ${LIB}/$file in new
186 for file2 in $files; do
189 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
190 echo "Duplicating ${file}'s ${dupdir}"
201 # Get the path from ${LIB} to $file, accounting for symlinks.
202 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
203 libabs=`cd ${LIB}; ${PWDCMD}`
204 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
205 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
206 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
207 rm -fr ${LIB}/$file > /dev/null 2>&1
208 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
209 treetops="$treetops $x ${LIB}/root$x"
220 while [ $# != 0 ]; do
221 # $1 is an old directory to copy, and $2 is the new directory to copy to.
224 # The same dir can appear more than once in treetops.
225 # There's no need to scan it more than once.
231 echo Fixing directory $1 into $2
232 # Check .h files which are symlinks as well as those which are files.
233 # A link to a header file will not be processed by anything but this.
235 files=`find . -name '*.h' \( -type f -o -type l \) -print`
237 files=`find . -name '*.h' -type f -print`
239 echo Checking header files
241 # Note that BSD43_* are used on recent MIPS systems.
242 for file in $files; do
243 # This call to egrep is essential, since checking a file with egrep
244 # is much faster than actually trying to fix it.
245 # It is also essential that most files *not* match!
246 # Thus, matching every #endif is unacceptable.
247 # But the argument to egrep must be kept small, or many versions of egrep
248 # won't be able to handle it.
250 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
251 # following #else or #endif because some buggy egreps think [^/] matches
252 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
254 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
255 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
256 # in this pattern lacks `d' and `l'; this means we don't worry about
257 # identifiers starting with `d' or `l'. This is OK, since none of the
258 # identifiers below start with `d' or `l'. It also greatly improves
259 # performance, since many files contain lines of the form `#if ... defined ...'
261 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
262 if [ -r $file ]; then
263 cp $file $2/$file >/dev/null 2>&1 \
264 || echo "Can't copy $file"
267 # Here is how the sed commands in braces work.
268 # (It doesn't work to put the comments inside the sed commands.)
269 # Surround each word with spaces, to simplify matching below.
270 # ANSIfy each pre-ANSI machine-dependent symbol
271 # by surrounding it with __ __.
272 # Remove the spaces that we inserted around each word.
277 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
278 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
279 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
280 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
281 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
282 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
283 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
284 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
285 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
286 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
287 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
288 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
289 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
290 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
291 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
293 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
295 s/ bsd4\([0-9]\) / __bsd4\1__ /g
296 s/ _*host_mips / __host_mips__ /g
297 s/ _*i386 / __i386__ /g
299 s/ is68k / __is68k__ /g
300 s/ m68k / __m68k__ /g
301 s/ mc680\([0-9]\)0 / __mc680\10__ /g
302 s/ m88k / __m88k__ /g
303 s/ _*mips / __mips__ /g
304 s/ news\([0-9]*\) / __news\1__ /g
305 s/ ns32000 / __ns32000__ /g
306 s/ pdp11 / __pdp11__ /g
308 s/ sony_news / __sony_news__ /g
309 s/ sparc / __sparc__ /g
310 s/ sun\([a-z0-9]*\) / __sun\1__ /g
311 s/ tower\([_0-9]*\) / __tower\1__ /g
312 s/ u370 / __u370__ /g
313 s/ u3b\([0-9]*\) / __u3b\1__ /g
314 s/ unix / __unix__ /g
316 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
317 s/ _*R\([34]\)000 / __R\1000__ /g
318 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
320 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
322 /^#define.NULL[ ]/ i\
324 ' $2/$file > $2/$file.
325 mv $2/$file. $2/$file
326 if cmp $file $2/$file >/dev/null 2>&1 \
327 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
331 # Find any include directives that use "file".
332 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
333 dir=`echo $file | sed -e s'|/[^/]*$||'`
334 required="$required $1 $dir/$include $2/$dir/$include"
345 # Install the proper definition of the three standard types in header files
346 # that they come from.
347 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
348 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
349 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
350 chmod +w ${LIB}/$file 2>/dev/null
351 chmod a+r ${LIB}/$file 2>/dev/null
354 if [ -r ${LIB}/$file ]; then
355 echo Fixing size_t, ptrdiff_t and wchar_t in $file
357 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
358 #ifndef __SIZE_TYPE__\
359 #define __SIZE_TYPE__ long unsigned int\
362 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
363 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
364 #ifndef __PTRDIFF_TYPE__\
365 #define __PTRDIFF_TYPE__ long int\
368 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
369 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
370 #ifndef __WCHAR_TYPE__\
371 #define __WCHAR_TYPE__ int\
374 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
375 ${LIB}/$file > ${LIB}/${file}.sed
376 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
377 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
383 # Fix one other error in this file: a mismatched quote not inside a C comment.
384 file=sundev/vuid_event.h
385 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
386 mkdir ${LIB}/sundev 2>/dev/null
387 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
388 chmod +w ${LIB}/$file 2>/dev/null
389 chmod a+r ${LIB}/$file 2>/dev/null
392 if [ -r ${LIB}/$file ]; then
393 echo Fixing $file comment
394 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
395 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
396 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
401 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
402 file=sunwindow/win_cursor.h
403 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
404 # mkdir ${LIB}/sunwindow 2>/dev/null
405 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
406 chmod +w ${LIB}/$file 2>/dev/null
408 if [ -r ${LIB}/$file ]; then
410 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
411 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
412 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
416 file=sunwindow/win_lock.h
417 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
418 # mkdir ${LIB}/sunwindow 2>/dev/null
419 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
420 chmod +w ${LIB}/$file 2>/dev/null
422 if [ -r ${LIB}/$file ]; then
424 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
425 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
426 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
431 # Fix this Sun file to avoid interfering with stddef.h.
433 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
434 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
435 chmod +w ${LIB}/$file 2>/dev/null
436 chmod a+r ${LIB}/$file 2>/dev/null
439 if [ -r ${LIB}/$file ]; then
441 sed -e '/[ ]size_t.*;/i\
448 -e '/[ ]ptrdiff_t.*;/i\
449 #ifndef _GCC_PTRDIFF_T\
450 #define _GCC_PTRDIFF_T
452 -e '/[ ]ptrdiff_t.*;/a\
455 -e '/[ ]wchar_t.*;/i\
456 #ifndef _GCC_WCHAR_T\
459 -e '/[ ]wchar_t.*;/a\
461 ' ${LIB}/$file > ${LIB}/${file}.sed
462 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
463 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
468 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
471 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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
479 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
480 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
481 ${LIB}/$file > ${LIB}/${file}.sed
482 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
483 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
488 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
489 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
492 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
493 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
494 chmod +w ${LIB}/$file 2>/dev/null
495 chmod a+r ${LIB}/$file 2>/dev/null
498 if [ -r ${LIB}/$file ]; then
500 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
504 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
506 ' ${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 # Fix HP's use of ../machine/inline.h to refer to
514 # /usr/include/machine/inline.h
516 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
517 cp $file ${LIB}/$file
519 if [ -r ${LIB}/$file ] ; then
521 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
522 -e 's,"../machine/psl.h",<machine/psl.h>,' \
523 ${LIB}/$file > ${LIB}/${file}.sed
524 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
525 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
530 # Fix an error in this file: the #if says _cplusplus, not the double
531 # underscore __cplusplus that it should be
533 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
534 mkdir ${LIB}/rpcsvc 2>/dev/null
535 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
536 chmod +w ${LIB}/$file 2>/dev/null
537 chmod a+r ${LIB}/$file 2>/dev/null
540 if [ -r ${LIB}/$file ]; then
541 echo Fixing $file, __cplusplus macro
542 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
543 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
544 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
549 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
550 # structure definition.
552 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
553 mkdir ${LIB}/rpcsvc 2>/dev/null
554 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
555 chmod +w ${LIB}/$file 2>/dev/null
556 chmod a+r ${LIB}/$file 2>/dev/null
559 if [ -r ${LIB}/$file ]; then
560 echo Fixing $file, definition of statsswtch
561 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
562 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
563 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
568 # Fix an error in this file: a missing semi-colon at the end of the nodeent
569 # structure definition.
570 file=netdnet/dnetdb.h
571 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
572 mkdir ${LIB}/netdnet 2>/dev/null
573 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
574 chmod +w ${LIB}/$file 2>/dev/null
575 chmod a+r ${LIB}/$file 2>/dev/null
578 if [ -r ${LIB}/$file ]; then
579 echo Fixing $file, definition of nodeent
580 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
581 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
582 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
587 # Check for bad #ifdef line (in Ultrix 4.1)
589 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
590 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
591 chmod +w ${LIB}/$file 2>/dev/null
592 chmod a+r ${LIB}/$file 2>/dev/null
595 if [ -r ${LIB}/$file ]; then
596 echo Fixing $file, bad \#ifdef line
597 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
598 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
599 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
604 # Check for superfluous `static' (in Ultrix 4.2)
605 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
607 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
608 mkdir ${LIB}/machine 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
615 echo Fixing $file, superfluous static and broken includes of other files.
616 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
617 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
618 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
619 ${LIB}/$file > ${LIB}/${file}.sed
620 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
621 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
624 # This file has an alternative name, mips/cpu.h. Fix that name, too.
625 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
626 mkdir ${LIB}/mips 2>&-
627 # Don't remove the file first, they may be the same file!
628 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
633 # Incorrect sprintf declaration in X11/Xmu.h
635 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
636 mkdir ${LIB}/X11 2>/dev/null
637 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
638 chmod +w ${LIB}/$file 2>/dev/null
639 chmod a+r ${LIB}/$file 2>/dev/null
642 if [ -r ${LIB}/$file ]; then
643 echo Fixing $file sprintf declaration
644 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
645 extern char * sprintf();\
646 #endif /* !defined __STDC__ */,' ${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 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
654 # (It's not clear whether the right file name is this or X11/Xmu.h.)
656 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
657 mkdir ${LIB}/X11/Xmu 2>/dev/null
658 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
659 chmod +w ${LIB}/$file 2>/dev/null
660 chmod a+r ${LIB}/$file 2>/dev/null
663 if [ -r ${LIB}/$file ]; then
664 echo Fixing $file sprintf declaration
665 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
666 extern char * sprintf();\
667 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
668 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
669 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
674 # Check for missing ';' in struct
676 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
677 mkdir ${LIB}/netinet 2>/dev/null
678 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
679 chmod +w ${LIB}/$file 2>/dev/null
680 chmod a+r ${LIB}/$file 2>/dev/null
683 if [ -r ${LIB}/$file ]; then
685 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
686 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
687 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
692 # Fix the CAT macro in SunOS memvar.h.
693 file=pixrect/memvar.h
694 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
695 mkdir ${LIB}/pixrect 2>/dev/null
696 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
697 chmod +w ${LIB}/$file 2>/dev/null
698 chmod a+r ${LIB}/$file 2>/dev/null
701 if [ -r ${LIB}/$file ]; then
703 sed -e '/^#define.CAT(a,b)/ i\
705 #define CAT(a,b) a##b\
707 /^#define.CAT(a,b)/ a\
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 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
718 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
719 mkdir ${LIB}/rpcsvc 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
727 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
728 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
729 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
734 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
735 # Also wrap protection around size_t for m88k-sysv3 systems.
737 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
738 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
739 chmod +w ${LIB}/$file 2>/dev/null
740 chmod a+r ${LIB}/$file 2>/dev/null
743 if [ -r ${LIB}/$file ]; then
745 sed -e 's/int abort/void abort/g' \
746 -e 's/int free/void free/g' \
747 -e 's/char \* calloc/void \* calloc/g' \
748 -e 's/char \* malloc/void \* malloc/g' \
749 -e 's/char \* realloc/void \* realloc/g' \
750 -e 's/int exit/void exit/g' \
751 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
755 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
758 ${LIB}/$file > ${LIB}/${file}.sed
759 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
760 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
765 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
767 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
768 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
769 chmod +w ${LIB}/$file 2>/dev/null
770 chmod a+r ${LIB}/$file 2>/dev/null
773 if [ -r ${LIB}/$file ]; then
775 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
776 -e 's/int[ ][ ]*free/void free/g' \
777 ${LIB}/$file > ${LIB}/${file}.sed
778 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
779 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
784 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
785 file=hsfs/hsfs_spec.h
786 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
787 mkdir ${LIB}/hsfs 2>/dev/null
788 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
789 chmod +w ${LIB}/$file 2>/dev/null
790 chmod a+r ${LIB}/$file 2>/dev/null
793 if [ -r ${LIB}/$file ]; then
795 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
796 ${LIB}/$file > ${LIB}/${file}.
797 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
798 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
803 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
805 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
806 mkdir ${LIB}/hsfs 2>/dev/null
807 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
808 chmod +w ${LIB}/$file 2>/dev/null
809 chmod a+r ${LIB}/$file 2>/dev/null
812 if [ -r ${LIB}/$file ]; then
814 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
815 ${LIB}/$file > ${LIB}/${file}.sed
816 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
817 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
822 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
824 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
825 mkdir ${LIB}/hsfs 2>/dev/null
826 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
827 chmod +w ${LIB}/$file 2>/dev/null
828 chmod a+r ${LIB}/$file 2>/dev/null
831 if [ -r ${LIB}/$file ]; then
833 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
834 ${LIB}/$file > ${LIB}/${file}.sed
835 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
836 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
841 # Incorrect #include in Sony News-OS 3.2.
842 file=machine/machparam.h
843 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
844 mkdir ${LIB}/machine 2>/dev/null
845 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
846 chmod +w ${LIB}/$file 2>/dev/null
847 chmod a+r ${LIB}/$file 2>/dev/null
850 if [ -r ${LIB}/$file ]; then
851 echo Fixing $file, incorrect \#include
852 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
853 ${LIB}/$file > ${LIB}/${file}.
854 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
855 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
860 # Multiline comment after typedef on IRIX 4.0.1.
862 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
863 mkdir ${LIB}/sys 2>/dev/null
864 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
865 chmod +w ${LIB}/$file 2>/dev/null
866 chmod a+r ${LIB}/$file 2>/dev/null
869 if [ -r ${LIB}/$file ]; then
870 echo Fixing $file, comment in the middle of \#ifdef
871 sed -e 's@type of the result@type of the result */@' \
872 -e 's@of the sizeof@/* of the sizeof@' \
873 ${LIB}/$file > ${LIB}/${file}.sed
874 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
875 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
880 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
881 # header file, which embeds // comments inside multi-line /* */
882 # comments. If this looks like the IRIX header file, we refix it by
883 # just throwing away the // comments.
885 if [ -r ${LIB}/$file ]; then
886 if egrep indigo.esd ${LIB}/$file > /dev/null; then
887 echo Fixing $file, overeager sed script
889 sed -e 's|//.*$||g' $file > ${LIB}/$file
890 chmod +w ${LIB}/$file 2>/dev/null
891 chmod a+r ${LIB}/$file 2>/dev/null
895 # Some IRIX header files contains the string "//"
896 for file in elf_abi.h elf.h; do
897 if [ -r ${LIB}/$file ]; then
898 echo Fixing $file, overeager sed script
899 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
900 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
901 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
907 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
908 # previous definition.
910 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
911 mkdir ${LIB}/rpc 2>/dev/null
912 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
913 chmod +w ${LIB}/$file 2>/dev/null
914 chmod a+r ${LIB}/$file 2>/dev/null
917 if [ -r ${LIB}/$file ]; then
918 echo Fixing $file, undefined type
919 sed -e '/authdes_create.*struct sockaddr/i\
922 ${LIB}/$file > ${LIB}/$file.sed
923 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
924 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
929 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
932 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
933 mkdir ${LIB}/rpc 2>/dev/null
934 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
935 chmod +w ${LIB}/$file 2>/dev/null
936 chmod a+r ${LIB}/$file 2>/dev/null
939 if [ -r ${LIB}/$file ]; then
940 echo Fixing $file, undefined type
941 sed -e '/xdrstdio_create.*struct __file_s/i\
944 ${LIB}/$file > ${LIB}/$file.sed
945 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
946 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
951 # Same problem with a file from SunOS 4.1.3 : a header file containing
952 # the string "//" embedded in "/**/"
953 file=sbusdev/audiovar.h
954 if [ -r ${LIB}/$file ]; then
955 echo Fixing $file, overeager sed script
957 sed -e 's|//.*$||g' $file > ${LIB}/$file
958 chmod +w ${LIB}/$file 2>/dev/null
959 chmod a+r ${LIB}/$file 2>/dev/null
962 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
963 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
964 # many other systems have similar text but correct versions of the file.
965 # To ensure only Sun's is fixed, we grep for a likely unique string.
967 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
968 if [ ! -r ${LIB}/$file ]; then
969 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
970 chmod +w ${LIB}/$file 2>/dev/null
971 chmod a+r ${LIB}/$file 2>/dev/null
973 if [ -r ${LIB}/$file ]; then
975 cat > ${LIB}/$file << EOF
976 /* This file was generated by fixincludes */
981 extern void *memccpy();
982 extern void *memchr();
983 extern void *memcpy();
984 extern void *memset();
986 extern char *memccpy();
987 extern char *memchr();
988 extern char *memcpy();
989 extern char *memset();
990 #endif /* __STDC__ */
994 #endif /* __memory_h__ */
999 # parameters not const on DECstation Ultrix V4.0.
1001 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1002 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1003 chmod +w ${LIB}/$file 2>/dev/null
1004 chmod a+r ${LIB}/$file 2>/dev/null
1007 if [ -r ${LIB}/$file ]; then
1008 echo Fixing $file, non-const arg
1009 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1010 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1011 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1012 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1013 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1014 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1015 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1016 ${LIB}/$file > ${LIB}/${file}.sed
1017 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1018 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1023 # parameters conflict with C++ new on rs/6000
1024 for file in stdio.h unistd.h ; do
1025 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1026 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1027 chmod +w ${LIB}/$file 2>/dev/null
1030 if [ -r ${LIB}/$file ]; then
1031 echo Fixing $file, parameter name conflicts
1032 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1033 ${LIB}/$file > ${LIB}/${file}.sed
1034 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1035 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1041 # function class(double x) conflicts with C++ keyword on rs/6000
1043 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1044 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1045 chmod +w ${LIB}/$file 2>/dev/null
1046 chmod a+r ${LIB}/$file 2>/dev/null
1049 if [ -r ${LIB}/$file ]; then
1050 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1052 sed -e '/class[(]/i\
1057 ' ${LIB}/$file > ${LIB}/${file}.sed
1058 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1059 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1065 # Wrong fchmod prototype on RS/6000.
1067 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1068 mkdir ${LIB}/sys 2>/dev/null
1069 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1070 chmod +w ${LIB}/$file 2>/dev/null
1071 chmod a+r ${LIB}/$file 2>/dev/null
1074 if [ -r ${LIB}/$file ]; then
1075 echo Fixing $file, fchmod prototype
1076 sed -e 's/fchmod(char \*/fchmod(int/' \
1077 ${LIB}/$file > ${LIB}/$file.sed
1078 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1079 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1084 # There are several name conflicts with C++ reserved words in X11
1085 # header files. These are fixed in some versions, so don't do the
1086 # fixes if we find __cplusplus in the file. These were found on the
1089 # class in X11/ShellP.h
1091 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1092 mkdir ${LIB}/sys 2>/dev/null
1093 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1094 chmod +w ${LIB}/$file 2>/dev/null
1095 chmod a+r ${LIB}/$file 2>/dev/null
1098 if [ -r ${LIB}/$file ]; then
1099 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1102 echo Fixing $file, field class
1103 sed -e '/char [*]class;/i\
1108 -e '/char [*]class;/a\
1110 ' ${LIB}/$file > ${LIB}/${file}.sed
1111 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1113 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1117 # new in Xm/Traversal.h
1119 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1120 mkdir ${LIB}/sys 2>/dev/null
1121 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1122 chmod +w ${LIB}/$file 2>/dev/null
1123 chmod a+r ${LIB}/$file 2>/dev/null
1126 if [ -r ${LIB}/$file ]; then
1127 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1130 echo Fixing $file, uses of new
1131 sed -e '/Widget old, new;/i\
1136 -e '/Widget old, new;/a\
1139 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1140 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1142 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1146 # class in Xm/BaseClassI.h
1147 file=Xm/BaseClassI.h
1148 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1149 mkdir ${LIB}/sys 2>/dev/null
1150 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1151 chmod +w ${LIB}/$file 2>/dev/null
1152 chmod a+r ${LIB}/$file 2>/dev/null
1155 if [ -r ${LIB}/$file ]; then
1156 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1159 echo Fixing $file, prototype parameter name
1160 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1161 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1163 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1169 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1170 # Note that version 3 of the NeXT system has wait.h in a different directory,
1171 # so that this code won't do anything. But wait.h in version 3 has a
1172 # conditional, so it doesn't need this fix. So everything is okay.
1174 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1175 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1176 chmod +w ${LIB}/$file 2>/dev/null
1179 if [ -r ${LIB}/$file ] \
1180 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1181 echo Fixing $file, bad wait formal
1182 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1183 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1184 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1189 # Don't use or define the name va_list in stdio.h.
1190 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1192 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1193 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1194 chmod +w ${LIB}/$file 2>/dev/null
1195 chmod a+r ${LIB}/$file 2>/dev/null
1198 if [ -r ${LIB}/$file ]; then
1199 echo Fixing $file, use of va_list
1200 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1201 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1202 touch ${LIB}/${file}.sed
1204 (echo "#define __need___va_list"
1205 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1207 # Use __gnuc_va_list in arg types in place of va_list.
1208 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1209 # trailing parentheses and semicolon save all other systems from this.
1210 # Define __va_list__ (something harmless and unused) instead of va_list.
1211 # Don't claim to have defined va_list.
1212 sed -e 's@ va_list @ __gnuc_va_list @' \
1213 -e 's@ va_list)@ __gnuc_va_list)@' \
1214 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1215 -e 's@ va_list@ __va_list__@' \
1216 -e 's@\*va_list@*__va_list__@' \
1217 -e 's@ __va_list)@ __gnuc_va_list)@' \
1218 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1219 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1220 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1221 -e 's@_Va_LIST@_VA_LIST@' \
1222 ${LIB}/$file >> ${LIB}/${file}.sed
1224 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1225 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1230 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1232 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1233 if grep -s ULTRIX $file; then
1234 echo "/* This file intentionally left blank. */" > $LIB/$file
1238 # parameter to atof not const on DECstation Ultrix V4.0.
1239 # also get rid of bogus inline definitions in HP-UX 8.0
1241 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1242 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1243 chmod +w ${LIB}/$file 2>/dev/null
1244 chmod a+r ${LIB}/$file 2>/dev/null
1247 if [ -r ${LIB}/$file ]; then
1248 echo Fixing $file, non-const arg
1249 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1250 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1251 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1252 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1253 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1254 ${LIB}/$file > ${LIB}/${file}.sed
1255 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1256 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1261 # Avoid nested comments on Ultrix 4.3.
1263 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1264 mkdir ${LIB}/rpc 2>/dev/null
1265 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1266 chmod +w ${LIB}/$file 2>/dev/null
1267 chmod a+r ${LIB}/$file 2>/dev/null
1270 if [ -r ${LIB}/$file ]; then
1271 echo Fixing $file, nested comment
1272 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1273 ${LIB}/$file > ${LIB}/$file.sed
1274 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1275 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1280 # This file in RISC/os uses /**/ to concatenate two tokens.
1282 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1283 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1284 chmod +w ${LIB}/$file 2>/dev/null
1285 chmod a+r ${LIB}/$file 2>/dev/null
1287 if [ -r ${LIB}/$file ]; then
1288 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1289 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1290 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1296 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1297 mkdir ${LIB}/rpc 2>/dev/null
1298 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1299 chmod +w ${LIB}/$file 2>/dev/null
1300 chmod a+r ${LIB}/$file 2>/dev/null
1303 if [ -r ${LIB}/$file ]; then
1304 echo Fixing $file, nested comment
1305 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1306 ${LIB}/$file > ${LIB}/$file.sed
1307 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1308 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1313 # In limits.h, put #ifndefs around things that are supposed to be defined
1314 # in float.h to avoid redefinition errors if float.h is included first.
1315 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1316 # multi line comments and the inserted #endif winds up inside the
1317 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1318 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1319 # are there, and we do not add them ourselves.
1320 for file in limits.h sys/limits.h; do
1321 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1322 mkdir ${LIB}/sys 2>/dev/null
1323 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1324 chmod +w ${LIB}/$file 2>/dev/null
1325 chmod a+r ${LIB}/$file 2>/dev/null
1328 if [ -r ${LIB}/$file ]; then
1329 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1333 sed -e '/[ ]FLT_MIN[ ]/i\
1336 -e '/[ ]FLT_MIN[ ]/a\
1339 -e '/[ ]FLT_MAX[ ]/i\
1342 -e '/[ ]FLT_MAX[ ]/a\
1345 -e '/[ ]FLT_DIG[ ]/i\
1348 -e '/[ ]FLT_DIG[ ]/a\
1351 -e '/[ ]DBL_MIN[ ]/i\
1354 -e '/[ ]DBL_MIN[ ]/a\
1357 -e '/[ ]DBL_MAX[ ]/i\
1360 -e '/[ ]DBL_MAX[ ]/a\
1363 -e '/[ ]DBL_DIG[ ]/i\
1366 -e '/[ ]DBL_DIG[ ]/a\
1369 ${LIB}/$file > ${LIB}/${file}.sed
1370 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1372 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1373 echo Deleting ${LIB}/$file\; no fixes were needed.
1379 # In math.h, put #ifndefs around things that might be defined in a gcc
1380 # specific math-*.h file.
1382 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1383 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1384 chmod +w ${LIB}/$file 2>/dev/null
1385 chmod a+r ${LIB}/$file 2>/dev/null
1388 if [ -r ${LIB}/$file ]; then
1390 sed -e '/define[ ]HUGE_VAL[ ]/i\
1393 -e '/define[ ]HUGE_VAL[ ]/a\
1396 ${LIB}/$file > ${LIB}/${file}.sed
1397 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1399 # In addition, copy the definition of DBL_MAX from float.h
1400 # if math.h requires one. The Lynx math.h requires it.
1401 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1402 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1405 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1406 if [ "$dbl_max_def" != "" ]; then
1407 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1408 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1409 ${LIB}/$file > ${LIB}/${file}.sed
1410 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1415 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1416 echo Deleting ${LIB}/$file\; no fixes were needed.
1421 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1423 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1424 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1425 chmod +w ${LIB}/$file 2>/dev/null
1426 chmod a+r ${LIB}/$file 2>/dev/null
1429 if [ -r ${LIB}/$file ]; then
1431 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1432 ${LIB}/$file > ${LIB}/${file}.sed
1433 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1434 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1439 # Correct the return type for strlen in string.h on Lynx.
1440 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1442 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1443 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1444 chmod +w ${LIB}/$file 2>/dev/null
1445 chmod a+r ${LIB}/$file 2>/dev/null
1448 if [ -r ${LIB}/$file ]; then
1450 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1451 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1452 ${LIB}/$file > ${LIB}/${file}.sed
1453 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1454 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1459 # Delete the '#define void int' line from curses.h on Lynx
1461 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1462 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1463 chmod +w ${LIB}/$file 2>/dev/null
1464 chmod a+r ${LIB}/$file 2>/dev/null
1467 if [ -r ${LIB}/$file ]; then
1469 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
1470 ${LIB}/$file > ${LIB}/${file}.sed
1471 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1472 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1477 # For C++, avoid any typedef or macro definition of bool, and use the
1478 # built in type instead.
1479 for files in curses.h; do
1480 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1481 if [ ! -r ${LIB}/$file ]; then
1482 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1483 chmod +w ${LIB}/$file 2>/dev/null
1484 chmod a+r ${LIB}/$file 2>/dev/null
1488 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1489 #ifndef __cplusplus'\
1490 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1492 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/i\
1493 #ifndef __cplusplus'\
1494 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/a\
1496 ${LIB}/$file > ${LIB}/${file}.sed
1497 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1498 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1504 # Fix incorrect S_IF* definitions on m88k-sysv3.
1506 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1507 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1508 chmod +w ${LIB}/$file 2>/dev/null
1509 chmod a+r ${LIB}/$file 2>/dev/null
1512 if [ -r ${LIB}/$file ]; then
1514 sed -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1515 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1516 ${LIB}/$file > ${LIB}/${file}.sed
1517 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1518 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1523 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1524 for file in stdio.h stdlib.h; do
1525 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1526 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1527 chmod +w ${LIB}/$file 2>/dev/null
1528 chmod a+r ${LIB}/$file 2>/dev/null
1531 if [ -r ${LIB}/$file ]; then
1532 echo Fixing $file, getopt declaration
1533 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
1534 ${LIB}/$file > ${LIB}/${file}.sed
1535 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1536 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1542 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1543 # need to fix some additional files. This is the same test for ISC that
1545 if test -d /etc/conf/kconfig.d \
1546 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1547 echo "Fixing ISC __STDC__ goof in several files..."
1548 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1550 if test -r ${LIB}/$name; then
1555 # On Interactive 2.2, certain traditional Unix definitions
1556 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1557 # defined, not just if _POSIX_SOURCE is defined. This makes it
1558 # impossible to compile any nontrivial program except with -posix.
1560 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1561 < $file > ${LIB}/$name.
1562 mv ${LIB}/$name. ${LIB}/$name
1565 echo "Fixing ISC fmod declaration"
1566 # This one's already been fixed for other things.
1568 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1571 echo "Fixing nested comments in ISC <sys/limits.h>"
1573 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1574 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1577 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1578 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1579 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1580 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1582 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1583 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1584 chmod +w ${LIB}/$file 2>/dev/null
1585 chmod a+r ${LIB}/$file 2>/dev/null
1588 if [ -r ${LIB}/$file ]; then
1589 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1590 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1591 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1597 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1598 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1599 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1601 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1602 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1603 chmod +w ${LIB}/$file 2>/dev/null
1604 chmod a+r ${LIB}/$file 2>/dev/null
1607 if [ -r ${LIB}/$file ]; then
1608 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1609 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1610 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1616 # math.h on SunOS 4 puts the declaration of matherr before the definition
1617 # of struct exception, so the prototype (added by fixproto) causes havoc.
1619 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1620 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1621 chmod +w ${LIB}/$file 2>/dev/null
1622 chmod a+r ${LIB}/$file 2>/dev/null
1625 if [ -r ${LIB}/$file ]; then
1626 echo Fixing $file, matherr declaration
1627 sed -e '/^struct exception/,$b' \
1631 ${LIB}/$file > ${LIB}/${file}.sed
1632 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1633 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1638 # assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1639 # is defined on HP/UX.
1641 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1642 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1643 chmod +w ${LIB}/$file 2>/dev/null
1644 chmod a+r ${LIB}/$file 2>/dev/null
1647 if [ -r ${LIB}/$file ]; then
1648 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
1649 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
1653 echo '#ifdef __cplusplus
1655 #endif' > ${LIB}/${file}.sed
1656 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1657 echo '#ifdef __cplusplus
1659 #endif' >> ${LIB}/${file}.sed
1660 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1661 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1667 # check for broken assert.h that needs stdio.h or stdlib.h
1669 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1670 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1671 chmod +w ${LIB}/$file 2>/dev/null
1672 chmod a+r ${LIB}/$file 2>/dev/null
1675 if [ -r ${LIB}/$file ]; then
1676 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
1677 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1680 echo "Fixing $file (needs stdio.h)"
1681 echo '#include <stdio.h>' >>${LIB}/$file
1684 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
1685 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
1686 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1689 echo "Fixing $file (needs stdlib.h)"
1690 echo '#include <stdlib.h>' >>${LIB}/$file
1693 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1698 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1700 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1701 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1702 chmod +w ${LIB}/$file 2>/dev/null
1703 chmod a+r ${LIB}/$file 2>/dev/null
1706 if [ -r ${LIB}/$file ]; then
1707 echo Fixing $file, sbrk declaration
1708 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
1709 ${LIB}/$file > ${LIB}/${file}.sed
1710 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1711 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1716 # This file on SunOS 4 has a very large macro. When the sed loop
1717 # tries pull it in, it overflows the pattern space size of the SunOS
1718 # sed (GNU sed does not have this problem). Since the file does not
1719 # require fixing, we remove it from the fixed directory.
1720 file=sundev/ipi_error.h
1721 if [ -r ${LIB}/$file ]; then
1722 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1726 # Put cpp wrappers around these include files to avoid redeclaration
1727 # errors during multiple inclusion on m88k-tektronix-sysv3.
1728 for file in time.h sys/time.h ; do
1729 if egrep '#ifndef' $file >/dev/null 2>&1; then
1732 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1733 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1734 chmod +w ${LIB}/$file 2>/dev/null
1736 if [ -r ${LIB}/$file ]; then
1737 echo Fixing $file, to protect against multiple inclusion.
1738 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
1739 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
1740 echo "#define __GCC_GOT_${cpp_wrapper}_"
1742 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
1743 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
1748 # Fix fcntl prototype in fcntl.h on LynxOS.
1750 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1751 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1752 chmod +w ${LIB}/$file 2>/dev/null
1753 chmod a+r ${LIB}/$file 2>/dev/null
1756 if [ -r ${LIB}/$file ]; then
1757 echo Fixing $file, fcntl declaration
1758 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
1759 ${LIB}/$file > ${LIB}/${file}.sed
1760 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1761 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1766 # This loop does not appear to do anything, because it uses file
1767 # rather than $file when setting target. It also appears to be
1768 # unnecessary, since the main loop processes symbolic links.
1770 # echo 'Making internal symbolic non-directory links'
1772 # files=`find . -type l -print`
1773 # for file in $files; do
1774 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
1775 # if expr "$dest" : '[^/].*' > /dev/null; then
1776 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1777 # if [ -f $target ]; then
1778 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
1784 # Make sure that any include files referenced using double quotes
1785 # exist in the fixed directory. This comes last since otherwise
1786 # we might end up deleting some of these files "because they don't
1790 while [ $# != 0 ]; do
1792 while [ $# != 0 ]; do
1793 # $1 is the directory to copy from, $2 is the unfixed file,
1794 # $3 is the fixed file name.
1797 if [ -r $2 ] && [ ! -r $3 ]; then
1798 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1799 chmod +w $3 2>/dev/null
1800 chmod a+r $3 2>/dev/null
1802 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1803 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1804 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1805 newreq="$newreq $1 $dir/$include $dir2/$include"
1814 echo 'Cleaning up DONE files.'
1816 find . -name DONE -exec rm -f '{}' ';'
1818 echo 'Removing unneeded directories:'
1820 files=`find . -type d -print | sort -r`
1821 for file in $files; do
1822 rmdir $LIB/$file > /dev/null 2>&1