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