2 # Install modified versions of certain problematic Irix include files.
3 # If possible, create a wrapper (see fixinc.wrap) instead of copying files.
5 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
6 # Contributed by Brendan Kehoe (brendan@cygnus.com).
8 # This file is part of GNU CC.
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)
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.
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.
25 # See README-fixinc for more information.
27 # Fail if no arg to specify a directory for the output.
29 then echo fixincludes
: no output directory specified
33 # Directory in which to store the results.
34 LIB
=${1?"fixincludes: output directory not specified"}
36 # Make sure it exists.
37 if [ ! -d $LIB ]; then
41 ORIG_DIR
=`${PWDCMD-pwd}`
43 # Make LIB absolute if it is relative.
44 # Don't do this if not necessary, since may screw up automounters.
49 cd $LIB; LIB
=`${PWDCMD-pwd}`
53 echo 'Building fixincludes in ' ${LIB}
54 # Directory containing the original header files.
56 if [ $# -eq 0 ] ; then
62 for INPUT
in ${INLIST} ; do
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.
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+.
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.
82 if [ -r $INPUT/$file ]; then
83 echo Checking
$INPUT/$file
84 if grep 'struct exception' $INPUT/$file >/dev
/null
88 cat <<'__EOF__' >$LIB/$file
89 #ifndef _MATH_H_WRAPPER
91 # define exception __math_exception
93 #include_next <math.h>
97 #define _MATH_H_WRAPPER
98 #endif /* _MATH_H_WRAPPER */
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
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.
111 # This is also from fixinc.wrap.
114 if [ -r $INPUT/$file ]; then
115 echo Checking
$INPUT/$file
117 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev
/null
121 cat <<'__EOF__' >$LIB/$file
122 #ifndef _CURSES_H_WRAPPER
124 # define bool __curses_bool_t
126 #include_next <curses.h>
130 #define _CURSES_H_WRAPPER
131 #endif /* _CURSES_H_WRAPPER */
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>.
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.
145 base
=`basename $file`.$$
146 if [ -r ${LIB}/$file ]; then
147 file_to_fix
=${LIB}/$file
149 if [ -r ${INPUT}/$file ]; then
150 file_to_fix
=${INPUT}/$file
155 if [ \
! -z "$file_to_fix" ]; then
156 echo Checking
$file_to_fix
157 sed -e '/[ ]FLT_MIN[ ]/i\
160 -e '/[ ]FLT_MIN[ ]/a\
163 -e '/[ ]FLT_MAX[ ]/i\
166 -e '/[ ]FLT_MAX[ ]/a\
169 -e '/[ ]FLT_DIG[ ]/i\
172 -e '/[ ]FLT_DIG[ ]/a\
175 -e '/[ ]DBL_MIN[ ]/i\
178 -e '/[ ]DBL_MIN[ ]/a\
181 -e '/[ ]DBL_MAX[ ]/i\
184 -e '/[ ]DBL_MAX[ ]/a\
187 -e '/[ ]DBL_DIG[ ]/i\
190 -e '/[ ]DBL_DIG[ ]/a\
192 ' $file_to_fix > /tmp
/$base
193 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
196 echo Fixed
$file_to_fix
198 cp /tmp
/$base ${LIB}/$file
199 chmod a
+r
${LIB}/$file
204 # The Irix unistd.h will introduce a call to __vfork in its libc, but the
205 # function is never actually prototyped.
207 base
=`basename $file`.$$
208 if [ -r ${LIB}/$file ]; then
209 file_to_fix
=${LIB}/$file
211 if [ -r ${INPUT}/$file ]; then
212 file_to_fix
=${INPUT}/$file
217 if [ \
! -z "$file_to_fix" ]; then
218 echo Checking
$file_to_fix
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 \
225 echo Fixed
$file_to_fix
227 cp /tmp
/$base ${LIB}/$file
228 chmod a
+r
${LIB}/$file
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
239 base
=`basename $file`.$$
240 if [ -r ${LIB}/$file ]; then
241 file_to_fix
=${LIB}/$file
243 if [ -r ${INPUT}/$file ]; then
244 file_to_fix
=${INPUT}/$file
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
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
267 cp /tmp
/$base ${LIB}/$file
268 chmod a
+r
${LIB}/$file
272 if [ x
${INSTALL_ASSERT_H} != x
]
275 rm -f include
/assert.h
276 cp ${srcdir}/assert.h include
/assert.h ||
exit 1
277 chmod a
+r include
/assert.h