Annotation of GNUtools/cc/fixincludes, revision 1.1.1.1

1.1       root        1: #! /bin/sh
                      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.
                      5: 
                      6: # See README-fixinc for more information.
                      7: 
                      8: # Command to run gcc.
                      9: GCCCMD=${4-${GCCCMD-gcc}}
                     10: 
                     11: # Directory where gcc sources (and sometimes special include files) live.
                     12: # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
                     13: # sure somebody doesn't try to use arg3 for something incompatible. -- gumby
                     14: SRCDIR=${3-${SRCDIR-.}}
                     15: 
                     16: # Directory containing the original header files.
                     17: # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
                     18: INPUT=${2-${INPUT-/usr/include}}
                     19: 
                     20: # Directory in which to store the results.
                     21: LIB=${1?"fixincludes: output directory not specified"}
                     22: 
                     23: # Define PWDCMD as a command to use to get the working dir
                     24: # in the form that we want.
                     25: PWDCMD=pwd
                     26: case "`pwd`" in
                     27: //*)
                     28:        # On an Apollo, discard everything before `/usr'.
                     29:        PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
                     30:        ;;
                     31: esac
                     32: 
                     33: # Original directory.
                     34: ORIGDIR=`${PWDCMD}`
                     35: 
                     36: # Make sure it exists.
                     37: if [ ! -d $LIB ]; then
                     38:   mkdir $LIB || exit 1
                     39: fi
                     40: 
                     41: # Make LIB absolute only if needed to avoid problems with the amd.
                     42: case $LIB in
                     43: /*)
                     44:        ;;
                     45: *)
                     46:        cd $LIB; LIB=`${PWDCMD}`
                     47:        ;;
                     48: esac
                     49: 
                     50: # Make SRCDIR absolute only if needed to avoid problems with the amd.
                     51: cd $ORIGDIR
                     52: case $SRCDIR in
                     53: /*)
                     54:        ;;
                     55: *)
                     56:        cd $SRCDIR; SRCDIR=`${PWDCMD}`
                     57:        ;;
                     58: esac
                     59: 
                     60: # Fail if no arg to specify a directory for the output.
                     61: if [ x$1 = x ]
                     62: then echo fixincludes: no output directory specified
                     63: exit 1
                     64: fi
                     65: 
                     66: echo Building fixed headers in ${LIB}
                     67: 
                     68: # Determine whether this system has symbolic links.
                     69: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     70:   rm -f $LIB/ShouldNotExist
                     71:   LINKS=true
                     72: elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
                     73:   rm -f /tmp/ShouldNotExist
                     74:   LINKS=true
                     75: else
                     76:   LINKS=false
                     77: fi
                     78: 
                     79: echo Finding directories and links to directories
                     80: cd ${INPUT}
                     81: # Find all directories and all symlinks that point to directories.
                     82: # Put the list in $files.
                     83: # Each time we find a symlink, add it to newdirs
                     84: # so that we do another find within the dir the link points to.
                     85: # Note that $files may have duplicates in it;
                     86: # later parts of this file are supposed to ignore them.
                     87: dirs="."
                     88: levels=2
                     89: while [ -n "$dirs" ] && [ $levels -gt 0 ]
                     90: do
                     91:     levels=`expr $levels - 1`
                     92:     newdirs=
                     93:     for d in $dirs
                     94:     do
                     95:        echo " Searching $INPUT/$d"
                     96:        if [ "$d" != . ]
                     97:        then
                     98:            d=$d/.
                     99:        fi
                    100: 
                    101:        # Find all directories under $d, relative to $d, excluding $d itself.
                    102:         files="$files `find $d -type d -print | \
                    103:                       sed -e '/\/\.$/d' -e '/^\.$/d'`"
                    104:        # Find all links to directories.
                    105:        # Using `-exec test -d' in find fails on some systems,
                    106:        # and trying to run test via sh fails on others,
                    107:        # so this is the simplest alternative left.
                    108:        # First find all the links, then test each one.
                    109:        theselinks=
                    110:        $LINKS && \
                    111:          theselinks=`find $d -type l -print`
                    112:        for d1 in $theselinks --dummy--
                    113:        do
                    114:            # If the link points to a directory,
                    115:            # add that dir to $newdirs
                    116:            if [ -d $d1 ]
                    117:            then
                    118:                newdirs="$newdirs $d1"
                    119:            fi
                    120:        done
                    121:     done
                    122: 
                    123:     files="$files $newdirs"
                    124:     dirs="$newdirs"
                    125: done
                    126: 
                    127: dirs=
                    128: echo "All directories (including links to directories):"
                    129: echo $files
                    130: 
                    131: for file in $files; do
                    132:   rm -rf $LIB/$file
                    133:   if [ ! -d $LIB/$file ]
                    134:   then mkdir $LIB/$file
                    135:   fi
                    136: done
                    137: mkdir $LIB/root
                    138: 
                    139: # treetops gets an alternating list
                    140: # of old directories to copy
                    141: # and the new directories to copy to.
                    142: treetops="${INPUT} ${LIB}"
                    143: 
                    144: if $LINKS; then
                    145:   echo 'Making symbolic directory links'
                    146:   for file in $files; do
                    147:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    148:     if [ "$dest" ]; then    
                    149:       cwd=`${PWDCMD}`
                    150:       # In case $dest is relative, get to $file's dir first.
                    151:       cd ${INPUT}
                    152:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
                    153:       # Check that the target directory exists.
                    154:       # Redirections changed to avoid bug in sh on Ultrix.
                    155:       (cd $dest) > /dev/null 2>&1
                    156:       if [ $? = 0 ]; then
                    157:        cd $dest
                    158:        # X gets the dir that the link actually leads to.
                    159:        x=`${PWDCMD}`
                    160:        # If a link points to ., make a similar link to .
                    161:        if [ $x = $INPUT ]; then
                    162:          echo $file '->' . ': Making link'
                    163:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    164:          ln -s . ${LIB}/$file > /dev/null 2>&1
                    165:        # If link leads back into ${INPUT},
                    166:        # make a similar link here.
                    167:        elif expr $x : "${INPUT}/.*" > /dev/null; then
                    168:          # Y gets the actual target dir name, relative to ${INPUT}.
                    169:          y=`echo $x | sed -n "s&${INPUT}/&&p"`
                    170:          # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
                    171:          dots=`echo "$file" |
                    172:            sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
                    173:          echo $file '->' $dots$y ': Making link'
                    174:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    175:          ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
                    176:        else
                    177:          # If the link is to a dir $target outside ${INPUT},
                    178:          # repoint the link at ${INPUT}/root$target
                    179:          # and process $target into ${INPUT}/root$target
                    180:          # treat this directory as if it actually contained the files.
                    181:          echo $file '->' root$x ': Making link'
                    182:          if [ -d $LIB/root$x ]
                    183:          then true
                    184:          else
                    185:            dirname=root$x/
                    186:            dirmade=.
                    187:            cd $LIB
                    188:            while [ x$dirname != x ]; do
                    189:              component=`echo $dirname | sed -e 's|/.*$||'`
                    190:              mkdir $component >/dev/null 2>&1
                    191:              cd $component
                    192:              dirmade=$dirmade/$component
                    193:              dirname=`echo $dirname | sed -e 's|[^/]*/||'`
                    194:            done
                    195:          fi
                    196:          # Duplicate directory structure created in ${LIB}/$file in new
                    197:          # root area.
                    198:          for file2 in $files; do
                    199:            case $file2 in
                    200:              $file/./*)
                    201:                dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
                    202:                echo "Duplicating ${file}'s ${dupdir}"
                    203:                if [ -d ${dupdir} ]
                    204:                then true
                    205:                else
                    206:                  mkdir ${dupdir}
                    207:                fi
                    208:                ;;
                    209:              *)
                    210:                ;;
                    211:            esac
                    212:           done
                    213:          # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
                    214:          dots=`echo "$file" |
                    215:            sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
                    216:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    217:          ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
                    218:          treetops="$treetops $x ${LIB}/root$x"
                    219:        fi
                    220:       fi
                    221:       cd $cwd
                    222:     fi
                    223:   done
                    224: fi
                    225: 
                    226: required=
                    227: set x $treetops
                    228: shift
                    229: while [ $# != 0 ]; do
                    230:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
                    231:   cd ${INPUT}
                    232:   cd $1
                    233: # The same dir can appear more than once in treetops.
                    234: # There's no need to scan it more than once.
                    235:   if [ -f $2/DONE ]
                    236:   then
                    237:     files=
                    238:   else
                    239:     touch $2/DONE
                    240:     echo Fixing directory $1 into $2
                    241: # Check .h files which are symlinks as well as those which are files.
                    242: # A link to a header file will not be processed by anything but this.
                    243:     if $LINKS; then
                    244:       files=`find . -name '*.h' \( -type f -o -type l \) -print`
                    245:     else
                    246:       files=`find . -name '*.h' -type f -print`
                    247:     fi
                    248:     echo Checking header files
                    249:   fi
                    250: # Note that BSD43_* are used on recent MIPS systems.
                    251:   for file in $files; do
                    252: # This call to egrep is essential, since checking a file with egrep
                    253: # is much faster than actually trying to fix it.
                    254: # It is also essential that most files *not* match!
                    255: # Thus, matching every #endif is unacceptable.
                    256: # But the argument to egrep must be kept small, or many versions of egrep
                    257: # won't be able to handle it.
                    258: #
                    259: # We use the pattern [!-.0-~] instead of [^/   ] to match a noncomment
                    260: # following #else or #endif because some buggy egreps think [^/] matches
                    261: # newline, and they thus think `#else ' matches `#e[ndiflse]*[         ]+[^/   ]'.
                    262: #
                    263: # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
                    264: # following #if or #elif that is not surrounded by __.  The `a-ce-km-z'
                    265: # in this pattern lacks `d' and `l'; this means we don't worry about
                    266: # identifiers starting with `d' or `l'.  This is OK, since none of the
                    267: # identifiers below start with `d' or `l'.  It also greatly improves
                    268: # performance, since many files contain lines of the form `#if ... defined ...'
                    269: # or `#if lint'.
                    270:     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
                    271:       if [ -r $file ]; then
                    272:        cp $file $2/$file >/dev/null 2>&1       \
                    273:        || echo "Can't copy $file"
                    274:        chmod +w $2/$file
                    275:        chmod a+r $2/$file
                    276:        # Here is how the sed commands in braces work.
                    277:        # (It doesn't work to put the comments inside the sed commands.)
                    278:                # Surround each word with spaces, to simplify matching below.
                    279:                # ANSIfy each pre-ANSI machine-dependent symbol
                    280:                # by surrounding it with __ __.
                    281:                # Remove the spaces that we inserted around each word.
                    282:        sed -e '
                    283:                                   :loop
                    284:          /\\$/                 N
                    285:          /\\$/                 b loop
                    286:          s%^\([        ]*#[    ]*else\)[       ]*/[^*].*%\1%
                    287:          s%^\([        ]*#[    ]*else\)[       ]*[^/   ].*%\1%
                    288:          s%^\([        ]*#[    ]*endif\)[      ]*/[^*].*%\1%
                    289:          s%^\([        ]*#[    ]*endif\)[      ]*\*[^/].*%\1%
                    290:          s%^\([        ]*#[    ]*endif\)[      ]*[^/*  ].*%\1%
                    291:          /\/\/[^*]/                    s|//\(.*\)$|/*\1*/|
                    292:          /[    ]_IO[A-Z]*[     ]*(/    s/\(_IO[A-Z]*[  ]*(\)\(.\),/\1'\''\2'\'',/
                    293:          /[    ]BSD43__IO[A-Z]*[       ]*(/    s/(\(.\),/('\''\1'\'',/
                    294:          /#define._IO/                 s/'\''\([cgxtf]\)'\''/\1/g
                    295:          /#define.BSD43__IO/           s/'\''\([cgx]\)'\''/\1/g
                    296:          /[^A-Z0-9_]CTRL[      ]*(/            s/\([^'\'']\))/'\''\1'\'')/
                    297:          /[^A-Z0-9]_CTRL[      ]*(/            s/\([^'\'']\))/'\''\1'\'')/
                    298:          /#define[     ]*[     ]CTRL/          s/'\''\([cgx]\)'\''/\1/g
                    299:          /#define[     ]*[     ]_CTRL/         s/'\''\([cgx]\)'\''/\1/g
                    300:          /#define.BSD43_CTRL/          s/'\''\([cgx]\)'\''/\1/g
                    301:          /#[el]*if/{
                    302:                s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
                    303: 
                    304:                s/ bsd4\([0-9]\) / __bsd4\1__ /g
                    305:                s/ _*i386 / __i386__ /g
                    306:                s/ is68k / __is68k__ /g
                    307:                s/ m68k / __m68k__ /g
                    308:                s/ mc680\([0-9]\)0 / __mc680\10__ /g
                    309:                s/ news\([0-9]*\) / __news\1__ /g
                    310:                s/ ns32000 / __ns32000__ /g
                    311:                s/ pyr / __pyr__ /g
                    312:                s/ sony_news / __sony_news__ /g
                    313:                s/ sparc / __sparc__ /g
                    314:                s/ sun\([a-z0-9]*\) / __sun\1__ /g
                    315:                s/ unix / __unix__ /g
                    316:                s/ vax / __vax__ /g
                    317: 
                    318:                s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
                    319:          }
                    320:          /^#define.NULL[       ]/      i\
                    321:                #undef NULL
                    322:        ' $2/$file > $2/$file.
                    323:        mv $2/$file. $2/$file
                    324:        if cmp $file $2/$file >/dev/null 2>&1; then
                    325:           rm $2/$file
                    326:        else
                    327:           echo Fixed $file
                    328:           # Find any include directives that use "file".
                    329:           for include in `egrep '^[    ]*#[    ]*include[      ]*"[^/]' $2/$file | sed -e 's/^[        ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
                    330:              dir=`echo $file | sed -e s'|/[^/]*$||'`
                    331:              required="$required $1 $dir/$include $2/$dir/$include"
                    332:           done
                    333:        fi
                    334:       fi
                    335:     fi
                    336:   done
                    337:   shift; shift
                    338: done
                    339: 
                    340: cd ${INPUT}
                    341: 
                    342: # Install the proper definition of size_t in header files that it comes from.
                    343: for file in sys/types.h stdlib.h sys/stdtypes.h; do
                    344:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    345:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    346:     chmod +w ${LIB}/$file 2>/dev/null
                    347:     chmod a+r ${LIB}/$file 2>/dev/null
                    348:   fi
                    349: 
                    350:   if [ -r ${LIB}/$file ]; then
                    351:     echo Fixing $file comment
                    352:     # Get the definition of __SIZE_TYPE__, if any.
                    353:     # (This file must be called something.c).
                    354:     echo "__SIZE_TYPE__" > ${LIB}/types.c
                    355:     foo=`${GCCCMD} -E -P ${LIB}/types.c`
                    356:     rm -f ${LIB}/types.c
                    357:     # Default to our preferred type.
                    358:     if [ "$foo" = __SIZE_TYPE__ ]; then foo="unsigned long int"; fi
                    359:     sed -e "s/typedef[         a-z_]*[         ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed
                    360:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    361:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    362:       rm ${LIB}/$file
                    363:     fi
                    364:   fi
                    365: done
                    366: 
                    367: # Fix one other error in this file: a mismatched quote not inside a C comment.
                    368: file=sundev/vuid_event.h
                    369: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    370:   mkdir ${LIB}/sundev 2>/dev/null
                    371:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    372:   chmod +w ${LIB}/$file 2>/dev/null
                    373:   chmod a+r ${LIB}/$file 2>/dev/null
                    374: fi
                    375: 
                    376: if [ -r ${LIB}/$file ]; then
                    377:   echo Fixing $file comment
                    378:   sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
                    379:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    380:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    381:     rm ${LIB}/$file
                    382:   fi
                    383: fi
                    384: 
                    385: # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
                    386: file=sunwindow/win_cursor.h
                    387: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    388: #  mkdir ${LIB}/sunwindow 2>/dev/null
                    389:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    390:   chmod +w ${LIB}/$file 2>/dev/null
                    391: fi
                    392: if [ -r ${LIB}/$file ]; then
                    393:   echo Fixing $file
                    394:   sed -e "s/ecd.cursor/ecd_cursor/" ${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
                    397:     rm ${LIB}/$file
                    398:   fi
                    399: fi
                    400: file=sunwindow/win_lock.h
                    401: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    402: #  mkdir ${LIB}/sunwindow 2>/dev/null
                    403:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    404:   chmod +w ${LIB}/$file 2>/dev/null
                    405: fi
                    406: if [ -r ${LIB}/$file ]; then
                    407:   echo Fixing $file
                    408:   sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
                    409:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    410:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    411:     rm ${LIB}/$file
                    412:   fi
                    413: fi
                    414: 
                    415: # Fix this Sun file to avoid interfering with stddef.h.
                    416: file=sys/stdtypes.h
                    417: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    418:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    419:   chmod +w ${LIB}/$file 2>/dev/null
                    420:   chmod a+r ${LIB}/$file 2>/dev/null
                    421: fi
                    422: 
                    423: if [ -r ${LIB}/$file ]; then
                    424:   echo Fixing $file
                    425: sed -e '/[      ]size_t.*;/i\
                    426: #ifndef _GCC_SIZE_T\
                    427: #define _GCC_SIZE_T' \
                    428:     -e '/[      ]size_t.*;/a\
                    429: #endif' \
                    430:     -e '/[      ]ptrdiff_t.*;/i\
                    431: #ifndef _GCC_PTRDIFF_T\
                    432: #define _GCC_PTRDIFF_T' \
                    433:     -e '/[      ]ptrdiff_t.*;/a\
                    434: #endif' \
                    435:     -e '/[      ]wchar_t.*;/i\
                    436: #ifndef _GCC_WCHAR_T\
                    437: #define _GCC_WCHAR_T' \
                    438:     -e '/[      ]wchar_t.*;/a\
                    439: #endif' ${LIB}/$file > ${LIB}/${file}.sed
                    440:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    441:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    442:     rm ${LIB}/$file
                    443:   fi
                    444: fi
                    445: 
                    446: # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
                    447: # in cc1plus.
                    448: file=stdlib.h
                    449: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    450:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    451:   chmod +w ${LIB}/$file 2>/dev/null
                    452:   chmod a+r ${LIB}/$file 2>/dev/null
                    453: fi
                    454: 
                    455: if [ -r ${LIB}/$file ]; then
                    456:   echo Fixing $file
                    457:   sed -e "s/\(#[       ]*ifndef[       ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
                    458:       -e "s/\(#[       ]*define[       ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
                    459:      ${LIB}/$file > ${LIB}/${file}.sed
                    460:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    461:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    462:     rm ${LIB}/$file
                    463:   fi
                    464: fi
                    465: 
                    466: # Fix this file to avoid interfering with stddef.h, but don't mistakenly
                    467: # match e.g. ssize_t present in AIX for the ps/2.
                    468: file=sys/types.h
                    469: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    470:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    471:   chmod +w ${LIB}/$file 2>/dev/null
                    472:   chmod a+r ${LIB}/$file 2>/dev/null
                    473: fi
                    474: 
                    475: if [ -r ${LIB}/$file ]; then
                    476:   echo Fixing $file
                    477: sed -e '/[     ]size_t.*;/i\
                    478: #ifndef _GCC_SIZE_T\
                    479: #define _GCC_SIZE_T' \
                    480:     -e '/[     ]size_t.*;/a\
                    481: #endif' ${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
                    484:     rm ${LIB}/$file
                    485:   fi
                    486: fi
                    487: 
                    488: # Fix HP's use of ../machine/inline.h to refer to
                    489: # /usr/include/machine/inline.h
                    490: file=sys/spinlock.h
                    491: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    492:   cp $file ${LIB}/$file
                    493: fi
                    494: if [ -r ${LIB}/$file ] ; then
                    495:   echo Fixing $file
                    496:   sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
                    497:     -e 's,"../machine/psl.h",<machine/psl.h>,' \
                    498:   ${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
                    501:     rm ${LIB}/$file
                    502:   fi
                    503: fi
                    504: 
                    505: # Fix an error in this file: the #if says _cplusplus, not the double
                    506: # underscore __cplusplus that it should be
                    507: file=tinfo.h
                    508: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    509:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    510:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    511:   chmod +w ${LIB}/$file 2>/dev/null
                    512:   chmod a+r ${LIB}/$file 2>/dev/null
                    513: fi
                    514: 
                    515: if [ -r ${LIB}/$file ]; then
                    516:   echo Fixing $file, __cplusplus macro
                    517:   sed -e 's/[  ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
                    518:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    519:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    520:     rm ${LIB}/$file
                    521:   fi
                    522: fi
                    523: 
                    524: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
                    525: # structure definition.
                    526: file=rpcsvc/rstat.h
                    527: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    528:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    529:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    530:   chmod +w ${LIB}/$file 2>/dev/null
                    531:   chmod a+r ${LIB}/$file 2>/dev/null
                    532: fi
                    533: 
                    534: if [ -r ${LIB}/$file ]; then
                    535:   echo Fixing $file, definition of statsswtch
                    536:   sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
                    537:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    538:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    539:     rm ${LIB}/$file
                    540:   fi
                    541: fi
                    542: 
                    543: # Fix an error in this file: a missing semi-colon at the end of the nodeent
                    544: # structure definition.
                    545: file=netdnet/dnetdb.h
                    546: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    547:   mkdir ${LIB}/netdnet 2>/dev/null
                    548:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    549:   chmod +w ${LIB}/$file 2>/dev/null
                    550:   chmod a+r ${LIB}/$file 2>/dev/null
                    551: fi
                    552: 
                    553: if [ -r ${LIB}/$file ]; then
                    554:   echo Fixing $file, definition of nodeent
                    555:   sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
                    556:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    557:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    558:     rm ${LIB}/$file
                    559:   fi
                    560: fi
                    561: 
                    562: # Check for bad #ifdef line (in Ultrix 4.1)
                    563: file=sys/file.h
                    564: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    565:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    566:   chmod +w ${LIB}/$file 2>/dev/null
                    567:   chmod a+r ${LIB}/$file 2>/dev/null
                    568: fi
                    569: 
                    570: if [ -r ${LIB}/$file ]; then
                    571:   echo Fixing $file, bad \#ifdef line
                    572:   sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
                    573:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    574:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    575:     rm ${LIB}/$file
                    576:   fi
                    577: fi
                    578: 
                    579: # Check for superfluous `static' (in Ultrix 4.2)
                    580: file=machine/cpu.h
                    581: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    582:   mkdir ${LIB}/machine 2>/dev/null
                    583:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    584:   chmod +w ${LIB}/$file 2>/dev/null
                    585:   chmod a+r ${LIB}/$file 2>/dev/null
                    586: fi
                    587: 
                    588: if [ -r ${LIB}/$file ]; then
                    589:   echo Fixing $file, superfluous static
                    590:   sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
                    591:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    592:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    593:     rm ${LIB}/$file
                    594:   else
                    595: # This file has an alternative name, mips/cpu.h.  Fix that name, too.
                    596:     if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
                    597:       mkdir ${LIB}/mips 2>&-
                    598:       ln ${LIB}/$file ${LIB}/mips/cpu.h 
                    599:     fi
                    600:   fi
                    601: fi
                    602: 
                    603: # Incorrect sprintf declaration in X11/Xmu.h
                    604: file=X11/Xmu.h
                    605: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    606:   mkdir ${LIB}/X11 2>/dev/null
                    607:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    608:   chmod +w ${LIB}/$file 2>/dev/null
                    609:   chmod a+r ${LIB}/$file 2>/dev/null
                    610: fi
                    611: 
                    612: if [ -r ${LIB}/$file ]; then
                    613:   echo Fixing $file sprintf declaration
                    614:   sed -e 's,^extern char \*    sprintf();$,#ifndef __STDC__\
                    615: extern char *  sprintf();\
                    616: #endif /* !defined __STDC__ */,' ${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
                    619:     rm ${LIB}/$file
                    620:   fi
                    621: fi
                    622: 
                    623: # Incorrect sprintf declaration in X11/Xmu/Xmu.h
                    624: # (It's not clear whether the right file name is this or X11/Xmu.h.)
                    625: file=X11/Xmu/Xmu.h
                    626: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    627:   mkdir ${LIB}/X11/Xmu 2>/dev/null
                    628:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    629:   chmod +w ${LIB}/$file 2>/dev/null
                    630:   chmod a+r ${LIB}/$file 2>/dev/null
                    631: fi
                    632: 
                    633: if [ -r ${LIB}/$file ]; then
                    634:   echo Fixing $file sprintf declaration
                    635:   sed -e 's,^extern char \*    sprintf();$,#ifndef __STDC__\
                    636: extern char *  sprintf();\
                    637: #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
                    638:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    639:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    640:     rm ${LIB}/$file
                    641:   fi
                    642: fi
                    643: 
                    644: # Check for missing ';' in struct
                    645: file=netinet/ip.h
                    646: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    647:   mkdir ${LIB}/netinet 2>/dev/null
                    648:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    649:   chmod +w ${LIB}/$file 2>/dev/null
                    650:   chmod a+r ${LIB}/$file 2>/dev/null
                    651: fi
                    652: 
                    653: if [ -r ${LIB}/$file ]; then
                    654:   echo Fixing $file
                    655:   sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
                    656:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    657:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    658:     rm -f ${LIB}/$file
                    659:   fi
                    660: fi
                    661: 
                    662: # Fix the CAT macro in SunOS memvar.h.
                    663: file=pixrect/memvar.h
                    664: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    665:   mkdir ${LIB}/pixrect 2>/dev/null
                    666:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    667:   chmod +w ${LIB}/$file 2>/dev/null
                    668:   chmod a+r ${LIB}/$file 2>/dev/null
                    669: fi
                    670: 
                    671: if [ -r ${LIB}/$file ]; then
                    672:   echo Fixing $file
                    673:   sed -e '/^#define.CAT(a,b)/ i\
                    674: #ifdef __STDC__ \
                    675: #define CAT(a,b) a##b\
                    676: #else
                    677: /^#define.CAT(a,b)/ a\
                    678: #endif
                    679: ' ${LIB}/$file > ${LIB}/${file}.sed
                    680:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    681:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    682:     rm -f ${LIB}/$file
                    683:   fi
                    684: fi
                    685: 
                    686: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
                    687: file=rpcsvc/rusers.h
                    688: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    689:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    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
                    693: fi
                    694: 
                    695: if [ -r ${LIB}/$file ]; then
                    696:   echo Fixing $file
                    697:   sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
                    698:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    699:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    700:     rm -f ${LIB}/$file
                    701:   fi
                    702: fi
                    703: 
                    704: # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
                    705: # Also wrap protection around size_t for m88k-sysv3 systems.
                    706: file=stdlib.h
                    707: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    708:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    709:   chmod +w ${LIB}/$file 2>/dev/null
                    710:   chmod a+r ${LIB}/$file 2>/dev/null
                    711: fi
                    712: 
                    713: if [ -r ${LIB}/$file ]; then
                    714:   echo Fixing $file
                    715:   sed -e 's/int        abort/void      abort/g' \
                    716:   -e 's/int    free/void       free/g' \
                    717:   -e 's/char \*        calloc/void \*  calloc/g' \
                    718:   -e 's/char \*        malloc/void \*  malloc/g' \
                    719:   -e 's/char \*        realloc/void \* realloc/g' \
                    720:   -e 's/int    exit/void       exit/g' \
                    721:   -e '/typedef[        a-zA-Z_]*[      ]size_t[        ]*;/i\
                    722: #ifndef _GCC_SIZE_T\
                    723: #define _GCC_SIZE_T' \
                    724:   -e '/typedef[        a-zA-Z_]*[      ]size_t[        ]*;/a\
                    725: #endif' \
                    726:       ${LIB}/$file > ${LIB}/${file}.sed
                    727:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    728:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    729:     rm -f ${LIB}/$file
                    730:   fi
                    731: fi
                    732: 
                    733: # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
                    734: file=malloc.h
                    735: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    736:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    737:   chmod +w ${LIB}/$file 2>/dev/null
                    738:   chmod a+r ${LIB}/$file 2>/dev/null
                    739: fi
                    740: 
                    741: if [ -r ${LIB}/$file ]; then
                    742:   echo Fixing $file
                    743:   sed -e 's/typedef[   ]char \*        malloc_t/typedef void \*        malloc_t/g' \
                    744:   -e 's/int[   ][      ]*free/void     free/g' \
                    745:   ${LIB}/$file > ${LIB}/${file}.sed
                    746:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    747:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    748:     rm -f ${LIB}/$file
                    749:   fi
                    750: fi
                    751: 
                    752: # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
                    753: file=hsfs/hsfs_spec.h
                    754: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    755:   mkdir ${LIB}/hsfs 2>/dev/null
                    756:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    757:   chmod +w ${LIB}/$file 2>/dev/null
                    758:   chmod a+r ${LIB}/$file 2>/dev/null
                    759: fi
                    760: 
                    761: if [ -r ${LIB}/$file ]; then
                    762:   echo Fixing $file
                    763:   sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
                    764:     ${LIB}/$file > ${LIB}/${file}.
                    765:   rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
                    766:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    767:     rm -f ${LIB}/$file
                    768:   fi
                    769: fi
                    770: 
                    771: # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
                    772: file=hsfs/hsnode.h
                    773: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    774:   mkdir ${LIB}/hsfs 2>/dev/null
                    775:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    776:   chmod +w ${LIB}/$file 2>/dev/null
                    777:   chmod a+r ${LIB}/$file 2>/dev/null
                    778: fi
                    779: 
                    780: if [ -r ${LIB}/$file ]; then
                    781:   echo Fixing $file
                    782:   sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
                    783:     ${LIB}/$file > ${LIB}/${file}.sed
                    784:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    785:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    786:     rm -f ${LIB}/$file
                    787:   fi
                    788: fi
                    789: 
                    790: # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
                    791: file=hsfs/iso_spec.h
                    792: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    793:   mkdir ${LIB}/hsfs 2>/dev/null
                    794:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    795:   chmod +w ${LIB}/$file 2>/dev/null
                    796:   chmod a+r ${LIB}/$file 2>/dev/null
                    797: fi
                    798: 
                    799: if [ -r ${LIB}/$file ]; then
                    800:   echo Fixing $file
                    801:   sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
                    802:     ${LIB}/$file > ${LIB}/${file}.sed
                    803:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    804:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    805:     rm -f ${LIB}/$file
                    806:   fi
                    807: fi
                    808: 
                    809: # Incorrect #include in Sony News-OS 3.2.
                    810: file=machine/machparam.h
                    811: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    812:   mkdir ${LIB}/machine 2>/dev/null
                    813:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    814:   chmod +w ${LIB}/$file 2>/dev/null
                    815:   chmod a+r ${LIB}/$file 2>/dev/null
                    816: fi
                    817: 
                    818: if [ -r ${LIB}/$file ]; then
                    819:   echo Fixing $file, incorrect \#include
                    820:   sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
                    821:     ${LIB}/$file > ${LIB}/${file}.
                    822:   rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
                    823:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    824:     rm -f ${LIB}/$file
                    825:   fi
                    826: fi
                    827: 
                    828: # Multiline comment after typedef on IRIX 4.0.1.
                    829: file=sys/types.h
                    830: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    831:   mkdir ${LIB}/sys 2>/dev/null
                    832:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    833:   chmod +w ${LIB}/$file 2>/dev/null
                    834:   chmod a+r ${LIB}/$file 2>/dev/null
                    835: fi
                    836: 
                    837: if [ -r ${LIB}/$file ]; then
                    838:   echo Fixing $file, comment in the middle of \#ifdef
                    839:   sed -e 's@type of the result@type of the result */@' \
                    840:     -e 's@of the sizeof@/* of the sizeof@' \
                    841:     ${LIB}/$file > ${LIB}/${file}.sed
                    842:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    843:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    844:     rm -f ${LIB}/$file
                    845:   fi
                    846: fi
                    847: 
                    848: # Turning // comments into /* */ comments trashes this IRIX 4.0.1
                    849: # header file, which embeds // comments inside multi-line /* */
                    850: # comments.  If this looks like the IRIX header file, we refix it by
                    851: # just throwing away the // comments.
                    852: file=fam.h
                    853: if [ -r ${LIB}/$file ]; then
                    854:   if egrep indigo.esd ${LIB}/$file > /dev/null; then
                    855:     echo Fixing $file, overeager sed script
                    856:     rm ${LIB}/$file
                    857:     sed -e 's|//.*$||g' $file > ${LIB}/$file
                    858:     chmod +w ${LIB}/$file 2>/dev/null
                    859:     chmod a+r ${LIB}/$file 2>/dev/null
                    860:   fi
                    861: fi
                    862: 
                    863: # Some IRIX header files contains the string "//"
                    864: for file in elf_abi.h elf.h; do
                    865:   if [ -r ${LIB}/$file ]; then
                    866:     echo Fixing $file, overeager sed script
                    867:     sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
                    868:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    869:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    870:       rm -f ${LIB}/$file
                    871:     fi
                    872:   fi
                    873: done
                    874: 
                    875: # Same problem with a file from SunOS 4.1.3 : a header file containing
                    876: # the string "//" embedded in "/**/"
                    877: file=sbusdev/audiovar.h
                    878: if [ -r ${LIB}/$file ]; then
                    879:   echo Fixing $file, overeager sed script
                    880:   rm ${LIB}/$file
                    881:   sed -e 's|//.*$||g' $file > ${LIB}/$file
                    882:   chmod +w ${LIB}/$file 2>/dev/null
                    883:   chmod a+r ${LIB}/$file 2>/dev/null
                    884: fi
                    885: 
                    886: # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
                    887: # declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
                    888: # many other systems have similar text but correct versions of the file.
                    889: # To ensure only Sun's is fixed, we grep for a likely unique string.
                    890: file=memory.h
                    891: if [ -r $file ] && egrep '/\*  @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2   \*/' $file > /dev/null; then
                    892:   if [ ! -r ${LIB}/$file ]; then
                    893:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    894:     chmod +w ${LIB}/$file 2>/dev/null
                    895:     chmod a+r ${LIB}/$file 2>/dev/null
                    896:   fi
                    897:   if [ -r ${LIB}/$file ]; then
                    898:     echo Replacing $file
                    899:     cat > ${LIB}/$file << EOF
                    900: /* This file was generated by fixincludes */
                    901: #ifndef __memory_h__
                    902: #define __memory_h__
                    903: 
                    904: #ifdef __STDC__
                    905: extern void *memccpy();
                    906: extern void *memchr();
                    907: extern void *memcpy();
                    908: extern void *memset();
                    909: #else
                    910: extern char *memccpy();
                    911: extern char *memchr();
                    912: extern char *memcpy();
                    913: extern char *memset();
                    914: #endif /* __STDC__ */
                    915: 
                    916: extern int memcmp();
                    917: 
                    918: #endif /* __memory_h__ */
                    919: EOF
                    920:   fi
                    921: fi
                    922: 
                    923: # parameters not const on DECstation Ultrix V4.0.
                    924: file=stdio.h
                    925: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    926:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    927:   chmod +w ${LIB}/$file 2>/dev/null
                    928:   chmod a+r ${LIB}/$file 2>/dev/null
                    929: fi
                    930: 
                    931: if [ -r ${LIB}/$file ]; then
                    932:   echo Fixing $file, non-const arg
                    933:   sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
                    934:       -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
                    935:       -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
                    936:       -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
                    937:       -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
                    938:       -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
                    939:       -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
                    940:     ${LIB}/$file > ${LIB}/${file}.sed
                    941:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    942:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    943:     rm -f ${LIB}/$file
                    944:   fi
                    945: fi
                    946: 
                    947: # parameters conflict with C++ new on rs/6000 
                    948: for file in stdio.h unistd.h ; do
                    949:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    950:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    951:     chmod +w ${LIB}/$file 2>/dev/null
                    952:   fi
                    953: 
                    954:   if [ -r ${LIB}/$file ]; then
                    955:     echo Fixing $file, parameter name conflicts
                    956:     sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
                    957:       ${LIB}/$file > ${LIB}/${file}.sed
                    958:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    959:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    960:       rm -f ${LIB}/$file
                    961:     fi
                    962:   fi
                    963: done
                    964: 
                    965: # function class(double x) conflicts with C++ keyword on rs/6000 
                    966: file=math.h
                    967: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    968:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    969:   chmod +w ${LIB}/$file 2>/dev/null
                    970:   chmod a+r ${LIB}/$file 2>/dev/null
                    971: fi
                    972: 
                    973: if [ -r ${LIB}/$file ]; then
                    974:   if grep 'class[(]' ${LIB}/$file >/dev/null; then
                    975:     echo Fixing $file
                    976:     sed -e '/class[(]/i\
                    977: #ifndef __cplusplus' \
                    978:         -e '/class[(]/a\
                    979: #endif' ${LIB}/$file > ${LIB}/${file}.sed
                    980:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    981:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    982:       rm ${LIB}/$file
                    983:     fi
                    984:   fi
                    985: fi
                    986: 
                    987: # Wrong fchmod prototype on RS/6000.
                    988: file=sys/stat.h
                    989: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    990:   mkdir ${LIB}/sys 2>/dev/null
                    991:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    992:   chmod +w ${LIB}/$file 2>/dev/null
                    993:   chmod a+r ${LIB}/$file 2>/dev/null
                    994: fi
                    995: 
                    996: if [ -r ${LIB}/$file ]; then
                    997:   echo Fixing $file, fchmod prototype
                    998:   sed -e 's/fchmod(char \*/fchmod(int/' \
                    999:     ${LIB}/$file > ${LIB}/$file.sed
                   1000:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1001:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1002:     rm -f ${LIB}/$file
                   1003:   fi
                   1004: fi
                   1005: 
                   1006: # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
                   1007: # Note that version 3 of the NeXT system has wait.h in a different directory,
                   1008: # so that this code won't do anything.  But wait.h in version 3 has a
                   1009: # conditional, so it doesn't need this fix.  So everything is okay.
                   1010: file=sys/wait.h
                   1011: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1012:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1013:   chmod +w ${LIB}/$file 2>/dev/null
                   1014: fi
                   1015: 
                   1016: if [ -r ${LIB}/$file ] \
                   1017:   && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
                   1018:   echo Fixing $file, bad wait formal
                   1019:   sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
                   1020:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1021:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1022:     rm -f ${LIB}/$file
                   1023:   fi
                   1024: fi
                   1025: 
                   1026: # Don't use or define the name va_list in stdio.h.
                   1027: # This is for ANSI and also to interoperate properly with gvarargs.h.
                   1028: file=stdio.h
                   1029: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1030:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1031:   chmod +w ${LIB}/$file 2>/dev/null
                   1032:   chmod a+r ${LIB}/$file 2>/dev/null
                   1033: fi
                   1034: 
                   1035: if [ -r ${LIB}/$file ]; then
                   1036:   echo Fixing $file, use of va_list
                   1037:   # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
                   1038:   (echo "#define __need___va_list"
                   1039:    echo "#include <stdarg.h>") > ${LIB}/${file}.sed
                   1040:   # Use __gnuc_va_list in arg types in place of va_list.
                   1041:   # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
                   1042:   # trailing parentheses and semicolon save all other systems from this.
                   1043:   # Define __va_list__ (something harmless and unused) instead of va_list.
                   1044:   # Don't claim to have defined va_list.
                   1045:   sed -e 's@ va_list @ __gnuc_va_list @' \
                   1046:       -e 's@ va_list)@ __gnuc_va_list)@' \
                   1047:       -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
                   1048:       -e 's@ va_list@ __va_list__@' \
                   1049:       -e 's@\*va_list@*__va_list__@' \
                   1050:       -e 's@ __va_list)@ __gnuc_va_list)@' \
                   1051:       -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
                   1052:       -e 's@VA_LIST@DUMMY_VA_LIST@' \
                   1053:       -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
                   1054:     ${LIB}/$file >> ${LIB}/${file}.sed
                   1055:   
                   1056:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1057:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1058:     rm -f ${LIB}/$file
                   1059:   fi
                   1060: fi
                   1061: 
                   1062: # Cancel out ansi_compat.h on Ultrix.  Replace it with empty file.
                   1063: file=ansi_compat.h
                   1064: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1065:   if grep -s ULTRIX $file; then
                   1066:     echo "/* This file intentionally left blank.  */" > $LIB/$file
                   1067:   fi
                   1068: fi
                   1069: 
                   1070: # parameter to atof not const on DECstation Ultrix V4.0.
                   1071: # also get rid of bogus inline definitions in HP-UX 8.0
                   1072: file=math.h
                   1073: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1074:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1075:   chmod +w ${LIB}/$file 2>/dev/null
                   1076:   chmod a+r ${LIB}/$file 2>/dev/null
                   1077: fi
                   1078: 
                   1079: if [ -r ${LIB}/$file ]; then
                   1080:   echo Fixing $file, non-const arg
                   1081:   sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
                   1082:       -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
                   1083:       -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
                   1084:       -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
                   1085:       -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
                   1086:     ${LIB}/$file > ${LIB}/${file}.sed
                   1087:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1088:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1089:     rm -f ${LIB}/$file
                   1090:   fi
                   1091: fi
                   1092: 
                   1093: # Avoid nested comments on Ultrix 4.3.
                   1094: file=rpc/svc.h
                   1095: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1096:   mkdir ${LIB}/rpc 2>/dev/null
                   1097:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1098:   chmod +w ${LIB}/$file 2>/dev/null
                   1099:   chmod a+r ${LIB}/$file 2>/dev/null
                   1100: fi
                   1101: 
                   1102: if [ -r ${LIB}/$file ]; then
                   1103:   echo Fixing $file, nested comment
                   1104:   sed -e 's@^\( \*     int protocol;  \)/\*@\1*/ /*@' \
                   1105:     ${LIB}/$file > ${LIB}/$file.sed
                   1106:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1107:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1108:     rm -f ${LIB}/$file
                   1109:   fi
                   1110: fi
                   1111: 
                   1112: # In limits.h, put #ifndefs around things that are supposed to be defined
                   1113: # in float.h to avoid redefinition errors if float.h is included first.
                   1114: # On HP/UX this patch does not work, because on HP/UX limits.h uses
                   1115: # multi line comments and the inserted #endif winds up inside the
                   1116: # comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
                   1117: # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
                   1118: # are there, and we do not add them ourselves.
                   1119: for file in limits.h sys/limits.h; do
                   1120:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1121:     mkdir ${LIB}/sys 2>/dev/null
                   1122:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1123:     chmod +w ${LIB}/$file 2>/dev/null
                   1124:     chmod a+r ${LIB}/$file 2>/dev/null
                   1125:   fi
                   1126: 
                   1127:   if [ -r ${LIB}/$file ]; then
                   1128:     if egrep 'ifndef[  ]+FLT_MIN' ${LIB}/$file >/dev/null; then
                   1129:       true
                   1130:     else
                   1131:       echo Fixing $file
                   1132:       sed -e '/[       ]FLT_MIN[       ]/i\
                   1133: #ifndef FLT_MIN'\
                   1134:          -e '/[        ]FLT_MIN[       ]/a\
                   1135: #endif'\
                   1136:          -e '/[        ]FLT_MAX[       ]/i\
                   1137: #ifndef FLT_MAX'\
                   1138:          -e '/[        ]FLT_MAX[       ]/a\
                   1139: #endif'\
                   1140:          -e '/[        ]FLT_DIG[       ]/i\
                   1141: #ifndef FLT_DIG'\
                   1142:          -e '/[        ]FLT_DIG[       ]/a\
                   1143: #endif'\
                   1144:          -e '/[        ]DBL_MIN[       ]/i\
                   1145: #ifndef DBL_MIN'\
                   1146:          -e '/[        ]DBL_MIN[       ]/a\
                   1147: #endif'\
                   1148:          -e '/[        ]DBL_MAX[       ]/i\
                   1149: #ifndef DBL_MAX'\
                   1150:          -e '/[        ]DBL_MAX[       ]/a\
                   1151: #endif'\
                   1152:          -e '/[        ]DBL_DIG[       ]/i\
                   1153: #ifndef DBL_DIG'\
                   1154:          -e '/[        ]DBL_DIG[       ]/a\
                   1155: #endif'\
                   1156:        ${LIB}/$file > ${LIB}/${file}.sed
                   1157:       rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1158:     fi
                   1159:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1160:       echo Deleting ${LIB}/$file\; no fixes were needed.
                   1161:       rm -f ${LIB}/$file
                   1162:     fi
                   1163:   fi
                   1164: done
                   1165: 
                   1166: # In math.h, put #ifndefs around things that might be defined in a gcc
                   1167: # specific math-*.h file.
                   1168: file=math.h
                   1169: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1170:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1171:   chmod +w ${LIB}/$file 2>/dev/null
                   1172:   chmod a+r ${LIB}/$file 2>/dev/null
                   1173: fi
                   1174: 
                   1175: if [ -r ${LIB}/$file ]; then
                   1176:   echo Fixing $file
                   1177:   sed -e '/define[     ]HUGE_VAL[      ]/i\
                   1178: #ifndef HUGE_VAL'\
                   1179:       -e '/define[     ]HUGE_VAL[      ]/a\
                   1180: #endif'\
                   1181:     ${LIB}/$file > ${LIB}/${file}.sed
                   1182:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1183:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1184:     echo Deleting ${LIB}/$file\; no fixes were needed.
                   1185:     rm -f ${LIB}/$file
                   1186:   fi
                   1187: fi
                   1188: 
                   1189: # Remove erroneous parentheses in sym.h on Alpha OSF/1.
                   1190: file=sym.h
                   1191: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1192:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1193:   chmod +w ${LIB}/$file 2>/dev/null
                   1194:   chmod a+r ${LIB}/$file 2>/dev/null
                   1195: fi
                   1196: 
                   1197: if [ -r ${LIB}/$file ]; then
                   1198:   echo Fixing $file
                   1199:   sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
                   1200:     ${LIB}/$file > ${LIB}/${file}.sed
                   1201:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1202:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1203:     rm -f ${LIB}/$file
                   1204:   fi
                   1205: fi
                   1206: 
                   1207: # Fix incorrect S_IF* definitions on m88k-sysv3.
                   1208: file=sys/stat.h
                   1209: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1210:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1211:   chmod +w ${LIB}/$file 2>/dev/null
                   1212:   chmod a+r ${LIB}/$file 2>/dev/null
                   1213: fi
                   1214: 
                   1215: if [ -r ${LIB}/$file ]; then
                   1216:   echo Fixing $file
                   1217:   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)/' \
                   1218:       -e 's/^\(#define[        ]*S_IS[A-Z]*(m)\)[      ]*(m[   ]*&[    ]*\(0[0-9]*\)[  ]*)/\1 (((m)\&S_IFMT)==\2)/' \
                   1219:     ${LIB}/$file > ${LIB}/${file}.sed
                   1220:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1221:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1222:     rm -f ${LIB}/$file
                   1223:   fi
                   1224: fi
                   1225: 
                   1226: # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
                   1227: for file in stdio.h stdlib.h; do
                   1228:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1229:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1230:     chmod +w ${LIB}/$file 2>/dev/null
                   1231:     chmod a+r ${LIB}/$file 2>/dev/null
                   1232:   fi
                   1233: 
                   1234:   if [ -r ${LIB}/$file ]; then
                   1235:     echo Fixing $file, getopt declaration
                   1236:     sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
                   1237:       ${LIB}/$file > ${LIB}/${file}.sed
                   1238:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1239:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1240:       rm -f ${LIB}/$file
                   1241:     fi
                   1242:   fi
                   1243: done
                   1244: 
                   1245: # These two files on SunOS 4 are included by other files
                   1246: # in the same directory, using "...".  So we must make sure they exist
                   1247: # in the same directory as the other fixed files.
                   1248: if [ -r ${INPUT}/multimedia/audio_errno.h ]
                   1249: then
                   1250:   ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
                   1251: fi
                   1252: if [ -r ${INPUT}/multimedia/audio_hdr.h ]
                   1253: then
                   1254:   ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
                   1255: fi
                   1256: 
                   1257: # Determine if we're on Interactive Unix 2.2 or later, in which case we
                   1258: # need to fix some additional files.  This is the same test for ISC that
                   1259: # Autoconf uses.
                   1260: if test -d /etc/conf/kconfig.d \
                   1261:     && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
                   1262:   echo "Fixing ISC __STDC__ goof in several files..."
                   1263:   for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
                   1264:     echo $name
                   1265:     if test -r ${LIB}/$name; then
                   1266:       file=${LIB}/$name
                   1267:     else
                   1268:       file=${INPUT}/$name
                   1269:     fi
                   1270:     # On Interactive 2.2, certain traditional Unix definitions
                   1271:     # (notably getc and putc in stdio.h) are omitted if __STDC__ is
                   1272:     # defined, not just if _POSIX_SOURCE is defined.  This makes it
                   1273:     # impossible to compile any nontrivial program except with -posix.
                   1274:     sed \
                   1275: 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
                   1276:            < $file > ${LIB}/$name.
                   1277:     mv ${LIB}/$name. ${LIB}/$name
                   1278:   done
                   1279:   
                   1280:   echo "Fixing ISC fmod declaration"
                   1281:   # This one's already been fixed for other things.
                   1282:   file=${LIB}/math.h
                   1283:   sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
                   1284:   mv $file. $file
                   1285:   
                   1286:   echo "Fixing nested comments in ISC <sys/limits.h>"
                   1287:   file=sys/limits.h
                   1288:   sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
                   1289:   sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
                   1290: fi
                   1291: 
                   1292: # These files in Sun OS 4.x use /**/ to concatenate tokens.
                   1293: for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
                   1294:        sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h      \
                   1295:        sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
                   1296: do
                   1297:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   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
                   1301:   fi
                   1302: 
                   1303:   if [ -r ${LIB}/$file ]; then
                   1304:     sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
                   1305:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1306:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1307:       rm -f ${LIB}/$file
                   1308:     fi
                   1309:   fi
                   1310: done
                   1311: 
                   1312: # These files in ARM/RISCiX use /**/ to concatenate tokens.
                   1313: for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
                   1314:        dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
                   1315: do
                   1316:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                   1317:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                   1318:     chmod +w ${LIB}/$file 2>/dev/null
                   1319:     chmod a+r ${LIB}/$file 2>/dev/null
                   1320:   fi
                   1321: 
                   1322:   if [ -r ${LIB}/$file ]; then
                   1323:     sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
                   1324:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                   1325:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                   1326:       rm -f ${LIB}/$file
                   1327:     fi
                   1328:   fi
                   1329: done
                   1330: 
                   1331: echo 'Removing unneeded directories:'
                   1332: cd $LIB
                   1333: files=`find . -type d -print | sort -r`
                   1334: for file in $files; do
                   1335:   rmdir $LIB/$file > /dev/null 2>&1
                   1336: done
                   1337: 
                   1338: if $LINKS; then
                   1339:   echo 'Making internal symbolic non-directory links'
                   1340:   cd ${INPUT}
                   1341:   files=`find . -type l -print`
                   1342:   for file in $files; do
                   1343:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                   1344:     if expr "$dest" : '[^/].*' > /dev/null; then    
                   1345:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                   1346:       if [ -f $target ]; then
                   1347:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                   1348:       fi
                   1349:     fi
                   1350:   done
                   1351: fi
                   1352: 
                   1353: # Make sure that any include files referenced using double quotes
                   1354: # exist in the fixed directory.  This comes last since otherwise
                   1355: # we might end up deleting some of these files "because they don't
                   1356: # need any change."
                   1357: while [ -n "$required" ]; do
                   1358:   newreq=
                   1359:   set x $required
                   1360:   shift
                   1361:   while [ $# != 0 ]; do
                   1362:     # $1 is the directory to copy from, $2 is the unfixed file,
                   1363:     # $3 is the fixed file name.
                   1364:     cd ${INPUT}
                   1365:     cd $1
                   1366:     if [ -r $2 ] && [ ! -r $3 ]; then
                   1367:       cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
                   1368:       chmod +w $3 2>/dev/null
                   1369:       chmod a+r $3 2>/dev/null
                   1370:       echo Copied $2
                   1371:       for include in `egrep '^[        ]*#[    ]*include[      ]*"[^/]' $3 | sed -e 's/^[      ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
                   1372:        dir=`echo $2 | sed -e s'|/[^/]*$||'`
                   1373:        dir2=`echo $3 | sed -e s'|/[^/]*$||'`
                   1374:        newreq="$newreq $1 $dir/$include $dir2/$include"
                   1375:       done
                   1376:     fi
                   1377:     shift; shift; shift
                   1378:   done
                   1379:   required=$newreq
                   1380: done
                   1381: 
                   1382: echo 'Cleaning up DONE files.'
                   1383: cd $LIB
                   1384: find . -name DONE -exec rm -f '{}' ';'
                   1385: 
                   1386: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.