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 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 # Directory containing the original header files.
28 INPUT=${2-${INPUT-/usr/include}}
30 # Fail if no arg to specify a directory for the output.
32 then echo fixincludes: no output directory specified
36 # Directory in which to store the results.
37 LIB=${1?"fixincludes: output directory not specified"}
39 # Make sure it exists.
40 if [ ! -d $LIB ]; then
46 # Make LIB absolute if it is relative.
47 # Don't do this if not necessary, since may screw up automounters.
56 echo 'Building fixincludes in ' ${LIB}
59 # Note: For Irix, we deliberately don't try to create the directory trees,
60 # since we only modify math.h, limits.h and unistd.h. If we
61 # ADD ANY OTHERS, the "Making directories:" and symlinks code from
62 # fixinc.svr4 may have to go back in.
64 # This math.h fix is copied from fixinc.wrap. We want to avoid copying
65 # math.h because both math.h and stdlib.h have a declaration for initstate,
66 # and this declaration changed between Irix 6.2 and Irix 6.3. If we copy this
67 # file, then the same toolchain can't be shared between 6.2 and 6.3+.
69 # Some math.h files define struct exception, which conflicts with
70 # the class exception defined in the C++ file std/stdexcept.h. We
71 # redefine it to __math_exception. This is not a great fix, but I
72 # haven't been able to think of anything better.
74 if [ -r $INPUT/$file ]; then
75 echo Checking $INPUT/$file
76 if grep 'struct exception' $INPUT/$file >/dev/null
80 cat <<'__EOF__' >$LIB/$file
81 #ifndef _MATH_H_WRAPPER
83 # define exception __math_exception
85 #include_next <math.h>
89 #define _MATH_H_WRAPPER
90 #endif /* _MATH_H_WRAPPER */
92 # Define _MATH_H_WRAPPER at the end of the wrapper, not the start,
93 # so that if #include_next gets another instance of the wrapper,
94 # this will follow the #include_next chain until we arrive at
100 # Avoid the definition of the bool type in curses.h when using
101 # g++, since it's now an official type in the C++ language.
103 # This is also from fixinc.wrap.
106 if [ -r $INPUT/$file ]; then
107 echo Checking $INPUT/$file
109 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev/null
113 cat <<'__EOF__' >$LIB/$file
114 #ifndef _CURSES_H_WRAPPER
116 # define bool __curses_bool_t
118 #include_next <curses.h>
122 #define _CURSES_H_WRAPPER
123 #endif /* _CURSES_H_WRAPPER */
125 # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
126 # so that if #include_next gets another instance of the wrapper,
127 # this will follow the #include_next chain until we arrive at
128 # the real <curses.h>.
133 # In limits.h, put #ifndefs around things that are supposed to be defined
134 # in float.h to avoid redefinition errors if float.h is included first.
137 base=`basename $file`
138 if [ -r ${LIB}/$file ]; then
139 file_to_fix=${LIB}/$file
141 if [ -r ${INPUT}/$file ]; then
142 file_to_fix=${INPUT}/$file
147 if [ \! -z "$file_to_fix" ]; then
148 echo Checking $file_to_fix
149 sed -e '/[ ]FLT_MIN[ ]/i\
152 -e '/[ ]FLT_MIN[ ]/a\
155 -e '/[ ]FLT_MAX[ ]/i\
158 -e '/[ ]FLT_MAX[ ]/a\
161 -e '/[ ]FLT_DIG[ ]/i\
164 -e '/[ ]FLT_DIG[ ]/a\
167 -e '/[ ]DBL_MIN[ ]/i\
170 -e '/[ ]DBL_MIN[ ]/a\
173 -e '/[ ]DBL_MAX[ ]/i\
176 -e '/[ ]DBL_MAX[ ]/a\
179 -e '/[ ]DBL_DIG[ ]/i\
182 -e '/[ ]DBL_DIG[ ]/a\
184 ' $file_to_fix > /tmp/$base
185 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
188 echo Fixed $file_to_fix
190 cp /tmp/$base ${LIB}/$file
191 chmod a+r ${LIB}/$file
196 # The Irix unistd.h will introduce a call to __vfork in its libc, but the
197 # function is never actually prototyped.
199 base=`basename $file`
200 if [ -r ${LIB}/$file ]; then
201 file_to_fix=${LIB}/$file
203 if [ -r ${INPUT}/$file ]; then
204 file_to_fix=${INPUT}/$file
209 if [ \! -z "$file_to_fix" ]; then
210 echo Checking $file_to_fix
212 extern pid_t __vfork(void);'\
213 $file_to_fix > /tmp/$base
214 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
217 echo Fixed $file_to_fix
219 cp /tmp/$base ${LIB}/$file
220 chmod a+r ${LIB}/$file