* ropeimpl.h: Check __STL_PTHREADS instead of _PTHREADS.
[official-gcc.git] / gcc / fixinc.irix
blob337289a121edff8b8e398f3bc039f7fc244b6e8d
1 #! /bin/sh
2 # Install modified versions of certain problematic Irix include files.
3 # Copyright (C) 1997 Free Software Foundation, Inc.
4 # Contributed by Brendan Kehoe (brendan@cygnus.com).
6 # This file is part of GNU CC.
7 #
8 # GNU CC is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
13 # GNU CC is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU CC; see the file COPYING. If not, write to
20 # the Free Software Foundation, 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
23 # See README-fixinc for more information.
25 # Directory containing the original header files.
26 INPUT=${2-${INPUT-/usr/include}}
28 # Fail if no arg to specify a directory for the output.
29 if [ x$1 = x ]
30 then echo fixincludes: no output directory specified
31 exit 1
34 # Directory in which to store the results.
35 LIB=${1?"fixincludes: output directory not specified"}
37 # Make sure it exists.
38 if [ ! -d $LIB ]; then
39 mkdir $LIB || exit 1
42 ORIG_DIR=`pwd`
44 # Make LIB absolute if it is relative.
45 # Don't do this if not necessary, since may screw up automounters.
46 case $LIB in
47 /*)
50 LIB=$ORIG_DIR/$LIB
52 esac
54 echo 'Building fixincludes in ' ${LIB}
57 # Note: For Irix, we deliberately don't try to create the directory trees,
58 # since we only modify math.h, limits.h and unistd.h. If we
59 # ADD ANY OTHERS, the "Making directories:" and symlinks code from
60 # fixinc.svr4 may have to go back in.
62 # The Irix math.h defines struct exception, which conflicts with
63 # the class exception defined in the C++ file std/stdexcept.h. We
64 # redefine it to __math_exception. This is not a great fix, but I
65 # haven't been able to think of anything better.
66 file=math.h
67 base=`basename $file`
68 if [ -r ${LIB}/$file ]; then
69 file_to_fix=${LIB}/$file
70 else
71 if [ -r ${INPUT}/$file ]; then
72 file_to_fix=${INPUT}/$file
73 else
74 file_to_fix=""
77 if [ \! -z "$file_to_fix" ]; then
78 echo Checking $file_to_fix
79 sed -e '/struct exception/i\
80 #ifdef __cplusplus\
81 #define exception __math_exception\
82 #endif'\
83 -e '/struct exception/a\
84 #ifdef __cplusplus\
85 #undef exception\
86 #endif' $file_to_fix > /tmp/$base
87 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
88 true
89 else
90 echo Fixed $file_to_fix
91 rm -f ${LIB}/$file
92 cp /tmp/$base ${LIB}/$file
93 chmod a+r ${LIB}/$file
95 rm -f /tmp/$base
98 # In limits.h, put #ifndefs around things that are supposed to be defined
99 # in float.h to avoid redefinition errors if float.h is included first.
101 file=limits.h
102 base=`basename $file`
103 if [ -r ${LIB}/$file ]; then
104 file_to_fix=${LIB}/$file
105 else
106 if [ -r ${INPUT}/$file ]; then
107 file_to_fix=${INPUT}/$file
108 else
109 file_to_fix=""
112 if [ \! -z "$file_to_fix" ]; then
113 echo Checking $file_to_fix
114 sed -e '/[ ]FLT_MIN[ ]/i\
115 #ifndef FLT_MIN
117 -e '/[ ]FLT_MIN[ ]/a\
118 #endif
120 -e '/[ ]FLT_MAX[ ]/i\
121 #ifndef FLT_MAX
123 -e '/[ ]FLT_MAX[ ]/a\
124 #endif
126 -e '/[ ]FLT_DIG[ ]/i\
127 #ifndef FLT_DIG
129 -e '/[ ]FLT_DIG[ ]/a\
130 #endif
132 -e '/[ ]DBL_MIN[ ]/i\
133 #ifndef DBL_MIN
135 -e '/[ ]DBL_MIN[ ]/a\
136 #endif
138 -e '/[ ]DBL_MAX[ ]/i\
139 #ifndef DBL_MAX
141 -e '/[ ]DBL_MAX[ ]/a\
142 #endif
144 -e '/[ ]DBL_DIG[ ]/i\
145 #ifndef DBL_DIG
147 -e '/[ ]DBL_DIG[ ]/a\
148 #endif
149 ' $file_to_fix > /tmp/$base
150 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
151 true
152 else
153 echo Fixed $file_to_fix
154 rm -f ${LIB}/$file
155 cp /tmp/$base ${LIB}/$file
156 chmod a+r ${LIB}/$file
158 rm -f /tmp/$base
161 # The Irix unistd.h will introduce a call to __vfork in its libc, but the
162 # function is never actually prototyped.
163 file=unistd.h
164 base=`basename $file`
165 if [ -r ${LIB}/$file ]; then
166 file_to_fix=${LIB}/$file
167 else
168 if [ -r ${INPUT}/$file ]; then
169 file_to_fix=${INPUT}/$file
170 else
171 file_to_fix=""
174 if [ \! -z "$file_to_fix" ]; then
175 echo Checking $file_to_fix
176 sed -e '/__vfork/i\
177 extern pid_t __vfork(void);'\
178 $file_to_fix > /tmp/$base
179 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
180 true
181 else
182 echo Fixed $file_to_fix
183 rm -f ${LIB}/$file
184 cp /tmp/$base ${LIB}/$file
185 chmod a+r ${LIB}/$file
187 rm -f /tmp/$base
190 exit 0