fixinc.math: New file to fix math.h on some systems.

* fixinc.math: New file to fix math.h on some systems.
        * configure.in (freebsd, netbsd): Use fixinc.math on these
        systems.
        * configure: Rebuilt.
Should fix struct exception problems for freebsd, netbsd.  Can be used
for others.

From-SVN: r15436
This commit is contained in:
Jeff Law 1997-09-14 12:29:43 -06:00
parent 124da27518
commit be1ed94f89
3 changed files with 147 additions and 36 deletions

36
gcc/configure vendored
View File

@ -1927,8 +1927,8 @@ for machine in $build $host $target; do
tm_file=arm/netbsd.h
xm_file=arm/xm-netbsd.h
tmake_file=arm/t-netbsd
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
use_collect2=yes
;;
arm-*-linux-gnuaout*) # ARM Linux
@ -2303,8 +2303,8 @@ for machine in $build $host $target; do
i[3456]86-*-freebsdelf*)
tm_file="i386/i386.h i386/att.h linux.h i386/freebsd-elf.h i386/perform.h"
xm_file=i386/xm-freebsd.h
# On FreeBSD, the headers are already ok.
fixincludes=Makefile.in
# On FreeBSD, the headers are already ok, except for math.h.
fixincludes=fixinc.math
tmake_file=i386/t-freebsd
gas=yes
gnu_ld=yes
@ -2313,15 +2313,15 @@ for machine in $build $host $target; do
i[3456]86-*-freebsd*)
tm_file=i386/freebsd.h
xm_file=i386/xm-freebsd.h
# On FreeBSD, the headers are already ok.
fixincludes=Makefile.in
# On FreeBSD, the headers are already ok, except for math.h
fixincludes=fixinc.math
tmake_file=i386/t-freebsd
;;
i[3456]86-*-netbsd*)
tm_file=i386/netbsd.h
xm_file=i386/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
i[3456]86-*-coff*)
@ -2978,8 +2978,8 @@ for machine in $build $host $target; do
m68k-*-netbsd*)
tm_file=m68k/netbsd.h
xm_file=m68k/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
m68k-*-sysv3*) # Motorola m68k's running system V.3
@ -3277,8 +3277,8 @@ for machine in $build $host $target; do
mips-dec-netbsd*) # Decstation running NetBSD
tm_file=mips/netbsd.h
xm_file=mips/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
mips-sony-bsd* | mips-sony-newsos*) # Sony NEWS 3600 or risc/news.
@ -3597,8 +3597,8 @@ for machine in $build $host $target; do
ns32k-pc532-netbsd*)
tm_file=ns32k/netbsd.h
xm_file=ns32k/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
pdp11-*-bsd)
@ -3827,8 +3827,8 @@ for machine in $build $host $target; do
sparc-*-netbsd*)
tm_file=sparc/netbsd.h
xm_file=sparc/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
sparc-*-bsd*)
@ -3969,8 +3969,8 @@ for machine in $build $host $target; do
vax-*-netbsd*)
tm_file="${tm_file} netbsd.h vax/netbsd.h"
xm_file="${xm_file} xm-netbsd.h"
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
float_format=vax
;;

View File

@ -413,8 +413,8 @@ for machine in $build $host $target; do
tm_file=arm/netbsd.h
xm_file=arm/xm-netbsd.h
tmake_file=arm/t-netbsd
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
use_collect2=yes
;;
arm-*-linux-gnuaout*) # ARM Linux
@ -789,8 +789,8 @@ for machine in $build $host $target; do
i[[3456]]86-*-freebsdelf*)
tm_file="i386/i386.h i386/att.h linux.h i386/freebsd-elf.h i386/perform.h"
xm_file=i386/xm-freebsd.h
# On FreeBSD, the headers are already ok.
fixincludes=Makefile.in
# On FreeBSD, the headers are already ok, except for math.h.
fixincludes=fixinc.math
tmake_file=i386/t-freebsd
gas=yes
gnu_ld=yes
@ -799,15 +799,15 @@ for machine in $build $host $target; do
i[[3456]]86-*-freebsd*)
tm_file=i386/freebsd.h
xm_file=i386/xm-freebsd.h
# On FreeBSD, the headers are already ok.
fixincludes=Makefile.in
# On FreeBSD, the headers are already ok, except for math.h.
fixincludes=fixinc.math
tmake_file=i386/t-freebsd
;;
i[[3456]]86-*-netbsd*)
tm_file=i386/netbsd.h
xm_file=i386/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
i[[3456]]86-*-coff*)
@ -1464,8 +1464,8 @@ for machine in $build $host $target; do
m68k-*-netbsd*)
tm_file=m68k/netbsd.h
xm_file=m68k/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
m68k-*-sysv3*) # Motorola m68k's running system V.3
@ -1763,8 +1763,8 @@ for machine in $build $host $target; do
mips-dec-netbsd*) # Decstation running NetBSD
tm_file=mips/netbsd.h
xm_file=mips/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
mips-sony-bsd* | mips-sony-newsos*) # Sony NEWS 3600 or risc/news.
@ -2083,8 +2083,8 @@ for machine in $build $host $target; do
ns32k-pc532-netbsd*)
tm_file=ns32k/netbsd.h
xm_file=ns32k/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
pdp11-*-bsd)
@ -2313,8 +2313,8 @@ for machine in $build $host $target; do
sparc-*-netbsd*)
tm_file=sparc/netbsd.h
xm_file=sparc/xm-netbsd.h
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
;;
sparc-*-bsd*)
@ -2455,8 +2455,8 @@ for machine in $build $host $target; do
vax-*-netbsd*)
tm_file="${tm_file} netbsd.h vax/netbsd.h"
xm_file="${xm_file} xm-netbsd.h"
# On NetBSD, the headers are already okay.
fixincludes=Makefile.in
# On NetBSD, the headers are already okay, except for math.h.
fixincludes=fixinc.math
tmake_file=t-netbsd
float_format=vax
;;

111
gcc/fixinc.math Executable file
View File

@ -0,0 +1,111 @@
#! /bin/sh
# Fix struct exception in /usr/include/math.h.
#
# We expect several systems which did not need fixincludes in the past
# to need to fix just math.h. So we created a separate fixinc.mathh
# script to fix just that problem.
# See README-fixinc for more information.
# Directory containing the original header files.
# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
INPUT=${2-${INPUT-/usr/include}}
# Directory in which to store the results.
LIB=${1?"fixincludes: output directory not specified"}
# Define PWDCMD as a command to use to get the working dir
# in the form that we want.
PWDCMD=pwd
case "`pwd`" in
//*)
# On an Apollo, discard everything before `/usr'.
PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
;;
esac
# Original directory.
ORIGDIR=`${PWDCMD}`
# Make sure it exists.
if [ ! -d $LIB ]; then
mkdir $LIB || exit 1
fi
# Make LIB absolute only if needed to avoid problems with the amd.
case $LIB in
/*)
;;
*)
cd $LIB; LIB=`${PWDCMD}`
;;
esac
# Fail if no arg to specify a directory for the output.
if [ x$1 = x ]
then echo fixincludes: no output directory specified
exit 1
fi
echo Building fixed headers in ${LIB}
# Determine whether this system has symbolic links.
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
rm -f $LIB/ShouldNotExist
LINKS=true
elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
rm -f /tmp/ShouldNotExist
LINKS=true
else
LINKS=false
fi
cd ${INPUT}
# 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
exit 0