2 # Create wrappers for include files instead of replacing them.
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.
9 # See README-fixinc for more information.
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}}
15 # Directory in which to store the results.
16 LIB=${1?"fixincludes: output directory not specified"}
18 # Make sure it exists.
19 if [ ! -d $LIB ]; then
23 echo Building fixed headers in ${LIB}
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.
30 if [ -r $INPUT/$file ]; then
31 echo Checking $INPUT/$file
32 if grep 'struct exception' $INPUT/$file >/dev/null
36 cat <<'__EOF__' >$LIB/$file
37 #ifndef _MATH_H_WRAPPER
39 # define exception __math_exception
41 #include_next <math.h>
45 #define _MATH_H_WRAPPER
46 #endif /* _MATH_H_WRAPPER */
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
56 # Similarly for struct queue in sys/stream.h.
58 if [ -r $INPUT/$file ]; then
59 echo Checking $INPUT/$file
60 if grep 'struct[ ]*queue' $INPUT/$file >/dev/null
63 mkdir -p $LIB/`dirname $file`
65 cat <<'__EOF__' >$LIB/$file
66 #ifndef _SYS_STREAM_H_WRAPPER
68 # define queue __stream_queue
70 #include_next <sys/stream.h>
74 #define _SYS_STREAM_H_WRAPPER
75 #endif /* _SYS_STREAM_H_WRAPPER */
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>.
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.
88 if [ -r $INPUT/$file ]; then
89 echo Checking $INPUT/$file
91 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev/null
95 cat <<'__EOF__' >$LIB/$file
96 #ifndef _CURSES_H_WRAPPER
98 # define bool __curses_bool_t
100 #include_next <curses.h>
104 #define _CURSES_H_WRAPPER
105 #endif /* _CURSES_H_WRAPPER */
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>.