OSDN Git Service

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