Annotation of gcc/fixinc.sco, revision 1.1.1.1

1.1       root        1: #! /bin/sh
                      2: #
                      3: #   fixinc.sco  --  Install modified versions of SCO system include
                      4: #   files.
                      5: #
                      6: #   Based on fixinc.svr4 script by Ron Guilmette ([email protected]) (SCO
                      7: #   modifications by Ian Lance Taylor ([email protected])).
                      8: #
                      9: # This file is part of GNU CC.
                     10: # 
                     11: # GNU CC is free software; you can redistribute it and/or modify
                     12: # it under the terms of the GNU General Public License as published by
                     13: # the Free Software Foundation; either version 2, or (at your option)
                     14: # any later version.
                     15: # 
                     16: # GNU CC is distributed in the hope that it will be useful,
                     17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19: # GNU General Public License for more details.
                     20: # 
                     21: # You should have received a copy of the GNU General Public License
                     22: # along with GNU CC; see the file COPYING.  If not, write to
                     23: # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
                     24: #
                     25: #      This script munges the native include files provided with SCO
                     26: #      3.2v4 systems so as to provide a reasonable namespace when
                     27: #      compiling with gcc.  The header files by default do not
                     28: #      provide many essential definitions and declarations if
                     29: #      __STDC__ is 1.  This script modifies the header files to check
                     30: #      for __STRICT_ANSI__ being defined instead.  Once munged, the
                     31: #      resulting new system include files are placed in a directory
                     32: #      that GNU C will search *before* searching the /usr/include
                     33: #      directory.  This script should work properly for most SCO
                     34: #      3.2v4 systems.  For other types of systems, you should use the
                     35: #      `fixincludes' or the `fixinc.svr4' script instead.
                     36: #
                     37: #      See README-fixinc for more information.
                     38: 
                     39: # Directory where gcc sources (and sometimes special include files) live.
                     40: SRCDIR=${3-${SRCDIR-.}}
                     41: 
                     42: # Directory containing the original header files.
                     43: INPUT=${2-${INPUT-/usr/include}}
                     44: 
                     45: # Fail if no arg to specify a directory for the output.
                     46: if [ x$1 = x ]
                     47: then echo fixincludes: no output directory specified
                     48: exit 1
                     49: fi
                     50: 
                     51: # Directory in which to store the results.
                     52: LIB=${1?"fixincludes: output directory not specified"}
                     53: 
                     54: # Make sure it exists.
                     55: if [ ! -d $LIB ]; then
                     56:   mkdir $LIB || exit 1
                     57: fi
                     58: 
                     59: ORIG_DIR=`pwd`
                     60: 
                     61: # Make LIB absolute.
                     62: cd $LIB; LIB=`pwd`
                     63: 
                     64: # This prevents /bin/ex from failing if the current terminal type is
                     65: # unrecognizable.
                     66: TERM=dumb
                     67: export TERM
                     68: # This prevents /bin/ex from failing if the EXINIT environment variable
                     69: # was set to something invalid.
                     70: EXINIT=""
                     71: export EXINIT
                     72: 
                     73: echo 'Building fixincludes in ' ${LIB}
                     74: 
                     75: # Determine whether this filesystem has symbolic links.
                     76: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     77:   rm -f $LIB/ShouldNotExist
                     78:   LINKS=true
                     79: else
                     80:   LINKS=false
                     81: fi
                     82: 
                     83: echo 'Making directories:'
                     84: cd ${INPUT}
                     85: if $LINKS; then
                     86:   files=`ls -LR | sed -n s/:$//p`
                     87: else
                     88:   files=`find . -type d -print | sed '/^.$/d'`
                     89: fi
                     90: for file in $files; do
                     91:   rm -rf $LIB/$file
                     92:   if [ ! -d $LIB/$file ]
                     93:   then mkdir $LIB/$file
                     94:   fi
                     95: done
                     96: 
                     97: # treetops gets an alternating list
                     98: # of old directories to copy
                     99: # and the new directories to copy to.
                    100: treetops="${INPUT} ${LIB}"
                    101: 
                    102: if $LINKS; then
                    103:   echo 'Making internal symbolic directory links'
                    104:   for file in $files; do
                    105:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    106:     if [ "$dest" ]; then    
                    107:       cwd=`pwd`
                    108:       # In case $dest is relative, get to $file's dir first.
                    109:       cd ${INPUT}
                    110:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
                    111:       # Check that the target directory exists.
                    112:       # Redirections changed to avoid bug in sh on Ultrix.
                    113:       (cd $dest) > /dev/null 2>&1
                    114:       if [ $? = 0 ]; then
                    115:        cd $dest
                    116:        # X gets the dir that the link actually leads to.
                    117:        x=`pwd`
                    118:        # If link leads back into ${INPUT},
                    119:        # make a similar link here.
                    120:        if expr $x : "${INPUT}/.*" > /dev/null; then
                    121:          # Y gets the actual target dir name, relative to ${INPUT}.
                    122:          y=`echo $x | sed -n "s&${INPUT}/&&p"`
                    123:          echo $file '->' $y ': Making link'
                    124:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    125:          ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
                    126:        else
                    127:          # If the link is to outside ${INPUT},
                    128:          # treat this directory as if it actually contained the files.
                    129: # This line used to have $dest instead of $x.
                    130: # $dest seemed to be wrong for links found in subdirectories
                    131: # of ${INPUT}.  Does this change break anything?
                    132:          treetops="$treetops $x ${LIB}/$file"
                    133:        fi
                    134:       fi
                    135:       cd $cwd
                    136:     fi
                    137:   done
                    138: fi
                    139: 
                    140: set - $treetops
                    141: while [ $# != 0 ]; do
                    142:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
                    143:   echo "Finding header files in $1:"
                    144:   cd ${INPUT}
                    145:   cd $1
                    146:   files=`find . -name '*.h' -type f -print`
                    147:   echo 'Checking header files:'
                    148:   for file in $files; do
                    149:     if egrep '!__STDC__' $file >/dev/null; then
                    150:       echo Fixing $file
                    151:       if [ -r $file ]; then
                    152:        cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    153:        chmod +w $2/$file
                    154: 
                    155: # The following have been removed from the sed command below
                    156: # because it is more useful to leave these things in.
                    157: # The only reason to remove them was for -pedantic,
                    158: # which isn't much of a reason. -- rms.
                    159: #        /^[   ]*#[    ]*ident/d
                    160: 
                    161:        sed -e '
                    162:          s/!__STDC__/!defined (__STRICT_ANSI__)/g
                    163:        ' $2/$file > $2/$file.sed
                    164:        mv $2/$file.sed $2/$file
                    165:        if cmp $file $2/$file >/dev/null 2>&1; then
                    166:           echo Deleting $2/$file\; no fixes were needed.
                    167:           rm $2/$file
                    168:        fi
                    169:       fi
                    170:     fi
                    171:   done
                    172:   shift; shift
                    173: done
                    174: 
                    175: # Fix first broken decl of getcwd present on some svr4 systems.
                    176: 
                    177: file=stdlib.h
                    178: base=`basename $file`
                    179: if [ -r ${LIB}/$file ]; then
                    180:   file_to_fix=${LIB}/$file
                    181: else
                    182:   if [ -r ${INPUT}/$file ]; then
                    183:     file_to_fix=${INPUT}/$file
                    184:   else
                    185:     file_to_fix=""
                    186:   fi
                    187: fi
                    188: if [ \! -z "$file_to_fix" ]; then
                    189:   echo Checking $file_to_fix
                    190:   sed -e 's/getcwd(char \{0,\}\*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
                    191:   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
                    192:     echo No change needed in $file_to_fix
                    193:   else
                    194:     echo Fixed $file_to_fix
                    195:     rm -f ${LIB}/$file
                    196:     cp /tmp/$base ${LIB}/$file
                    197:   fi
                    198:   rm -f /tmp/$base
                    199: fi
                    200: 
                    201: # Fix second broken decl of getcwd present on some svr4 systems.  Also
                    202: # fix the incorrect decl of profil present on some svr4 systems.
                    203: 
                    204: file=unistd.h
                    205: base=`basename $file`
                    206: if [ -r ${LIB}/$file ]; then
                    207:   file_to_fix=${LIB}/$file
                    208: else
                    209:   if [ -r ${INPUT}/$file ]; then
                    210:     file_to_fix=${INPUT}/$file
                    211:   else
                    212:     file_to_fix=""
                    213:   fi
                    214: fi
                    215: if [ \! -z "$file_to_fix" ]; then
                    216:   echo Checking $file_to_fix
                    217:   sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
                    218:     | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
                    219:   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
                    220:     echo No change needed in $file_to_fix
                    221:   else
                    222:     echo Fixed $file_to_fix
                    223:     rm -f ${LIB}/$file
                    224:     cp /tmp/$base ${LIB}/$file
                    225:   fi
                    226:   rm -f /tmp/$base
                    227: fi
                    228: 
                    229: # Fix an error in this file: the #if says _cplusplus, not the double
                    230: # underscore __cplusplus that it should be
                    231: file=tinfo.h
                    232: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    233:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    234:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    235:   chmod +w ${LIB}/$file 2>/dev/null
                    236: fi
                    237: 
                    238: if [ -r ${LIB}/$file ]; then
                    239:   echo Fixing $file, __cplusplus macro
                    240:   sed -e 's/[  ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
                    241:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    242:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    243:     rm ${LIB}/$file
                    244:   fi
                    245: fi
                    246: 
                    247: echo 'Removing unneeded directories:'
                    248: cd $LIB
                    249: files=`find . -type d -print | sort -r`
                    250: for file in $files; do
                    251:   rmdir $LIB/$file > /dev/null 2>&1
                    252: done
                    253: 
                    254: if $LINKS; then
                    255:   echo 'Making internal symbolic non-directory links'
                    256:   cd ${INPUT}
                    257:   files=`find . -type l -print`
                    258:   for file in $files; do
                    259:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    260:     if expr "$dest" : '[^/].*' > /dev/null; then    
                    261:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                    262:       if [ -f $target ]; then
                    263:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                    264:       fi
                    265:     fi
                    266:   done
                    267: fi
                    268: 
                    269: cd ${ORIG_DIR}
                    270: 
                    271: echo 'Replacing <sys/byteorder.h>'
                    272: rm -f ${LIB}/sys/byteorder.h
                    273: cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
                    274: 
                    275: exit 0

unix.superglobalmegacorp.com

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