diff --git a/ChangeLog b/ChangeLog
index 47f97cb1f6f55e74882be9aedb141565899f520b..31870cde9de29df09d00538663e3c23e30fca6c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Apr  2 15:11:32 1999  H.J. Lu  (hjl@gnu.org)
+
+	* configure (gxx_include_dir): Removed.
+
+	* configure.in (gxx_include_dir): Handle it.
+	* Makefile.in: Likewise.
+
 Thu Mar 18 00:17:50 1999  Mark Elbrecht <snowball3@usa.net>
 
 	* config/mh-go32: Delete.
diff --git a/Makefile.in b/Makefile.in
index 79527fbdd645ec20cb48b6208bc45062fb2826a4..795a7da3fd39ed54624f46d26242fac039047cc8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -35,6 +35,7 @@ includedir=${prefix}/include
 oldincludedir=/usr/include
 infodir=${prefix}/info
 mandir=${prefix}/man
+gxx_include_dir=${includedir}/g++
 
 tooldir = $(exec_prefix)/$(target_alias)
 build_tooldir = $(exec_prefix)/$(target_alias)
diff --git a/configure b/configure
index 8031282ed998bb6b50b3c88e0d6a6ae34ccaf8b7..a7d3cb8b1e2f464adf0806eda447c135c0cd56f0 100755
--- a/configure
+++ b/configure
@@ -1331,35 +1331,6 @@ EOF
                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
             fi 
 
-	    # provide a proper gxx_include_dir to all subdirs.
-	    # Note, if you change the default, make sure to fix both here
-	    # and in the gcc subdirectory.
-	    # Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
-	    gxx_include_dir=
-	    if test -n "${with_gxx_include_dir}"; then
-		case "${with_gxx_include_dir}" in
-		  yes )
-		    echo "configure: error: bad value ${withval} given for g++ include directory" 1>&2
-		    exit 1
-		    ;;
-		  no )
-		    ;;
-		  * )
-		    gxx_include_dir=${with_gxx_include_dir}
-		    ;;
-		esac
-	    fi
-	    if test x${gxx_include_dir} = x; then
-	        if test x${enable_version_specific_runtime_libs} = xyes; then
-		    echo gxx_include_dir = '${libsubdir}/include/g++' >> ${Makefile}
-		else
-		    . ${topsrcdir}/config.if
-		    echo gxx_include_dir = '${prefix}/include/g++'-${libstdcxx_interface} >> ${Makefile}
-		fi
-	    else
-		echo gxx_include_dir = ${gxx_include_dir} >> ${Makefile}
-	    fi
-
 	    # record if we want to build shared libs.
 	    if test -z "${enable_shared}"; then
 	        echo enable_shared = no >> ${Makefile}
diff --git a/configure.in b/configure.in
index f72f638dde2e49eceb83aa9788d21983a4c546bd..d0e7166d51ae90bb68e507fb8c892152ef43c6da 100644
--- a/configure.in
+++ b/configure.in
@@ -1080,10 +1080,40 @@ if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " newlib "
   targargs="--with-newlib ${targargs}"
 fi
 
+# provide a proper gxx_include_dir.
+# Note, if you change the default, make sure to fix both here and in
+# the gcc, libio, libstdc++ and libg++ subdirectories.
+# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
+gxx_include_dir=
+if test -n "${with_gxx_include_dir}"; then
+  case "${with_gxx_include_dir}" in
+    yes )
+      echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2
+      exit 1
+      ;;
+    no )
+      ;;
+    * )
+      gxx_include_dir=${with_gxx_include_dir}
+      ;;
+  esac
+fi
+if test x${gxx_include_dir} = x; then
+  if test x${enable_version_specific_runtime_libs} = xyes; then
+    gxx_include_dir='${libsubdir}/include/g++'
+  else
+    . ${topsrcdir}/config.if
+    gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
+  fi
+else
+  gxx_include_dir=${gxx_include_dir}
+fi
+
 targargs="--host=${target_alias} --build=${build_alias} ${targargs}"
 sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
     -e "s%^CONFIG_ARGUMENTS[ 	]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
     -e "s%^TARGET_SUBDIR[ 	]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
+    -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
        Makefile > Makefile.tem
 rm -f Makefile
 mv -f Makefile.tem Makefile
diff --git a/libio/ChangeLog b/libio/ChangeLog
index d83539e54837d9a0a3f4bebca16dc0a4de221629..faeb9967ef3f94e4c32f88178a0cc2333539ae97 100644
--- a/libio/ChangeLog
+++ b/libio/ChangeLog
@@ -1,3 +1,8 @@
+Fri Apr  2 15:11:58 1999  H.J. Lu  (hjl@gnu.org)
+
+	* libio/configure.in (gxx_include_dir): Handle it.
+	* libio/Makefile.in: Likewise.
+
 Wed Mar 24 22:36:45 1999  Mumit Khan  <khan@xraylith.wisc.edu>
 
 	* configure.in (EXEEXT): Define.
