]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fixinc.math
Update mainline egcs to gcc2 snapshot 971021.
[thirdparty/gcc.git] / gcc / fixinc.math
CommitLineData
be1ed94f
JL
1#! /bin/sh
2# Fix struct exception in /usr/include/math.h.
3#
4# We expect several systems which did not need fixincludes in the past
e9a25f70 5# to need to fix just math.h. So we created a separate fixinc.math
be1ed94f
JL
6# script to fix just that problem.
7# See README-fixinc for more information.
8
9# Directory containing the original header files.
10# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
11INPUT=${2-${INPUT-/usr/include}}
12
13# Directory in which to store the results.
14LIB=${1?"fixincludes: output directory not specified"}
15
be1ed94f
JL
16# Make sure it exists.
17if [ ! -d $LIB ]; then
18 mkdir $LIB || exit 1
19fi
20
be1ed94f
JL
21echo Building fixed headers in ${LIB}
22
be1ed94f
JL
23# Some math.h files define struct exception, which conflicts with
24# the class exception defined in the C++ file std/stdexcept.h. We
25# redefine it to __math_exception. This is not a great fix, but I
26# haven't been able to think of anything better.
27file=math.h
e9a25f70
JL
28if [ -r $INPUT/$file ]; then
29 echo Checking $INPUT/$file
30 if grep 'struct exception' $INPUT/$file >/dev/null
31 then
32 echo Fixed $file
33 rm -f $LIB/$file
34 cat <<'__EOF__' >$LIB/$file
35#ifndef _MATH_H_WRAPPER
36#ifdef __cplusplus
37# define exception __math_exception
38#endif
39#include_next <math.h>
40#ifdef __cplusplus
41# undef exception
42#endif
43#define _MATH_H_WRAPPER
44#endif /* _MATH_H_WRAPPER */
45__EOF__
46 # Define _MATH_H_WRAPPER at the end of the wrapper, not the start,
47 # so that if #include_next gets another instance of the wrapper,
48 # this will follow the #include_next chain until we arrive at
49 # the real <math.h>.
50 chmod a+r $LIB/$file
be1ed94f
JL
51 fi
52fi
53exit 0