Annotation of gcc/fixinc.winnt, revision 1.1.1.1

1.1       root        1: #! sh
                      2: #
                      3: #   fixinc.winnt  --  Install modified versions of Windows NT system include
                      4: #   files.
                      5: #
                      6: #   Based on fixinc.sco script by Ian Lance Taylor ([email protected])).
                      7: #   Modifications by Douglas Rupp ([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, 59 Temple Place - Suite 330,
                     24: # Boston, MA 02111-1307, USA.
                     25: #
                     26: #      This script munges the native include files provided with Windows NT
                     27: #      3.5 SDK systems so as to provide a reasonable namespace when
                     28: #      compiling with gcc.  The header files by default do not
                     29: #      provide many essential definitions and declarations if
                     30: #      __STDC__ is 1.  This script modifies the header files to check
                     31: #      for __STRICT_ANSI__ being defined instead.  Once munged, the
                     32: #      resulting new system include files are placed in a directory
                     33: #      that GNU C will search *before* searching the Include
                     34: #      directory.
                     35: #
                     36: #      See README-fixinc for more information.
                     37: 
                     38: ORIG_DIR=`pwd`
                     39: 
                     40: # Directory containing the original header files.
                     41: cd $2; SEDFILE=`${PWDCMD-pwd}`/fixinc-nt.sed
                     42: echo $SEDFILE
                     43: if [ ! -f $SEDFILE ]
                     44: then echo fixincludes: sed script 'fixinc-nt.sed' not found
                     45: exit 1
                     46: fi
                     47: echo 'Using sed script: ' ${SEDFILE}
                     48: 
                     49: cd $ORIG_DIR
                     50: 
                     51: INPUT=${INCLUDE}
                     52: echo 'Using the Include environment variable to find header files to fix'
                     53: 
                     54: # Fail if no arg to specify a directory for the output.
                     55: if [ x$1 = x ]
                     56: then echo fixincludes: no output directory specified
                     57: exit 1
                     58: fi
                     59: 
                     60: # Directory in which to store the results.
                     61: LIB=${1?"fixincludes: output directory not specified"}
                     62: 
                     63: # Make sure it exists.
                     64: if [ ! -d $LIB ]; then
                     65:   mkdir $LIB || exit 1
                     66: fi
                     67: 
                     68: ORIG_DIR=`pwd`
                     69: 
                     70: # Make LIB absolute if it is relative.
                     71: # Don't do this if not necessary, since may screw up automounters.
                     72: case $LIB in
                     73: /*)
                     74:        ;;
                     75: *)
                     76:        cd $LIB; LIB=`${PWDCMD-pwd}`
                     77:        ;;
                     78: esac
                     79: 
                     80: echo 'Building fixincludes in ' ${LIB}
                     81: 
                     82: # Determine whether this filesystem has symbolic links.
                     83: if ln -s X $LIB/ShouldNotExist 2>NUL; then
                     84:   rm -f $LIB/ShouldNotExist
                     85:   LINKS=true
                     86: else
                     87:   LINKS=false
                     88: fi
                     89: 
                     90: echo 'Making directories:'
                     91: cd ${INPUT}
                     92: if $LINKS; then
                     93:   files=`ls -LR | sed -n s/:$//p`
                     94: else
                     95:   files=`find . -type d -print | sed '/^.$/d'`
                     96: fi
                     97: for file in $files; do
                     98:   rm -rf $LIB/$file
                     99:   if [ ! -d $LIB/$file ]
                    100:   then mkdir $LIB/$file
                    101:   fi
                    102: done
                    103: 
                    104: # treetops gets an alternating list
                    105: # of old directories to copy
                    106: # and the new directories to copy to.
                    107: treetops="${INPUT} ${LIB}"
                    108: 
                    109: set - $treetops
                    110: while [ $# != 0 ]; do
                    111:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
                    112:   echo "Finding header files in $1:"
                    113:   cd ${INPUT}
                    114:   cd $1
                    115:   files=`find . -name '*.[hH]' -type f -print`
                    116:   echo 'Checking header files:'
                    117:   for file in $files; do
                    118:     echo $file
                    119:     if egrep "!__STDC__" $file >NUL; then
                    120:       if [ -r $file ]; then
                    121:        cp $file $2/$file >NUL 2>&1 || echo "Can't copy $file"
                    122:        chmod +w,a+r $2/$file
                    123: 
                    124: # The following have been removed from the sed command below
                    125: # because it is more useful to leave these things in.
                    126: # The only reason to remove them was for -pedantic,
                    127: # which isn't much of a reason. -- rms.
                    128: #        /^[   ]*#[    ]*ident/d
                    129: 
                    130:        sed -e '
                    131:          s/!__STDC__/!defined (__STRICT_ANSI__)/g
                    132:        ' $2/$file > $2/$file.sed
                    133:        mv $2/$file.sed $2/$file
                    134:        if cmp $file $2/$file >NUL 2>&1; then
                    135:           rm $2/$file
                    136:        else
                    137:           echo Fixed $file
                    138:        fi
                    139:       fi
                    140:     fi
                    141:   done
                    142:   shift; shift
                    143: done
                    144: 
                    145: # Fix first broken decl of getcwd present on some svr4 systems.
                    146: 
                    147: file=direct.h
                    148: base=`basename $file`
                    149: if [ -r ${LIB}/$file ]; then
                    150:   file_to_fix=${LIB}/$file
                    151: else
                    152:   if [ -r ${INPUT}/$file ]; then
                    153:     file_to_fix=${INPUT}/$file
                    154:   else
                    155:     file_to_fix=""
                    156:   fi
                    157: fi
                    158: if [ \! -z "$file_to_fix" ]; then
                    159:   echo Checking $file_to_fix
                    160:   sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
                    161:   if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
                    162:     true
                    163:   else
                    164:     echo Fixed $file_to_fix
                    165:     rm -f ${LIB}/$file
                    166:     cp /tmp/$base ${LIB}/$file
                    167:     chmod a+r ${LIB}/$file
                    168:   fi
                    169:   rm -f /tmp/$base
                    170: fi
                    171: 
                    172: file=rpcndr.h
                    173: base=`basename $file`
                    174: if [ -r ${LIB}/$file ]; then
                    175:   file_to_fix=${LIB}/$file
                    176: else
                    177:   if [ -r ${INPUT}/$file ]; then
                    178:     file_to_fix=${INPUT}/$file
                    179:   else
                    180:     file_to_fix=""
                    181:   fi
                    182: fi
                    183: if [ \! -z "$file_to_fix" ]; then
                    184:   echo Checking $file_to_fix
                    185:   sed -e 's/Format\[\]/Format\[1\]/' $file_to_fix > /tmp/$base
                    186:   if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
                    187:     true
                    188:   else
                    189:     echo Fixed $file_to_fix
                    190:     rm -f ${LIB}/$file
                    191:     cp /tmp/$base ${LIB}/$file
                    192:     chmod a+r ${LIB}/$file
                    193:   fi
                    194:   rm -f /tmp/$base
                    195: fi
                    196: 
                    197: file=winnt.h
                    198: base=`basename $file`
                    199: if [ -r ${LIB}/$file ]; then
                    200:   file_to_fix=${LIB}/$file
                    201: else
                    202:   if [ -r ${INPUT}/$file ]; then
                    203:     file_to_fix=${INPUT}/$file
                    204:   else
                    205:     file_to_fix=""
                    206:   fi
                    207: fi
                    208: if [ \! -z "$file_to_fix" ]; then
                    209:   echo Checking $file_to_fix
                    210:   sed -e '
                    211:     s/^#if !defined (__cplusplus)/#if 0/
                    212:     s/^#define DECLSPEC_IMPORT __declspec(dllimport)/#define DECLSPEC_IMPORT/
                    213:   ' $file_to_fix > /tmp/$base
                    214:   if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
                    215:     true
                    216:   else
                    217:     echo Fixed $file_to_fix
                    218:     rm -f ${LIB}/$file
                    219:     cp /tmp/$base ${LIB}/$file
                    220:     chmod a+r ${LIB}/$file
                    221:   fi
                    222:   rm -f /tmp/$base
                    223: fi
                    224: 
                    225: echo 'Removing unneeded directories:'
                    226: cd $LIB
                    227: files=`find . -type d -print | sort -r`
                    228: for file in $files; do
                    229:   rmdir $LIB/$file > NUL 2>&1
                    230: done
                    231: 
                    232: exit 0

unix.superglobalmegacorp.com

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