source: trunk/third/gcc/fixinc.winnt @ 8834

Revision 8834, 5.6 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
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 (ian@airs.com)).
7#   Modifications by Douglas Rupp (drupp@cs.washington.edu)
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
38ORIG_DIR=`pwd`
39
40# Directory containing the original header files.
41cd $2; SEDFILE=`${PWDCMD-pwd}`/fixinc-nt.sed
42echo $SEDFILE
43if [ ! -f $SEDFILE ]
44then echo fixincludes: sed script 'fixinc-nt.sed' not found
45exit 1
46fi
47echo 'Using sed script: ' ${SEDFILE}
48
49cd $ORIG_DIR
50
51INPUT=${INCLUDE}
52echo 'Using the Include environment variable to find header files to fix'
53
54# Fail if no arg to specify a directory for the output.
55if [ x$1 = x ]
56then echo fixincludes: no output directory specified
57exit 1
58fi
59
60# Directory in which to store the results.
61LIB=${1?"fixincludes: output directory not specified"}
62
63# Make sure it exists.
64if [ ! -d $LIB ]; then
65  mkdir $LIB || exit 1
66fi
67
68ORIG_DIR=`pwd`
69
70# Make LIB absolute if it is relative.
71# Don't do this if not necessary, since may screw up automounters.
72case $LIB in
73/*)
74        ;;
75*)
76        cd $LIB; LIB=`${PWDCMD-pwd}`
77        ;;
78esac
79
80echo 'Building fixincludes in ' ${LIB}
81
82# Determine whether this filesystem has symbolic links.
83if ln -s X $LIB/ShouldNotExist 2>NUL; then
84  rm -f $LIB/ShouldNotExist
85  LINKS=true
86else
87  LINKS=false
88fi
89
90echo 'Making directories:'
91cd ${INPUT}
92if $LINKS; then
93  files=`ls -LR | sed -n s/:$//p`
94else
95  files=`find . -type d -print | sed '/^.$/d'`
96fi
97for file in $files; do
98  rm -rf $LIB/$file
99  if [ ! -d $LIB/$file ]
100  then mkdir $LIB/$file
101  fi
102done
103
104# treetops gets an alternating list
105# of old directories to copy
106# and the new directories to copy to.
107treetops="${INPUT} ${LIB}"
108
109set - $treetops
110while [ $# != 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
143done
144
145# Fix first broken decl of getcwd present on some svr4 systems.
146
147file=direct.h
148base=`basename $file`
149if [ -r ${LIB}/$file ]; then
150  file_to_fix=${LIB}/$file
151else
152  if [ -r ${INPUT}/$file ]; then
153    file_to_fix=${INPUT}/$file
154  else
155    file_to_fix=""
156  fi
157fi
158if [ \! -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
170fi
171
172file=rpcndr.h
173base=`basename $file`
174if [ -r ${LIB}/$file ]; then
175  file_to_fix=${LIB}/$file
176else
177  if [ -r ${INPUT}/$file ]; then
178    file_to_fix=${INPUT}/$file
179  else
180    file_to_fix=""
181  fi
182fi
183if [ \! -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
195fi
196
197file=winnt.h
198base=`basename $file`
199if [ -r ${LIB}/$file ]; then
200  file_to_fix=${LIB}/$file
201else
202  if [ -r ${INPUT}/$file ]; then
203    file_to_fix=${INPUT}/$file
204  else
205    file_to_fix=""
206  fi
207fi
208if [ \! -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
223fi
224
225echo 'Removing unneeded directories:'
226cd $LIB
227files=`find . -type d -print | sort -r`
228for file in $files; do
229  rmdir $LIB/$file > NUL 2>&1
230done
231
232exit 0
Note: See TracBrowser for help on using the repository browser.