diff --git a/libio/Makefile.in b/libio/Makefile.in
index 2ac472bceef41f2573834bcb60933b9563095c18..1d4123b523c38f8cbc6de53fac4bf5870aa39775 100644
--- a/libio/Makefile.in
+++ b/libio/Makefile.in
@@ -22,6 +22,7 @@ VERSION = 2.8.0
 _G_CONFIG_H=_G_config.h
 tooldir = $(exec_prefix)/$(target)
 INSTALLDIR = $(libdir)
+gxx_include_dir=${includedir}/g++
 
 IO_OBJECTS = filedoalloc.o floatconv.o genops.o fileops.o \
   iovfprintf.o \
diff --git a/libio/configure.in b/libio/configure.in
index c5243bda235106a89a2f7379c3a2c8a3fd7e2193..85a00018c9f7019fd49970ca1f6a09c33d011bad 100644
--- a/libio/configure.in
+++ b/libio/configure.in
@@ -178,3 +178,32 @@ if [ -n "${with_cross_host}" ] ; then
 fi
 
 . ${topsrcdir}/config-ml.in
+
+gxx_include_dir=
+# Specify the g++ header file directory
+# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
+if test "${with_gxx_include_dir+set}" = set; then
+  withval="$with_gxx_include_dir"
+  case "${withval}" in
+    yes)
+      echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2
+      exit 1
+      ;;
+    no)	;;
+    *)	gxx_include_dir=$with_gxx_include_dir ;;
+  esac
+fi
+
+if test x${gxx_include_dir} = x; then
+  if test x${enable_version_specific_runtime_libs} = xyes; then
+    gxx_include_dir='${libsubdir}/include/g++'
+  else
+    topsrcdir=${srcdir}/.. . ${srcdir}/../config.if
+    gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
+  fi
+fi
+
+rm -f Makefile.tem
+sed -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
+       Makefile >Makefile.tem
+mv -f Makefile.tem Makefile
diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog
index ea3010d6f1533491e4593c5c4934dc0801e089a6..658f5fd44aea66524a7e3b3f6ff0b924c63079d4 100644
--- a/libstdc++/ChangeLog
+++ b/libstdc++/ChangeLog
@@ -1,3 +1,8 @@
+Fri Apr  2 15:12:14 1999  H.J. Lu  (hjl@gnu.org)
+
+	* libstdc++/configure.in (gxx_include_dir): Handle it.
+	* libstdc++/Makefile.in: Likewise.
+
 Wed Mar 24 22:36:45 1999  Mumit Khan  <khan@xraylith.wisc.edu>
 
 	* configure.in (EXEEXT): Define.
diff --git a/libstdc++/Makefile.in b/libstdc++/Makefile.in
index 903b38ed1b9558553139996037e246985b5050ca..9e03d0545a7a24f3d2781855771f1880b12d9c3f 100644
--- a/libstdc++/Makefile.in
+++ b/libstdc++/Makefile.in
@@ -17,6 +17,8 @@
 VERSION = 2.9.0
 INTERFACE = 2
 
+gxx_include_dir=${includedir}/g++
+
 OBJS  = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o
 SUBLIBS = $(STAMP)-string $(STAMP)-complx
 
diff --git a/libstdc++/configure.in b/libstdc++/configure.in
index 143f6ba637be944835b12645c16c752b14a07def..9590b6b363eb293c46c92d8421cbfcc17cdf710b 100644
--- a/libstdc++/configure.in
+++ b/libstdc++/configure.in
@@ -177,3 +177,31 @@ if [ -n "${with_cross_host}" ] ; then
 fi
 
 . ${topsrcdir}/config-ml.in
+
+gxx_include_dir=
+# Specify the g++ header file directory
+# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
+if test "${with_gxx_include_dir+set}" = set; then
+  withval="$with_gxx_include_dir"
+  case "${withval}" in
+    yes)
+      echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2
+      exit 1
+      ;;
+    no)	;;
+    *)	gxx_include_dir=$with_gxx_include_dir ;;
+  esac
+fi
+
+if test x${gxx_include_dir} = x; then
+  if test x${enable_version_specific_runtime_libs} = xyes; then
+    gxx_include_dir='${libsubdir}/include/g++'
+  else
+    gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
+  fi
+fi
+
+rm -f Makefile.tem
+sed -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
+       Makefile >Makefile.tem
+mv -f Makefile.tem Makefile