diff --git a/ChangeLog b/ChangeLog
index 8b2887fc4fe38d918e0a05989ce3ebdc741465fa..4e06a85514eadf490643a732239a5f4ae49d417f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Aug 30 22:14:44 1998  H.J. Lu  (hjl@gnu.org)
+
+	* configure (gxx_include_dir): Changed to
+	'${prefix}/include/g++'-${libstdcxx_interface}.
+
+	* config.if: New to determine the interfaces.
+
 Sun Aug 30 21:15:19 1998  Mark Klein (mklein@dis.com)
 
 	* config.guess: Detect and handle MPE/IX.
diff --git a/config.if b/config.if
new file mode 100644
index 0000000000000000000000000000000000000000..795119e65e63b4f00aa56ee54518c4e253ad4ece
--- /dev/null
+++ b/config.if
@@ -0,0 +1,79 @@
+#! /dev/null
+# Don't call it directly. This shell script fragment is called to
+# determine:
+#
+#	1. libstcxx_interface: the interface name for libstdc++.
+#	2. cxx_interface: the interface name for c++.
+#	3. libc_interface: the interface name for libc.
+#
+
+# Get the top level src dir.
+if [ -z "${topsrcdir}" -a -z "${top_srcdir}" ]
+then
+  echo "Undefined top level src dir: topsrcdir and top_srcdir are empty" >&2
+  exit 1
+fi
+
+if [ -n "${topsrcdir}" ]
+then
+  if_topsrcdir=${topsrcdir}
+else
+  if_topsrcdir=${top_srcdir}
+fi
+
+# We check libstdc++ for libstdcxx_interface.
+libstdcxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/libstdc++/Makefile.in | sed 's/INTERFACE[ 	]*=[ 	]*\(.*\)/\1/'`
+
+# We check gcc/cp for cxx_interface.
+cxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/gcc/cp/Makefile.in | sed 's/INTERFACE[ 	]*=[ 	]*\(.*\)/\1/'`
+
+# The trickiest part is libc_interface.
+if [ -z "${libc_interface}" ]
+then
+  case ${target_os} in
+  *linux*libc1*|*linux*libc5*)
+    case ${target_alias} in
+    *alpha*|*powerpc*)
+      libc_interface=-libc5.9-
+      ;;
+    *)
+      libc_interface=-libc5-
+      ;;
+    esac
+    ;;
+  *linux*gnu*)
+    # We have to work harder to figure it out.
+    if [ ${target_alias} = ${build_alias} ]
+    then
+      dummy=if$$
+      cat >$dummy.c <<EOF
+#include <features.h>                      
+main(argc, argv)
+     int argc;          
+     char *argv[];
+{
+  printf("%d\n", __GLIBC_MINOR__);
+  return 0;
+}
+EOF
+      ${CC-cc} $dummy.c -o $dummy 2>/dev/null
+      if [ "$?" = 0 ]
+      then
+	libc_interface=-libc6.`./$dummy`-
+	rm -f $dummy.c $dummy
+      else
+	# It should never happen.
+	echo "Cannot find the GNU C library minor version number." >&2
+	rm -f $dummy.c $dummy
+	exit 1
+      fi
+    else
+      # Cross compiling. Assume glibc 2.1.
+      libc_interface=-libc6.1-
+    fi
+    ;;
+  *)
+    libc_interface=-
+    ;;
+  esac
+fi
diff --git a/configure b/configure
index 99e35e9a364446840e23aa6614a49447df716cf2..d194ff11737d2ccf1f5ba21600da49ce88e591d1 100755
--- a/configure
+++ b/configure
@@ -1259,7 +1259,8 @@ EOF
 	        if test x${enable_version_specific_runtime_libs} = xyes; then
 		    echo gxx_include_dir = '${libsubdir}/include/g++' >> ${Makefile}
 		else
-		    echo gxx_include_dir = '${prefix}/include/g++' >> ${Makefile}
+		    . ${topsrcdir}/config.if
+		    echo gxx_include_dir = '${prefix}/include/g++'-${libstdcxx_interface} >> ${Makefile}
 		fi
 	    else
 		echo gxx_include_dir = ${gxx_include_dir} >> ${Makefile}