|| echo "Can't copy $file"
chmod +w $2/$file
chmod a+r $2/$file
+ # The fixinc_eol stuff is to work around a bug in the sed
+ # program on HP/UX 10.20.
# Here is how the sed commands in braces work.
# (It doesn't work to put the comments inside the sed commands.)
# Surround each word with spaces, to simplify matching below.
sed -e '
:loop
/\\$/ N
+ s/\\$/\\*fixinc_eol*/
/\\$/ b loop
+ s/\\\*fixinc_eol\*/\\/g
s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
fi
if [ -r ${LIB}/$file ]; then
- if grep 'class[(]' ${LIB}/$file >/dev/null; then
+ if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
echo Fixing $file
sed -e '/class[(]/i\
#ifndef __cplusplus
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file
- sed -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
+ sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
+ -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
+ -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
-e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
fi
fi
-# assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
-# is defined on HP/UX.
-file=assert.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
+# assert.h and sys/mman.h on HP/UX are not C++ ready, even though
+# NO_IMPLICIT_EXTERN_C is defined on HP/UX.
+for file in assert.h sys/mman.h; do
+ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+ fi
-if [ -r ${LIB}/$file ]; then
- if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
- || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
- true
- else
- echo Fixing $file
- echo '#ifdef __cplusplus
+ if [ -r ${LIB}/$file ]; then
+ if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
+ || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
+ true
+ else
+ echo Fixing $file
+ echo '#ifdef __cplusplus
extern "C" {
#endif' > ${LIB}/${file}.sed
- cat ${LIB}/${file} >> ${LIB}/${file}.sed
- echo '#ifdef __cplusplus
+ cat ${LIB}/${file} >> ${LIB}/${file}.sed
+ echo '#ifdef __cplusplus
}
#endif' >> ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ fi
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
rm -f ${LIB}/$file
else
# Find any include directives that use "file".
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
- dir=`echo $file | sed -e s'|/[^/]*$||'`
- required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+ dir=`echo $file | sed -e s'|/[^/]*$||'`
+ required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
done
fi
fi
-fi
+done
# check for broken assert.h that needs stdio.h or stdlib.h
file=assert.h
true
else
echo "Fixing $file (needs stdio.h)"
- echo '#ifdef __cplusplus
-#include <stdio.h>
-#endif' >>${LIB}/$file
+ echo '#include <stdio.h>' >>${LIB}/$file
fi
fi
if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
fi
fi
+# Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
+file=sys/time.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ mkdir ${LIB}/sys 2>/dev/null
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+ if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
+ echo Fixing $file
+ sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ fi
+ if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+ rm -f ${LIB}/$file
+ else
+ # Find any include directives that use "file".
+ for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
+ dir=`echo $file | sed -e s'|/[^/]*$||'`
+ required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+ done
+ fi
+fi
+
# Another bad dependency in VxWorks 5.2 <time.h>.
file=time.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
fi
fi
+# Some math.h files define struct exception, which conflicts with
+# the class exception defined in the C++ file std/stdexcept.h. We
+# redefine it to __math_exception. This is not a great fix, but I
+# haven't been able to think of anything better.
+file=math.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+ echo Fixing $file, exception
+ sed -e '/struct exception/i\
+#ifdef __cplusplus\
+#define exception __math_exception\
+#endif'\
+ -e '/struct exception/a\
+#ifdef __cplusplus\
+#undef exception\
+#endif' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
+ sed -e '/matherr/i\
+#ifdef __cplusplus\
+#define exception __math_exception\
+#endif'\
+ -e '/matherr/a\
+#ifdef __cplusplus\
+#undef exception\
+#endif' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ fi
+ if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+ rm -f ${LIB}/$file
+ else
+ # Find any include directives that use "file".
+ for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
+ dir=`echo $file | sed -e s'|/[^/]*$||'`
+ required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+ done
+ fi
+fi
+
+# rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers.
+file=rpc/xdr.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+ echo "Checking for needed C++ prototype in $file"
+ sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
+#ifdef __cplusplus\
+\1*\2(...);\3\
+#else\
+\1*\2();\3\
+#endif/g' \
+ $LIB/$file > ${LIB}/${file}.sed
+
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+ rm -f ${LIB}/$file
+ else
+ # Find any include directives that use "file".
+ for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
+ dir=`echo $file | sed -e s'|/[^/]*$||'`
+ required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+ done
+ fi
+fi
+
+# sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
+# defining regex.h related types. This causes libg++ build and usage failures.
+# Fixing this correctly requires checking and modifying 3 files.
+for file in reg_types.h regex.h sys/lc_core.h; do
+ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+ fi
+done
+if [ -r ${LIB}/reg_types.h ]; then
+ if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
+ if [ -r ${LIB}/sys/lc_core.h ]; then
+ if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
+ if [ -r ${LIB}/regex.h ]; then
+ if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
+ true;
+ else
+ echo Fixing reg_types.h, regex.h, sys/lc_core.h
+ for file in reg_types.h sys/lc_core.h; do
+ sed -e 's/regex_t/__regex_t/g' \
+ -e 's/regoff_t/__regoff_t/g' \
+ -e 's/regmatch_t/__regmatch_t/g' \
+ ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ done
+ sed -e '/#include <reg_types.h>/a\
+typedef __regex_t regex_t;\
+typedef __regoff_t regoff_t;\
+typedef __regmatch_t regmatch_t;\
+' \
+ ${LIB}/regex.h > ${LIB}/regex.h.sed
+ rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+for file in reg_types.h regex.h sys/lc_core.h; do
+ if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+ rm -f ${LIB}/$file
+ else
+ # Find any include directives that use "file".
+ for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
+ dir=`echo $file | sed -e s'|/[^/]*$||'`
+ required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+ done
+ fi
+done
+
# This loop does not appear to do anything, because it uses file
# rather than $file when setting target. It also appears to be
# unnecessary, since the main loop processes symbolic links.