Annotation of gcc/fixincludes, revision 1.1.1.15

1.1.1.2   root        1: #! /bin/sh
1.1       root        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: # This works properly on a Sun in system version 3.4;
                      6: # for other versions, you had better check.
                      7: 
1.1.1.15! root        8: # Directory containing the original header files.
        !             9: INCLUDES=${2-${INCLUDES-/usr/include}}
        !            10: 
1.1.1.3   root       11: # Directory in which to store the results.
1.1.1.11  root       12: LIB=${LIB-/usr/local/lib/gcc-include}
                     13: 
                     14: # Make sure it exists.
1.1.1.12  root       15: if [ ! -d $LIB ]; then
                     16:   mkdir $LIB || exit 1
                     17: fi
1.1.1.3   root       18: 
1.1.1.10  root       19: # Determine whether this system has symbolic links.
                     20: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     21:   rm -f $LIB/ShouldNotExist
                     22:   LINKS=true
                     23: else
                     24:   LINKS=false
                     25: fi
                     26: 
1.1.1.9   root       27: echo 'Making directories:'
1.1.1.15! root       28: cd ${INCLUDES}
1.1.1.10  root       29: if $LINKS; then
                     30:   files=`ls -LR | sed -n s/:$//p`
                     31: else
1.1.1.12  root       32:   files=`find . -type d -print | sed '/^.$/d'`
1.1.1.10  root       33: fi
1.1.1.9   root       34: for file in $files; do
1.1.1.12  root       35:   rm -rf $LIB/$file
                     36:   if [ ! -d $LIB/$file ]
                     37:   then mkdir $LIB/$file
                     38:   fi
1.1.1.9   root       39: done
1.1.1.6   root       40: 
1.1.1.10  root       41: # treetops gets an alternating list
                     42: # of old directories to copy
                     43: # and the new directories to copy to.
1.1.1.15! root       44: treetops="${INCLUDES} ${LIB}"
1.1.1.10  root       45: 
                     46: if $LINKS; then
                     47:   echo 'Making internal symbolic directory links'
                     48:   for file in $files; do
                     49:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                     50:     if [ "$dest" ]; then    
1.1.1.12  root       51:       cwd=`pwd`
                     52:       # In case $dest is relative, get to $file's dir first.
1.1.1.15! root       53:       cd ${INCLUDES}
1.1.1.12  root       54:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
                     55:       # Check that the target directory exists.
                     56:       # Redirections changed to avoid bug in sh on Ultrix.
                     57:       (cd $dest) > /dev/null 2>&1
                     58:       if [ $? = 0 ]; then
                     59:        cd $dest
                     60:        # X gets the dir that the link actually leads to.
                     61:        x=`pwd`
1.1.1.15! root       62:        # If link leads back into ${INCLUDES},
1.1.1.12  root       63:        # make a similar link here.
1.1.1.15! root       64:        if expr $x : '${INCLUDES}/.*' > /dev/null; then
        !            65:          # Y gets the actual target dir name, relative to ${INCLUDES}.
        !            66:          y=`echo $x | sed -n 's&${INCLUDES}/&&p'`
1.1.1.12  root       67:          echo $file '->' $y ': Making link'
                     68:          rm -fr ${LIB}/$file > /dev/null 2>&1
                     69:          ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
                     70:        else
1.1.1.15! root       71:          # If the link is to outside ${INCLUDES},
1.1.1.12  root       72:          # treat this directory as if it actually contained the files.
                     73: # This line used to have $dest instead of $x.
                     74: # $dest seemed to be wrong for links found in subdirectories
1.1.1.15! root       75: # of ${INCLUDES}.  Does this change break anything?
1.1.1.12  root       76:          treetops="$treetops $x ${LIB}/$file"
                     77:        fi
