OSDN Git Service

* config/mips/mips.c (mips_explicit_type_size_string): Correct
[pf3gnuchains/gcc-fork.git] / gcc / fixinc.wrap
1 #! /bin/sh
2 # Create wrappers for include files instead of replacing them.
3 #
4 # This script is designed for systems whose include files can be fixed
5 # by creating small wrappers around them.
6 # An advantage of this method is that if the system include files are changed
7 # (e.g. by OS upgrade), you need not re-run fixincludes.
8 #
9 # See README-fixinc for more information.
10
11 # Directory containing the original header files.
12 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
13 INPUT=${2-${INPUT-/usr/include}}
14
15 # Directory in which to store the results.
16 LIB=${1?"fixincludes: output directory not specified"}
17
18 # Make sure it exists.
19 if [ ! -d $LIB ]; then
20   mkdir $LIB || exit 1
21 fi
22
23 echo Building fixed headers in ${LIB}
24
25 # Some math.h files define struct exception, which conflicts with
26 # the class exception defined in the C++ file std/stdexcept.h.  We
27 # redefine it to __math_exception.  This is not a great fix, but I
28 # haven't been able to think of anything better.
29 file=math.h
30 if [ -r $INPUT/$file ]; then
31   echo Checking $INPUT/$file
32   if grep 'struct exception' $INPUT/$file >/dev/null
33   then
34     echo Fixed $file
35     rm -f $LIB/$file
36     cat <<'__EOF__' >$LIB/$file
37 #ifndef _MATH_H_WRAPPER
38 #ifdef __cplusplus
39 # define exception __math_exception
40 #endif
41 #include_next <math.h>
42 #ifdef __cplusplus
43 # undef exception
44 #endif
45 #define _MATH_H_WRAPPER
46 #endif /* _MATH_H_WRAPPER */
47 __EOF__
48     # Define _MATH_H_WRAPPER at the end of the wrapper, not the start,
49     # so that if #include_next gets another instance of the wrapper,
50     # this will follow the #include_next chain until we arrive at
51     # the real <math.h>.
52     chmod a+r $LIB/$file
53   fi
54 fi
55
56 # Similarly for struct queue in sys/stream.h.
57 file=sys/stream.h
58 if [ -r $INPUT/$file ]; then
59   echo Checking $INPUT/$file
60   if grep 'struct[      ]*queue' $INPUT/$file >/dev/null
61   then
62     echo Fixed $file
63     mkdir -p $LIB/`dirname $file`
64     rm -f $LIB/$file
65     cat <<'__EOF__' >$LIB/$file
66 #ifndef _SYS_STREAM_H_WRAPPER
67 #ifdef __cplusplus
68 # define queue __stream_queue
69 #endif
70 #include_next <sys/stream.h>
71 #ifdef __cplusplus
72 # undef queue
73 #endif
74 #define _SYS_STREAM_H_WRAPPER
75 #endif /* _SYS_STREAM_H_WRAPPER */
76 __EOF__
77     # Define _SYS_STREAM_H_WRAPPER at the end of the wrapper, not the start,
78     # so that if #include_next gets another instance of the wrapper,
79     # this will follow the #include_next chain until we arrive at
80     # the real <sys/stream.h>.
81     chmod a+r $LIB/$file
82   fi
83 fi
84
85 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
86 # g++, since it's now an official type in the C++ language.
87 file=curses.h
88 if [ -r $INPUT/$file ]; then
89   echo Checking $INPUT/$file
90   w='[   ]'
91   if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev/null
92   then
93     echo Fixed $file
94     rm -f $LIB/$file
95     cat <<'__EOF__' >$LIB/$file
96 #ifndef _CURSES_H_WRAPPER
97 #ifdef __cplusplus
98 # define bool __curses_bool_t
99 #endif
100 #include_next <curses.h>
101 #ifdef __cplusplus
102 # undef bool
103 #endif
104 #define _CURSES_H_WRAPPER
105 #endif /* _CURSES_H_WRAPPER */
106 __EOF__
107     # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
108     # so that if #include_next gets another instance of the wrapper,
109     # this will follow the #include_next chain until we arrive at
110     # the real <curses.h>.
111     chmod a+r $LIB/$file
112   fi
113 fi
114
115 exit 0