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 in which to store the results.
12 LIB
=${1?"fixincludes: output directory not specified"}
14 # Make sure it exists.
15 if [ ! -d $LIB ]; then
19 ORIG_DIR
=`${PWDCMD-pwd}`
21 # Make LIB absolute if it is relative.
22 # Don't do this if not necessary, since may screw up automounters.
27 cd $LIB; LIB
=`${PWDCMD-pwd}`
31 echo Building fixed headers
in ${LIB}
32 # Directory containing the original header files.
34 if [ $# -eq 0 ] ; then
40 for INPUT
in ${INLIST} ; do
44 # Some math.h files define struct exception, which conflicts with
45 # the class exception defined in the C++ file std/stdexcept.h. We
46 # redefine it to __math_exception. This is not a great fix, but I
47 # haven't been able to think of anything better.
49 if [ -r $INPUT/$file ]; then
50 echo Checking
$INPUT/$file
51 if grep 'struct exception' $INPUT/$file >/dev
/null
55 cat <<'__EOF__' >$LIB/$file
56 #ifndef _MATH_H_WRAPPER
58 # define exception __math_exception
60 #include_next <math.h>
64 #define _MATH_H_WRAPPER
65 #endif /* _MATH_H_WRAPPER */
67 # Define _MATH_H_WRAPPER at the end of the wrapper, not the start,
68 # so that if #include_next gets another instance of the wrapper,
69 # this will follow the #include_next chain until we arrive at
75 # Similarly for struct queue in sys/stream.h.
77 if [ -r $INPUT/$file ]; then
78 echo Checking
$INPUT/$file
79 if grep 'struct[ ]*queue' $INPUT/$file >/dev
/null
82 mkdir
-p $LIB/`dirname $file`
84 cat <<'__EOF__' >$LIB/$file
85 #ifndef _SYS_STREAM_H_WRAPPER
87 # define queue __stream_queue
89 #include_next <sys/stream.h>
93 #define _SYS_STREAM_H_WRAPPER
94 #endif /* _SYS_STREAM_H_WRAPPER */
96 # Define _SYS_STREAM_H_WRAPPER at the end of the wrapper, not the start,
97 # so that if #include_next gets another instance of the wrapper,
98 # this will follow the #include_next chain until we arrive at
99 # the real <sys/stream.h>.
104 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
105 # g++, since it's now an official type in the C++ language.
107 if [ -r $INPUT/$file ]; then
108 echo Checking
$INPUT/$file
110 if grep "typedef$w$w*char$w$w*bool$w*;" $INPUT/$file >/dev
/null
114 cat <<'__EOF__' >$LIB/$file
115 #ifndef _CURSES_H_WRAPPER
117 # define bool __curses_bool_t
119 #include_next <curses.h>
123 #define _CURSES_H_WRAPPER
124 #endif /* _CURSES_H_WRAPPER */
126 # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
127 # so that if #include_next gets another instance of the wrapper,
128 # this will follow the #include_next chain until we arrive at
129 # the real <curses.h>.