1.1.1.10  root       78:       fi
1.1.1.12  root       79:       cd $cwd
1.1.1.10  root       80:     fi
                     81:   done
                     82: fi
                     83: 
                     84: set - $treetops
                     85: while [ $# != 0 ]; do
                     86:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
1.1.1.11  root       87:   echo "Finding header files in $1:"
1.1.1.15! root       88:   cd ${INCLUDES}
1.1.1.10  root       89:   cd $1
1.1.1.12  root       90:   files=`find . -name '*.h' -type f -print`
1.1.1.10  root       91:   echo 'Checking header files:'
1.1.1.14  root       92: # Note that BSD43_* are used on recent MIPS systems.
1.1.1.10  root       93:   for file in $files; do
1.1.1.14  root       94:     if egrep '[        ]_IO[A-Z]*\(|[   ]BSD43__IO[A-Z]*\(|#define._IO|#define.BSD43__IO|CTRL' $file > /dev/null; then
1.1.1.10  root       95:       echo Fixing $file
                     96:       if [ -r $file ]; then
                     97:        cp $file $2/$file >/dev/null 2>&1       \
                     98:        || echo "Can't copy $file"
                     99:        chmod +w $2/$file
1.1.1.11  root      100:        sed -e '
                    101:                                   :loop
                    102:          /\\$/                 N
                    103:          /\\$/                 b loop
1.1.1.12  root      104:          /[    ]_IO[A-Z]*[     ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.14  root      105:          /[    ]BSD43__IO[A-Z]*[       ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.11  root      106:          /#define._IO/         s/'\''x'\''/x/g
1.1.1.14  root      107:          /#define.BSD43__IO/           s/'\''x'\''/x/g
1.1.1.12  root      108:          /[^A-Z]CTRL[  ]*(/    s/\([^'\'']\))/'\''\1'\'')/
1.1.1.11  root      109:          /#define.CTRL/                s/'\''c'\''/c/g
1.1.1.12  root      110:          /#define._CTRL/               s/'\''c'\''/c/g
1.1.1.14  root      111:          /#define.BSD43_CTRL/          s/'\''c'\''/c/g
1.1.1.15! root      112:          /#if.* m68k$/                 s/m68k/__m68k__/g
        !           113:          /#if.*defined *(m68k)/        s/m68k/__m68k__/g
1.1.1.11  root      114:        ' $2/$file > $2/$file.sed
                    115:        mv $2/$file.sed $2/$file
1.1.1.10  root      116:        if cmp $file $2/$file >/dev/null 2>&1; then
                    117:           echo Deleting $2/$file\; no fixes were needed.
                    118:           rm $2/$file
                    119:        fi
1.1.1.8   root      120:       fi
1.1.1.5   root      121:     fi
1.1.1.10  root      122:   done
                    123:   shift; shift
1.1.1.2   root      124: done
                    125: 
1.1.1.15! root      126: cd ${INCLUDES}
1.1.1.11  root      127: 
1.1.1.5   root      128: # Fix one other error in this file: a mismatched quote not inside a C comment.
                    129: file=sundev/vuid_event.h
                    130: if [ -r $file ]; then
                    131:   if [ ! -r ${LIB}/$file ]; then
                    132:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    133:     || echo "Can't copy $file"
1.1.1.3   root      134:     chmod +w ${LIB}/$file
1.1.1.2   root      135:   fi
1.1.1.5   root      136: fi
1.1.1.4   root      137: 
1.1.1.12  root      138: if [ -r ${LIB}/$file ]; then
                    139:   echo Fixing $file comment
                    140:   ex ${LIB}/$file <<EOF
1.1.1.11  root      141:   g/doesn't/s/doesn't/does not/
                    142:   wq
                    143: EOF
1.1.1.12  root      144:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    145:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    146:     rm ${LIB}/$file
                    147:   fi
                    148: fi
                    149: 
1.1.1.14  root      150: # Fix this Sun file to avoid intefering with stddef.h.
                    151: 
                    152: file=sys/stdtypes.h
                    153: if [ -r $file ]; then
                    154:   if [ ! -r ${LIB}/$file ]; then
                    155:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    156:     || echo "Can't copy $file"
                    157:     chmod +w ${LIB}/$file
                    158:   fi
                    159: fi
                    160: 
                    161: if [ -r ${LIB}/$file ]; then
                    162:   echo Fixing $file comment
                    163:   ex ${LIB}/$file <<EOF
                    164:   /size_t.*;/
                    165:   i
                    166: #ifndef _SIZE_T
                    167: #define _SIZE_T
                    168: .
                    169:   /size_t/+1
                    170:   i
                    171: #endif
                    172: .
                    173:   /ptrdiff_t.*;/
                    174:   i
                    175: #ifndef _PTRDIFF_T
                    176: #define _PTRDIFF_T
                    177: .
                    178:   /ptrdiff_t/+1
                    179:   i
                    180: #endif
                    181: .
                    182:   /wchar_t.*;/
                    183:   i
                    184: #ifndef _WCHAR_T
                    185: #define _WCHAR_T
                    186: .
                    187:   /wchar_t/+1
                    188:   i
                    189: #endif
                    190: .
                    191:   wq
                    192: EOF
                    193:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    194:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    195:     rm ${LIB}/$file
                    196:   fi
                    197: fi
                    198: 
1.1.1.12  root      199: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
                    200: # structure definition.
                    201: file=rpcsvc/rstat.h
                    202: if [ -r $file ]; then
                    203:   if [ ! -r ${LIB}/$file ]; then
                    204:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    205:     || echo "Can't copy $file"
                    206:     chmod +w ${LIB}/$file
                    207:   fi
                    208: fi
                    209: 
                    210: if [ -r ${LIB}/$file ]; then
                    211:   echo Fixing $file, definition of statsswtch
                    212:   ex ${LIB}/$file <<EOF
                    213:   g/boottime$/s//&;/
                    214:   wq
                    215: EOF
1.1.1.13  root      216:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    217:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    218:     rm ${LIB}/$file
                    219:   fi
                    220: fi
                    221: 
1.1.1.14  root      222: # Fix an error in this file: a missing semi-colon at the end of the nodeent
                    223: # structure definition.
                    224: file=netdnet/dnetdb.h
                    225: if [ -r $file ]; then
                    226:   if [ ! -r ${LIB}/$file ]; then
                    227:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    228:     || echo "Can't copy $file"
                    229:     chmod +w ${LIB}/$file
                    230:   fi
                    231: fi
                    232: 
                    233: if [ -r ${LIB}/$file ]; then
                    234:   echo Fixing $file, definition of nodeent
                    235:   ex ${LIB}/$file <<EOF
                    236:   g/na_addr/s//&;/
                    237:   wq
                    238: EOF
                    239:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    240:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    241:     rm ${LIB}/$file
                    242:   fi
                    243: fi
                    244: 
1.1.1.13  root      245: # Check for bad #ifdef line (in Ultrix 4.1)
                    246: 
                    247: file=sys/file.h
                    248: if [ -r $file ]; then
                    249:   if [ ! -r ${LIB}/$file ]; then
                    250:     mkdir ${LIB}/rpcsvc 2>&-
                    251:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    252:     || echo "Can't copy $file"
                    253:     chmod +w ${LIB}/$file
                    254:   fi
                    255: fi
                    256: 
                    257: if [ -r ${LIB}/$file ]; then
1.1.1.14  root      258:   echo Fixing $file, bad \#ifdef line
1.1.1.13  root      259:   ex ${LIB}/$file <<EOF
                    260:   g/^#ifdef KERNEL && !defined/
                    261:   s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
                    262:   wq
                    263: EOF
                    264:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    265:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    266:     rm ${LIB}/$file
1.1.1.12  root      267:   fi
1.1.1.11  root      268: fi
                    269: 
1.1.1.14  root      270: # Check for superfluous `static' (in Ultrix 4.2)
                    271: 
                    272: file=machine/cpu.h
                    273: if [ -r $file ]; then
                    274:   if [ ! -r ${LIB}/$file ]; then
                    275:     mkdir ${LIB}/machine 2>&-
                    276:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    277:     || echo "Can't copy $file"
                    278:     chmod +w ${LIB}/$file
                    279:   fi
                    280: fi
                    281: 
                    282: if [ -r ${LIB}/$file ]; then
                    283:   echo Fixing $file, superfluous static
                    284:   ex ${LIB}/$file <<EOF
                    285:   g/^static struct tlb_pid_state/
                    286:   s/static//
                    287:   wq
                    288: EOF
                    289:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    290:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    291:     rm ${LIB}/$file
                    292:   else
                    293: # This file has an alternative name, mips/cpu.h.  Fix that name, too.
                    294:     if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
                    295:       mkdir ${LIB}/mips 2>&-
                    296:       ln ${LIB}/$file ${LIB}/mips/cpu.h 
                    297:     fi
                    298:   fi
                    299: fi
                    300: 
1.1.1.11  root      301: # Deal with yet another challenge, this in X11/Xmu.h
                    302: file=X11/Xmu.h
                    303: if [ -r $file ]; then
                    304:   if [ ! -r ${LIB}/$file ]; then
                    305:     mkdir ${LIB}/X11 2>&-
                    306:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    307:     || echo "Can't copy $file"
                    308:     chmod +w ${LIB}/$file
                    309:   fi
                    310: fi
                    311: 
                    312: if [ -r ${LIB}/$file ]; then
                    313:   echo Fixing $file sprintf declaration
                    314:   ex ${LIB}/$file <<EOF
                    315:   /^extern char \*     sprintf();$/c
                    316: #ifndef __STDC__
                    317: extern char *  sprintf();
                    318: #endif /* !defined __STDC__ */
                    319: .
1.1.1.5   root      320:   wq
1.1       root      321: EOF
1.1.1.12  root      322:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    323:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    324:     rm ${LIB}/$file
                    325:   fi
                    326: fi
                    327: 
                    328: # Check for missing ';' in struct
                    329: 
                    330: file=netinet/ip.h
                    331: if [ -r $file ]; then
                    332:   if [ ! -r ${LIB}/$file ]; then
                    333:     mkdir ${LIB}/netinet 2>&-
                    334:     sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file
1.1.1.15! root      335:     cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file
1.1.1.12  root      336:   fi
                    337: fi
                    338: 
                    339: # Fix the CAT macro in memvar.h.
                    340: 
                    341: file=pixrect/memvar.h
                    342: if [ -r $file ]; then
                    343:   if [ ! -r ${LIB}/$file ]; then
                    344:     mkdir ${LIB}/pixrect 2>&-
1.1.1.15! root      345:     sed -e '/^#define.CAT(a,b)/ i\
        !           346: #ifdef __STDC__ \
        !           347: #define CAT(a,b) a##b\
        !           348: #else
        !           349: /^#define.CAT(a,b)/ a\
        !           350: #endif
        !           351: ' $file > ${LIB}/$file
        !           352:     cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file
1.1.1.12  root      353:   fi
                    354: fi
                    355: 
                    356: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
                    357: 
                    358: file=rpcsvc/rusers.h
                    359: if [ -r $file ]; then
                    360:   if [ ! -r ${LIB}/$file ]; then
                    361:     mkdir ${LIB}/rpcsvc 2>&-
                    362:     sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
1.1.1.15! root      363:     cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file
1.1.1.12  root      364:   fi
                    365: fi
                    366: 
1.1.1.10  root      367: echo 'Removing unneeded directories:'
                    368: cd $LIB
                    369: files=`find . -type d -print | sort -r`
                    370: for file in $files; do
                    371:   rmdir $LIB/$file > /dev/null 2>&1
                    372: done
                    373: 
1.1.1.11  root      374: if $LINKS; then
                    375:   echo 'Making internal symbolic non-directory links'
1.1.1.15! root      376:   cd ${INCLUDES}
1.1.1.11  root      377:   files=`find . -type l -print`
                    378:   for file in $files; do
                    379:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    380:     if expr "$dest" : '[^/].*' > /dev/null; then    
                    381:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                    382:       if [ -f $target ]; then
                    383:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                    384:       fi
                    385:     fi
                    386:   done
                    387: fi
                    388: 
                    389: exit 0

unix.superglobalmegacorp.com

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