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 # In limits.h, put #ifndefs around things that are supposed to be defined
101 # in float.h to avoid redefinition errors if float.h is included first.
104 base=`basename $file`
105 if [ -r ${LIB}/$file ]; then
106 file_to_fix=${LIB}/$file
108 if [ -r ${INPUT}/$file ]; then
109 file_to_fix=${INPUT}/$file
114 if [ \! -z "$file_to_fix" ]; then
115 echo Checking $file_to_fix
116 sed -e '/[ ]FLT_MIN[ ]/i\
119 -e '/[ ]FLT_MIN[ ]/a\
122 -e '/[ ]FLT_MAX[ ]/i\
125 -e '/[ ]FLT_MAX[ ]/a\
128 -e '/[ ]FLT_DIG[ ]/i\
131 -e '/[ ]FLT_DIG[ ]/a\
134 -e '/[ ]DBL_MIN[ ]/i\
137 -e '/[ ]DBL_MIN[ ]/a\
140 -e '/[ ]DBL_MAX[ ]/i\
143 -e '/[ ]DBL_MAX[ ]/a\
146 -e '/[ ]DBL_DIG[ ]/i\
149 -e '/[ ]DBL_DIG[ ]/a\
151 ' $file_to_fix > /tmp/$base
152 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
155 echo Fixed $file_to_fix
157 cp /tmp/$base ${LIB}/$file
158 chmod a+r ${LIB}/$file
163 # The Irix unistd.h will introduce a call to __vfork in its libc, but the
164 # function is never actually prototyped.
166 base=`basename $file`
167 if [ -r ${LIB}/$file ]; then
168 file_to_fix=${LIB}/$file
170 if [ -r ${INPUT}/$file ]; then
171 file_to_fix=${INPUT}/$file
176 if [ \! -z "$file_to_fix" ]; then
177 echo Checking $file_to_fix
179 extern pid_t __vfork(void);'\
180 $file_to_fix > /tmp/$base
181 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
184 echo Fixed $file_to_fix
186 cp /tmp/$base ${LIB}/$file
187 chmod a+r ${LIB}/$file