Annotation of GNUtools/cc/fixinc.dgux, revision 1.1

1.1     ! root        1: #!/bin/sh
        !             2: #
        !             3: # modified for dgux by [email protected] based on
        !             4: #
        !             5: #   fixinc.svr4  written by Ron Guilmette ([email protected]).
        !             6: #
        !             7: # This file is part of GNU CC.
        !             8: # 
        !             9: # GNU CC is free software; you can redistribute it and/or modify
        !            10: # it under the terms of the GNU General Public License as published by
        !            11: # the Free Software Foundation; either version 2, or (at your option)
        !            12: # any later version.
        !            13: # 
        !            14: # GNU CC is distributed in the hope that it will be useful,
        !            15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            17: # GNU General Public License for more details.
        !            18: # 
        !            19: # You should have received a copy of the GNU General Public License
        !            20: # along with GNU CC; see the file COPYING.  If not, write to
        !            21: # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
        !            22: #
        !            23: #
        !            24: #      See README-fixinc for more information.
        !            25: 
        !            26: # Directory where gcc sources (and sometimes special include files) live.
        !            27: SRCDIR=${3-${SRCDIR-.}}
        !            28: 
        !            29: # Directory containing the original header files.
        !            30: INPUT=${2-${INPUT-/usr/include}}
        !            31: 
        !            32: # Fail if no arg to specify a directory for the output.
        !            33: if [ x$1 = x ]
        !            34: then echo fixincludes: no output directory specified
        !            35: exit 1
        !            36: fi
        !            37: 
        !            38: # Directory in which to store the results.
        !            39: LIB=${1?"fixincludes: output directory not specified"}
        !            40: 
        !            41: # Make sure it exists.
        !            42: if [ ! -d $LIB ]; then
        !            43:   mkdir $LIB || exit 1
        !            44: fi
        !            45: 
        !            46: ORIG_DIR=`pwd`
        !            47: 
        !            48: # Make LIB absolute if it is relative.
        !            49: # Don't do this if not necessary, since may screw up automounters.
        !            50: case $LIB in
        !            51: /*)
        !            52:        ;;
        !            53: *)
        !            54:        cd $LIB; LIB=`${PWDCMD-pwd}`
        !            55:        ;;
        !            56: esac
        !            57: 
        !            58: echo 'Building fixincludes in ' ${LIB}
        !            59: 
        !            60: # Determine whether this filesystem has symbolic links.
        !            61: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
        !            62:   rm -f $LIB/ShouldNotExist
        !            63:   LINKS=true
        !            64: else
        !            65:   LINKS=false
        !            66: fi
        !            67: 
        !            68: echo 'Making directories:'
        !            69: cd ${INPUT}
        !            70: if $LINKS; then
        !            71:   files=`ls -LR | sed -n s/:$//p`
        !            72: else
        !            73:   files=`find . -type d -print | sed '/^.$/d'`
        !            74: fi
        !            75: for file in $files; do
        !            76:   rm -rf $LIB/$file
        !            77:   if [ ! -d $LIB/$file ]
        !            78:   then mkdir $LIB/$file
        !            79:   fi
        !            80: done
        !            81: 
        !            82: # treetops gets an alternating list
        !            83: # of old directories to copy
        !            84: # and the new directories to copy to.
        !            85: treetops="${INPUT} ${LIB}"
        !            86: 
        !            87: if $LINKS; then
        !            88:   echo 'Making internal symbolic directory links'
        !            89:   for file in $files; do
        !            90:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
        !            91:     if [ "$dest" ]; then    
        !            92:       cwd=`pwd`
        !            93:       # In case $dest is relative, get to $file's dir first.
        !            94:       cd ${INPUT}
        !            95:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
        !            96:       # Check that the target directory exists.
        !            97:       # Redirections changed to avoid bug in sh on Ultrix.
        !            98:       (cd $dest) > /dev/null 2>&1
        !            99:       if [ $? = 0 ]; then
        !           100:        cd $dest
        !           101:        # X gets the dir that the link actually leads to.
        !           102:        x=`pwd`
        !           103:        # If link leads back into ${INPUT},
        !           104:        # make a similar link here.
        !           105:        if expr $x : "${INPUT}/.*" > /dev/null; then
        !           106:          # Y gets the actual target dir name, relative to ${INPUT}.
        !           107:          y=`echo $x | sed -n "s&${INPUT}/&&p"`
        !           108:          # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
        !           109:          dots=`echo "$file" |
        !           110:            sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
        !           111:          echo $file '->' $dots$y ': Making link'
        !           112:          rm -fr ${LIB}/$file > /dev/null 2>&1
        !           113:          ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
        !           114:        else
        !           115:          # If the link is to outside ${INPUT},
        !           116:          # treat this directory as if it actually contained the files.
        !           117: # This line used to have $dest instead of $x.
        !           118: # $dest seemed to be wrong for links found in subdirectories
        !           119: # of ${INPUT}.  Does this change break anything?
        !           120:          treetops="$treetops $x ${LIB}/$file"
        !           121:        fi
        !           122:       fi
        !           123:       cd $cwd
        !           124:     fi
        !           125:   done
        !           126: fi
        !           127: 
        !           128: # Completely replace <_int_varargs.h> with a file that defines
        !           129: # va_list and gnuc_va_list
        !           130: 
        !           131: file=_int_varargs.h
        !           132: if [ -r ${INPUT}/$file ]; then
        !           133:   echo Replacing $file
        !           134:   cat > ${LIB}/$file << EOF
        !           135: /* This file was generated by fixinc.dgux.  */
        !           136: #ifndef __INT_VARARGS_H
        !           137: #define __INT_VARARGS_H
        !           138: 
        !           139: #if defined(__m88k__) && defined (__DGUX__)
        !           140: #ifndef __GNUC_VA_LIST
        !           141: #define __GNUC_VA_LIST
        !           142: typedef struct
        !           143: {
        !           144:   int  __va_arg;               /* argument number */
        !           145:   int *__va_stk;               /* start of args passed on stack */
        !           146:   int *__va_reg;               /* start of args passed in regs */
        !           147: } __gnuc_va_list;
        !           148: #endif /* not __GNUC_VA_LIST */
        !           149: #endif /* 88k && dgux */
        !           150: 
        !           151: #ifndef _VA_LIST_
        !           152: #define _VA_LIST_
        !           153: typedef __gnuc_va_list va_list;
        !           154: #endif /* _VA_LIST_ */
        !           155: 
        !           156: #endif /* __INT_VARARGS_H */
        !           157: 
        !           158: EOF
        !           159:   chmod a+r ${LIB}/$file
        !           160: fi
        !           161: 
        !           162: echo 'Removing unneeded directories:'
        !           163: cd $LIB
        !           164: files=`find . -type d -print | sort -r`
        !           165: for file in $files; do
        !           166:   rmdir $LIB/$file > /dev/null 2>&1
        !           167: done
        !           168: 
        !           169: if $LINKS; then
        !           170:   echo 'Making internal symbolic non-directory links'
        !           171:   cd ${INPUT}
        !           172:   files=`find . -type l -print`
        !           173:   for file in $files; do
        !           174:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
        !           175:     if expr "$dest" : '[^/].*' > /dev/null; then    
        !           176:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
        !           177:       if [ -f $target ]; then
        !           178:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
        !           179:       fi
        !           180:     fi
        !           181:   done
        !           182: fi
        !           183: 
        !           184: cd ${ORIG_DIR}
        !           185: 
        !           186: exit 0
        !           187: 

unix.superglobalmegacorp.com

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