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 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
57 # g++, since it's now an official type in the C++ language.
59 if [ -r $INPUT/$file ]; then
60 echo Checking
$INPUT/$file
62 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev
/null
66 cat <<'__EOF__' >$LIB/$file
67 #ifndef _CURSES_H_WRAPPER
69 # define bool __curses_bool_t
71 #include_next <curses.h>
75 #define _CURSES_H_WRAPPER
76 #endif /* _CURSES_H_WRAPPER */
78 # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
79 # so that if #include_next gets another instance of the wrapper,
80 # this will follow the #include_next chain until we arrive at
81 # the real <curses.h>.