* i386.c (notice_update_cc): Remove bogus pentium GCC code.
[official-gcc.git] / gcc / fixinc.math
blob02652aa387bd4816f6ca7db9b02182eb8632e75c
1 #! /bin/sh
2 # Fix struct exception in /usr/include/math.h.
4 # We expect several systems which did not need fixincludes in the past
5 # to need to fix just math.h. So we created a separate fixinc.mathh
6 # script to fix just that problem.
7 # See README-fixinc for more information.
9 # Directory containing the original header files.
10 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
11 INPUT=${2-${INPUT-/usr/include}}
13 # Directory in which to store the results.
14 LIB=${1?"fixincludes: output directory not specified"}
16 # Define PWDCMD as a command to use to get the working dir
17 # in the form that we want.
18 PWDCMD=pwd
19 case "`pwd`" in
20 //*)
21 # On an Apollo, discard everything before `/usr'.
22 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
24 esac
26 # Original directory.
27 ORIGDIR=`${PWDCMD}`
29 # Make sure it exists.
30 if [ ! -d $LIB ]; then
31 mkdir $LIB || exit 1
34 # Make LIB absolute only if needed to avoid problems with the amd.
35 case $LIB in
36 /*)
39 cd $LIB; LIB=`${PWDCMD}`
41 esac
43 # Fail if no arg to specify a directory for the output.
44 if [ x$1 = x ]
45 then echo fixincludes: no output directory specified
46 exit 1
49 echo Building fixed headers in ${LIB}
51 # Determine whether this system has symbolic links.
52 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
53 rm -f $LIB/ShouldNotExist
54 LINKS=true
55 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
56 rm -f /tmp/ShouldNotExist
57 LINKS=true
58 else
59 LINKS=false
62 cd ${INPUT}
64 # Some math.h files define struct exception, which conflicts with
65 # the class exception defined in the C++ file std/stdexcept.h. We
66 # redefine it to __math_exception. This is not a great fix, but I
67 # haven't been able to think of anything better.
68 file=math.h
69 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
70 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
71 chmod +w ${LIB}/$file 2>/dev/null
72 chmod a+r ${LIB}/$file 2>/dev/null
75 if [ -r ${LIB}/$file ]; then
76 echo Fixing $file, exception
77 sed -e '/struct exception/i\
78 #ifdef __cplusplus\
79 #define exception __math_exception\
80 #endif\
82 -e '/struct exception/a\
83 #ifdef __cplusplus\
84 #undef exception\
85 #endif\
86 ' ${LIB}/$file > ${LIB}/${file}.sed
87 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
88 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
89 sed -e '/matherr/i\
90 #ifdef __cplusplus\
91 #define exception __math_exception\
92 #endif\
94 -e '/matherr/a\
95 #ifdef __cplusplus\
96 #undef exception\
97 #endif\
98 ' ${LIB}/$file > ${LIB}/${file}.sed
99 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
101 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
102 rm -f ${LIB}/$file
103 else
104 # Find any include directives that use "file".
105 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
106 dir=`echo $file | sed -e s'|/[^/]*$||'`
107 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
108 done
111 exit 0