]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc/fixinc.irix
cppinit.c (cpp_start_read): Turn off -Wtraditional if processing C++.
[gcc.git] / gcc / fixinc / fixinc.irix
1 #! /bin/sh
2 # Install modified versions of certain problematic Irix include files.
3 # If possible, create a wrapper (see fixinc.wrap) instead of copying files.
4 #
5 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
6 # Contributed by Brendan Kehoe (brendan@cygnus.com).
7 #
8 # This file is part of GNU CC.
9 #
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
13 # any later version.
14 #
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 59 Temple Place - Suite 330,
23 # Boston, MA 02111-1307, USA.
24 #
25 # See README-fixinc for more information.
26
27 # Fail if no arg to specify a directory for the output.
28 if [ x$1 = x ]
29 then echo fixincludes: no output directory specified
30 exit 1
31 fi
32
33 # Directory in which to store the results.
34 LIB=${1?"fixincludes: output directory not specified"}
35
36 # Make sure it exists.
37 if [ ! -d $LIB ]; then
38 mkdir $LIB || exit 1
39 fi
40
41 ORIG_DIR=`${PWDCMD-pwd}`
42
43 # Make LIB absolute if it is relative.
44 # Don't do this if not necessary, since may screw up automounters.
45 case $LIB in
46 /*)
47 ;;
48 *)
49 cd $LIB; LIB=`${PWDCMD-pwd}`
50 ;;
51 esac
52
53 echo 'Building fixincludes in ' ${LIB}
54 # Directory containing the original header files.
55 shift
56 if [ $# -eq 0 ] ; then
57 set /usr/include
58 fi
59
60 INLIST="$@"
61
62 for INPUT in ${INLIST} ; do
63 cd ${ORIG_DIR}
64 cd ${INPUT}
65
66 #
67 # Note: For Irix, we deliberately don't try to create the directory trees,
68 # since we only modify math.h, limits.h and unistd.h. If we
69 # ADD ANY OTHERS, the "Making directories:" and symlinks code from
70 # fixinc.svr4 may have to go back in.
71
72 # This math.h fix is copied from fixinc.wrap. We want to avoid copying
73 # math.h because both math.h and stdlib.h have a declaration for initstate,
74 # and this declaration changed between Irix 6.2 and Irix 6.3. If we copy this
75 # file, then the same toolchain can't be shared between 6.2 and 6.3+.
76
77 # Some math.h files define struct exception, which conflicts with
78 # the class exception defined in the C++ file std/stdexcept.h. We
79 # redefine it to __math_exception. This is not a great fix, but I
80 # haven't been able to think of anything better.
81 file=math.h
82 if [ -r $INPUT/$file ]; then
83 echo Checking $INPUT/$file
84 if grep 'struct exception' $INPUT/$file >/dev/null
85 then
86 echo Fixed $file
87 rm -f $LIB/$file
88 cat <<'__EOF__' >$LIB/$file
89 #ifndef _MATH_H_WRAPPER
90 #ifdef __cplusplus
91 # define exception __math_exception
92 #endif
93 #include_next <math.h>
94 #ifdef __cplusplus
95 # undef exception
96 #endif
97 #define _MATH_H_WRAPPER
98 #endif /* _MATH_H_WRAPPER */
99 __EOF__
100 # Define _MATH_H_WRAPPER at the end of the wrapper, not the start,
101 # so that if #include_next gets another instance of the wrapper,
102 # this will follow the #include_next chain until we arrive at
103 # the real <math.h>.
104 chmod a+r $LIB/$file
105 fi
106 fi
107
108 # Avoid the definition of the bool type in curses.h when using
109 # g++, since it's now an official type in the C++ language.
110
111 # This is also from fixinc.wrap.
112
113 file=curses.h
114 if [ -r $INPUT/$file ]; then
115 echo Checking $INPUT/$file
116 w='[ ]'
117 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev/null
118 then
119 echo Fixed $file
120 rm -f $LIB/$file
121 cat <<'__EOF__' >$LIB/$file
122 #ifndef _CURSES_H_WRAPPER
123 #ifdef __cplusplus
124 # define bool __curses_bool_t
125 #endif
126 #include_next <curses.h>
127 #ifdef __cplusplus
128 # undef bool
129 #endif
130 #define _CURSES_H_WRAPPER
131 #endif /* _CURSES_H_WRAPPER */
132 __EOF__
133 # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
134 # so that if #include_next gets another instance of the wrapper,
135 # this will follow the #include_next chain until we arrive at
136 # the real <curses.h>.
137 chmod a+r $LIB/$file
138 fi
139 fi
140
141 # In limits.h, put #ifndefs around things that are supposed to be defined
142 # in float.h to avoid redefinition errors if float.h is included first.
143
144 file=limits.h
145 base=`basename $file`.$$
146 if [ -r ${LIB}/$file ]; then
147 file_to_fix=${LIB}/$file
148 else
149 if [ -r ${INPUT}/$file ]; then
150 file_to_fix=${INPUT}/$file
151 else
152 file_to_fix=""
153 fi
154 fi
155 if [ \! -z "$file_to_fix" ]; then
156 echo Checking $file_to_fix
157 sed -e '/[ ]FLT_MIN[ ]/i\
158 #ifndef FLT_MIN
159 '\
160 -e '/[ ]FLT_MIN[ ]/a\
161 #endif
162 '\
163 -e '/[ ]FLT_MAX[ ]/i\
164 #ifndef FLT_MAX
165 '\
166 -e '/[ ]FLT_MAX[ ]/a\
167 #endif
168 '\
169 -e '/[ ]FLT_DIG[ ]/i\
170 #ifndef FLT_DIG
171 '\
172 -e '/[ ]FLT_DIG[ ]/a\
173 #endif
174 '\
175 -e '/[ ]DBL_MIN[ ]/i\
176 #ifndef DBL_MIN
177 '\
178 -e '/[ ]DBL_MIN[ ]/a\
179 #endif
180 '\
181 -e '/[ ]DBL_MAX[ ]/i\
182 #ifndef DBL_MAX
183 '\
184 -e '/[ ]DBL_MAX[ ]/a\
185 #endif
186 '\
187 -e '/[ ]DBL_DIG[ ]/i\
188 #ifndef DBL_DIG
189 '\
190 -e '/[ ]DBL_DIG[ ]/a\
191 #endif
192 ' $file_to_fix > /tmp/$base
193 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
194 true
195 else
196 echo Fixed $file_to_fix
197 rm -f ${LIB}/$file
198 cp /tmp/$base ${LIB}/$file
199 chmod a+r ${LIB}/$file
200 fi
201 rm -f /tmp/$base
202 fi
203
204 # The Irix unistd.h will introduce a call to __vfork in its libc, but the
205 # function is never actually prototyped.
206 file=unistd.h
207 base=`basename $file`.$$
208 if [ -r ${LIB}/$file ]; then
209 file_to_fix=${LIB}/$file
210 else
211 if [ -r ${INPUT}/$file ]; then
212 file_to_fix=${INPUT}/$file
213 else
214 file_to_fix=""
215 fi
216 fi
217 if [ \! -z "$file_to_fix" ]; then
218 echo Checking $file_to_fix
219 sed -e '/__vfork/i\
220 extern pid_t __vfork(void);'\
221 $file_to_fix > /tmp/$base
222 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
223 true
224 else
225 echo Fixed $file_to_fix
226 rm -f ${LIB}/$file
227 cp /tmp/$base ${LIB}/$file
228 chmod a+r ${LIB}/$file
229 fi
230 rm -f /tmp/$base
231 fi
232
233 done
234
235 # Don't use or define the name va_list in stdio.h.
236 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
237 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
238 file=stdio.h
239 base=`basename $file`.$$
240 if [ -r ${LIB}/$file ]; then
241 file_to_fix=${LIB}/$file
242 else
243 if [ -r ${INPUT}/$file ]; then
244 file_to_fix=${INPUT}/$file
245 else
246 file_to_fix=""
247 fi
248 fi
249 if [ \! -z "$file_to_fix" ]; then
250 echo Fixing $file_to_fix
251 echo "#define __need___va_list" > /tmp/$base
252 echo "#include <stdarg.h>" >> /tmp/$base
253
254 sed -e 's@ va_list @ __gnuc_va_list @' \
255 -e 's@ va_list)@ __gnuc_va_list)@' \
256 -e 's@ _BSD_VA_LIST_))@ __gnuc_va_list))@' \
257 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
258 -e 's@ va_list@ __not_va_list__@' \
259 -e 's@\*va_list@*__not_va_list__@' \
260 -e 's@ __va_list)@ __gnuc_va_list)@' \
261 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
262 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
263 -e 's@VA_LIST@DUMMY_VA_LIST@' \
264 -e 's@_Va_LIST@_VA_LIST@' $file_to_fix >> /tmp/$base
265 echo Fixed $file_to_fix
266 rm -f ${LIB}/$file
267 cp /tmp/$base ${LIB}/$file
268 chmod a+r ${LIB}/$file
269 rm -f /tmp/$base
270 fi
271
272 if [ x${INSTALL_ASSERT_H} != x ]
273 then
274 cd ${ORIG_DIR}
275 rm -f include/assert.h
276 cp ${srcdir}/assert.h include/assert.h || exit 1
277 chmod a+r include/assert.h
278 fi
279
280 exit 0
This page took 0.048984 seconds and 5 git commands to generate.