diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a412c5d0fb00180087443b865d7d64f740f4c3df..aa985ac93b1455cbad556692598fa5d3bb8b51a0 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,31 @@
+2000-10-06  benjamin kosnik  <bkoz@fillmore.constant.com>
+2000-10-06  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>
+
+	* src/Makefile.am: Remove OPTIMIZE_CXXFLAGS, WARN_CXXFLAGS,
+	CONFIG_CXXFLAGS from here, and move to...
+	* src/Makefile.in: Regenerate.
+	* Makefile.am: ... here. Clean.
+	(OPTIMIZE_CXXFLAGS): Move up Makefile hierarchy to here.
+	(WARN_CXXFLAGS): Same.
+	(CONFIG_CXXFLAGS): Same.
+	* Makefile.in: Regenerate.
+	* libsupc++/Makefile.am: Use top-level OPTIMIZE_CXXFLAGS,
+	WARN_CXXFLAGS, CONFIG_CXXFLAGS as part of local AM_CXXFLAGS.
+	* libsupc++/Makefile.in: Regenerate.
+		
+	Change math to libmath.
+	* math: Move to libmath, delete.
+	* libmath: New directory.
+	* libmath/*: Populate.
+	* src/Makefile.am (LIBMATH_INCLUDES): Change to libmath.
+	(libstdc___la_LIBADD): Same.
+	* src/Makefile.in: Regenerate.
+	* configure.in: Add AC_OUTPUT for libmath/Makefile.
+	* configure: Regenerate.
+	* Makefile.am (SUBDIRS): Add libmath.
+	* Makefile.in: Regenerate.
+	* README (file): Change name.
+	
 2000-10-06  Benjamin Kosnik  <bkoz@cygnus.com>
             Richard Henderson  <rth@cygnus.com>
 	    Alexandre Oliva  <aoliva@redhat.com>
@@ -13,7 +41,7 @@
 	* src/Makefile.am (libstdc___la_LIBADD): Add in libsupc++.la
 	* src/Makefile.in: Regenerate.
 	* libio/Makefile.am: Remove extraneous, confusing bits.
-	* libio/Makefile.in: Regeneate.
+	* libio/Makefile.in: Regenerate.
 	
 2000-10-05  Brent Verner  <brent@rcfile.org>
 
diff --git a/libstdc++-v3/Makefile.am b/libstdc++-v3/Makefile.am
index bad1b08661a6ccab4fc8a25b0ac8afcf8cfd4622..783c179e667ffacb037e5143c3c35fcf5d2cb580 100644
--- a/libstdc++-v3/Makefile.am
+++ b/libstdc++-v3/Makefile.am
@@ -29,7 +29,28 @@ MAINT_CHARSET = latin1
 INTERFACE = v3
 gxx_include_dir=$(includedir)/g++
 
-SUBDIRS = math libio libsupc++ src
+SUBDIRS = libio libmath libsupc++ src
+
+
+# Compile flags that should be constant throughout the build, both for
+# SUBDIRS and for libstdc++-v3 in general.
+# Optimization flags that are probably a good idea for thrill-seekers. Just
+# uncomment the lines below and make, everything else is ready to go... 
+# OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
+OPTIMIZE_CXXFLAGS = 
+
+# Warning flags to use.
+WARN_CXXFLAGS = \
+	-Wall -Wno-format -W -Wwrite-strings -Winline \
+	$(WERROR) @WFMT_FLAGS@
+
+# These bits are all figured out from configure. Look in acinclude.m4
+# or configure.in to see how they are set.
+# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
+CONFIG_CXXFLAGS = \
+	@CPU_FLAGS@ @EXTRA_CXX_FLAGS@ \
+	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
+
 
 # Use $(blddir) instead of $(top_builddir) for arguments to "mkcheck"
 # because then the paths will be full pathnames, not relative
@@ -42,28 +63,6 @@ check-install: $(top_builddir)/mkcheck
 	chmod +x  $(top_builddir)/mkcheck
 	$(top_builddir)/mkcheck 1 `pwd` $(top_srcdir) $(prefix)
 
-#all-local:  stamp-rebuild
-
-# This has already been sanity-checked by configure to a certain extent
-#stamp-rebuild:  $(top_builddir)/config.status
-#	if test "$(GCC_OBJDIR)" != "no"; then \
-#	(cd "$(GCC_OBJDIR)/gcc" && \
-#	 if test -f libgcc2.ready ; then \
-#	   rm -f libgcc2.ready libgcc.a libgcc2.a ; \
-#	   $(MAKE) libgcc2.a TARGET_LIBGCC2_CFLAGS='@NAMESPACES@' ; \
-#	   $(MAKE) libgcc.a ; \
-#	 else \
-#	   echo '** There does not appear to be a previously-built' ; \
-#	   echo '** library here.  Please see' ; \
-#	   echo '** <http://sourceware.cygnus.com/libstdc++/install.html>' ; \
-#	   echo '** In particular, the "Building and Installing' ; \
-#	   echo '** the library (without GCC sources)" section.' ; \
-#	   exit 1 ; \
-#	 fi \
-#	) \
-#	fi
-#	touch stamp-rebuild
-
 # Multilib support.
 MAKEOVERRIDES=
 
@@ -147,11 +146,10 @@ AM_MAKEFLAGS = \
 	"NM_FOR_BUILD=$(NM_FOR_BUILD)" \
 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
 	"DESTDIR=$(DESTDIR)" \
-	"WERROR=$(WERROR)"
-
-
-
-
+	"WERROR=$(WERROR)" \
+	"OPTIMIZE_CXXFLAGS=$(OPTIMIZE_CXXFLAGS)" \
+	"WARN_CXXFLAGS=$(WARN_CXXFLAGS)" \
+	"CONFIG_CXXFLAGS=$(CONFIG_CXXFLAGS)" 
 
 
 
diff --git a/libstdc++-v3/Makefile.in b/libstdc++-v3/Makefile.in
index d6f930e5fef2d49055dd6e4c866150f8f373f23c..471b12eb66ddd8fc4a9464ec04a7e50bc392764d 100644
--- a/libstdc++-v3/Makefile.in
+++ b/libstdc++-v3/Makefile.in
@@ -117,29 +117,24 @@ MAINT_CHARSET = latin1
 INTERFACE = v3
 gxx_include_dir = $(includedir)/g++
 
-SUBDIRS = math libio libsupc++ src
-
-#all-local:  stamp-rebuild
-
-# This has already been sanity-checked by configure to a certain extent
-#stamp-rebuild:  $(top_builddir)/config.status
-#	if test "$(GCC_OBJDIR)" != "no"; then \
-#	(cd "$(GCC_OBJDIR)/gcc" && \
-#	 if test -f libgcc2.ready ; then \
-#	   rm -f libgcc2.ready libgcc.a libgcc2.a ; \
-#	   $(MAKE) libgcc2.a TARGET_LIBGCC2_CFLAGS='@NAMESPACES@' ; \
-#	   $(MAKE) libgcc.a ; \
-#	 else \
-#	   echo '** There does not appear to be a previously-built' ; \
-#	   echo '** library here.  Please see' ; \
-#	   echo '** <http://sourceware.cygnus.com/libstdc++/install.html>' ; \
-#	   echo '** In particular, the "Building and Installing' ; \
-#	   echo '** the library (without GCC sources)" section.' ; \
-#	   exit 1 ; \
-#	 fi \
-#	) \
-#	fi
-#	touch stamp-rebuild
+SUBDIRS = libio libmath libsupc++ src
+
+# Compile flags that should be constant throughout the build, both for
+# SUBDIRS and for libstdc++-v3 in general.
+# Optimization flags that are probably a good idea for thrill-seekers. Just
+# uncomment the lines below and make, everything else is ready to go... 
+# OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
+OPTIMIZE_CXXFLAGS = 
+
+# Warning flags to use.
+WARN_CXXFLAGS =  	-Wall -Wno-format -W -Wwrite-strings -Winline 	$(WERROR) @WFMT_FLAGS@
+
+
+# These bits are all figured out from configure. Look in acinclude.m4
+# or configure.in to see how they are set.
+# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
+CONFIG_CXXFLAGS =  	@CPU_FLAGS@ @EXTRA_CXX_FLAGS@ 	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
+
 
 # Multilib support.
 MAKEOVERRIDES = 
@@ -155,7 +150,7 @@ MULTICLEAN = true
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
 # friends when we are called from the top level Makefile.
-AM_MAKEFLAGS =  	"AR_FLAGS=$(AR_FLAGS)" 	"CC_FOR_BUILD=$(CC_FOR_BUILD)" 	"CC_FOR_TARGET=$(CC_FOR_TARGET)" 	"CFLAGS=$(CFLAGS)" 	"CXXFLAGS=$(CXXFLAGS)" 	"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" 	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" 	"INSTALL=$(INSTALL)" 	"INSTALL_DATA=$(INSTALL_DATA)" 	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" 	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" 	"LDFLAGS=$(LDFLAGS)" 	"LIBCFLAGS=$(LIBCFLAGS)" 	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" 	"MAKE=$(MAKE)" 	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 	"PICFLAG=$(PICFLAG)" 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" 	"SHELL=$(SHELL)" 	"EXPECT=$(EXPECT)" 	"RUNTEST=$(RUNTEST)" 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" 	"exec_prefix=$(exec_prefix)" 	"infodir=$(infodir)" 	"libdir=$(libdir)" 	"includedir=$(includedir)" 	"prefix=$(prefix)" 	"tooldir=$(tooldir)" 	"AR=$(AR)" 	"AS=$(AS)" 	"CC=$(CC)" 	"CXX=$(CXX)" 	"LD=$(LD)" 	"LIBCFLAGS=$(LIBCFLAGS)" 	"PICFLAG=$(PICFLAG)" 	"RANLIB=$(RANLIB)" 	"NM=$(NM)" 	"NM_FOR_BUILD=$(NM_FOR_BUILD)" 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" 	"DESTDIR=$(DESTDIR)" 	"WERROR=$(WERROR)"
+AM_MAKEFLAGS =  	"AR_FLAGS=$(AR_FLAGS)" 	"CC_FOR_BUILD=$(CC_FOR_BUILD)" 	"CC_FOR_TARGET=$(CC_FOR_TARGET)" 	"CFLAGS=$(CFLAGS)" 	"CXXFLAGS=$(CXXFLAGS)" 	"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" 	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" 	"INSTALL=$(INSTALL)" 	"INSTALL_DATA=$(INSTALL_DATA)" 	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" 	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" 	"LDFLAGS=$(LDFLAGS)" 	"LIBCFLAGS=$(LIBCFLAGS)" 	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" 	"MAKE=$(MAKE)" 	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 	"PICFLAG=$(PICFLAG)" 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" 	"SHELL=$(SHELL)" 	"EXPECT=$(EXPECT)" 	"RUNTEST=$(RUNTEST)" 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" 	"exec_prefix=$(exec_prefix)" 	"infodir=$(infodir)" 	"libdir=$(libdir)" 	"includedir=$(includedir)" 	"prefix=$(prefix)" 	"tooldir=$(tooldir)" 	"AR=$(AR)" 	"AS=$(AS)" 	"CC=$(CC)" 	"CXX=$(CXX)" 	"LD=$(LD)" 	"LIBCFLAGS=$(LIBCFLAGS)" 	"PICFLAG=$(PICFLAG)" 	"RANLIB=$(RANLIB)" 	"NM=$(NM)" 	"NM_FOR_BUILD=$(NM_FOR_BUILD)" 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" 	"DESTDIR=$(DESTDIR)" 	"WERROR=$(WERROR)" 	"OPTIMIZE_CXXFLAGS=$(OPTIMIZE_CXXFLAGS)" 	"WARN_CXXFLAGS=$(WARN_CXXFLAGS)" 	"CONFIG_CXXFLAGS=$(CONFIG_CXXFLAGS)" 
 
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
diff --git a/libstdc++-v3/README b/libstdc++-v3/README
index eb2ce9b082fb100eab079fc8c246fb7d9f428b4b..7516e5c425eefa6ed7f0f2a999beef33f7b23790 100644
--- a/libstdc++-v3/README
+++ b/libstdc++-v3/README
@@ -68,7 +68,6 @@ Other subdirectories contain variant versions of certain files
 that are meant to be copied or linked by the configure script.
 Currently these are:
 
-  math
   config/cpu
   config/os
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index b5ea155f50bbbf7dcb80beabaaa94071558bcdf4..199309dad9ef871e39a1eb8e459410a680c11552 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -18582,7 +18582,7 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "mkcheck Makefile src/Makefile math/Makefile libio/Makefile libsupc++/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "mkcheck Makefile src/Makefile libmath/Makefile libio/Makefile libsupc++/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -18735,7 +18735,7 @@ EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"mkcheck Makefile src/Makefile math/Makefile libio/Makefile libsupc++/Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"mkcheck Makefile src/Makefile libmath/Makefile libio/Makefile libsupc++/Makefile"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
diff --git a/libstdc++-v3/configure.in b/libstdc++-v3/configure.in
index 7fa52a06367256c55ed0621c117c64539fd393c6..0af656ede9e437642621499087c0944bf27412f9 100644
--- a/libstdc++-v3/configure.in
+++ b/libstdc++-v3/configure.in
@@ -148,7 +148,7 @@ fi
 # -> top_srcdir/Makefile.am -> top_srcdir/src/Makefile.am, manually
 # append it here.
 
-AC_OUTPUT(mkcheck Makefile src/Makefile math/Makefile libio/Makefile libsupc++/Makefile,
+AC_OUTPUT(mkcheck Makefile src/Makefile libmath/Makefile libio/Makefile libsupc++/Makefile,
 [if test -n "$CONFIG_FILES"; then
   ac_file=Makefile . ${glibcpp_basedir}/../config-ml.in
   grep '^MULTISUBDIR =' Makefile >> src/Makefile
diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am
index 10e7bff9996c027a9e6d3f7471ffc3323827d979..1506545b9d5ae12fefd94a8a7eea9c526e52d242 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -75,21 +75,17 @@ libsupc__convenience_la_SOURCES = $(sources)
 LIBTOOL = @LIBTOOL@ --tag disable-shared
 LIBSUPCXX_CXXFLAGS = -prefer-pic
 
-
-# These bits are all figured out from configure. Look in acinclude.m4
-# or configure.in to see how they are set.
-# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
-AC_CXXFLAGS = \
-	$(WERROR) @WFMT_FLAGS@ @CPU_FLAGS@ @EXTRA_CXX_FLAGS@ \
-	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
-
-# Need to manually set this option because AC_CXXFLAGS has to be at
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way.
+# Need to manually set this option because CONFIG_CXXFLAGS has to be at
 # the end of the compile line so that -O2 can be overridden as the
 # occasion call for it. (ie, --enable-debug)
 AM_CXXFLAGS = \
-	-fno-implicit-templates $(OPTIMIZE_CXXFLAGS) \
-	-Wall -Wno-format -W -Wwrite-strings -Winline \
-	$(LIBSUPCXX_CXXFLAGS) $(AC_CXXFLAGS) 
+	-fno-implicit-templates \
+	$(LIBSUPCXX_CXXFLAGS) \
+	$(WARN_CXXFLAGS) \
+	$(OPTIMIZE_CXXFLAGS) \
+	$(CONFIG_CXXFLAGS) 
 
 # Need to explicitly set this so that AM_CXXFLAGS is last. In
 # addition, we don't use $(DEFS), which tries to set $(top_srcdir) as
@@ -107,3 +103,8 @@ LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(INCLUDES) \
 # in libtool since this would add -lstdc++ to the link line which of
 # course is impossible.
 CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
+
+
+
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index b5841dd7565ccabe41a6f32d19211dbcfa854a8b..25f8037f1f374b77cba680a125138af1f55eab69 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -137,16 +137,12 @@ libsupc__convenience_la_SOURCES = $(sources)
 LIBTOOL = @LIBTOOL@ --tag disable-shared
 LIBSUPCXX_CXXFLAGS = -prefer-pic
 
-# These bits are all figured out from configure. Look in acinclude.m4
-# or configure.in to see how they are set.
-# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
-AC_CXXFLAGS =  	$(WERROR) @WFMT_FLAGS@ @CPU_FLAGS@ @EXTRA_CXX_FLAGS@ 	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
-
-
-# Need to manually set this option because AC_CXXFLAGS has to be at
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way.
+# Need to manually set this option because CONFIG_CXXFLAGS has to be at
 # the end of the compile line so that -O2 can be overridden as the
 # occasion call for it. (ie, --enable-debug)
-AM_CXXFLAGS =  	-fno-implicit-templates $(OPTIMIZE_CXXFLAGS) 	-Wall -Wno-format -W -Wwrite-strings -Winline 	$(LIBSUPCXX_CXXFLAGS) $(AC_CXXFLAGS) 
+AM_CXXFLAGS =  	-fno-implicit-templates 	$(LIBSUPCXX_CXXFLAGS) 	$(WARN_CXXFLAGS) 	$(OPTIMIZE_CXXFLAGS) 	$(CONFIG_CXXFLAGS) 
 
 
 # Need to explicitly set this so that AM_CXXFLAGS is last. In
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index c211aa259a03980c4e5c8a89ee51564f80b32567..3052d3973124959056471914e2bcb331ba014f76 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -21,7 +21,7 @@
 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 ## USA.
 
-## $Id: Makefile.am,v 1.33 2000/10/05 11:36:52 bkoz Exp $
+## $Id: Makefile.am,v 1.34 2000/10/06 23:31:22 bkoz Exp $
 
 AUTOMAKE_OPTIONS = 1.3 gnits
 MAINT_CHARSET = latin1
@@ -39,24 +39,33 @@ toolexeclib_LTLIBRARIES = libstdc++.la
 EXTRA_LTLIBRARIES = libinst-string.la libinst-wstring.la
 
 
-# Using these options is probably a good idea for thrill-seekers. Just
-# uncomment the lines below and make, everything else is ready to go... 
-# OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
-
-# These bits are all figured out from configure. Look in acinclude.m4
-# or configure.in to see how they are set.
-# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
-AC_CXXFLAGS = \
-	$(WERROR) @WFMT_FLAGS@ @CPU_FLAGS@ @EXTRA_CXX_FLAGS@ \
-	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
-
-# Need to manually set this option because AC_CXXFLAGS has to be at
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way.
+# Need to manually set this option because CONFIG_CXXFLAGS has to be at
 # the end of the compile line so that -O2 can be overridden as the
 # occasion call for it. (ie, --enable-debug)
 AM_CXXFLAGS = \
-	-fno-implicit-templates $(OPTIMIZE_CXXFLAGS) \
-	-Wall -Wno-format -W -Wwrite-strings -Winline \
-	$(AC_CXXFLAGS) 
+	-fno-implicit-templates \
+	$(WARN_CXXFLAGS) \
+	$(OPTIMIZE_CXXFLAGS) \
+	$(CONFIG_CXXFLAGS) 
+
+# Need to explicitly set this so that AM_CXXFLAGS is last. In
+# addition, we don't use $(DEFS), which tries to set $(top_srcdir) as
+# an include diretory, which screws up shadow headers. (That way,
+# things like -O2 passed down from the toplevel can be overridden by
+# --enable-debug.)
+CXXCOMPILE = $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	     $(CXXFLAGS) $(AM_CXXFLAGS) 
+
+LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(INCLUDES) \
+	       $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) 
+
+# We have a problem when building the shared libstdc++ object if the
+# rules automake generates would be used.  We cannot allow CXX to be used
+# in libtool since this would add -lstdc++ to the link line which of
+# course is impossible.
+CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
 
 
 # Root level of the include sources.
@@ -65,7 +74,7 @@ glibcpp_includedir = $(top_srcdir)/include
 # Passed down for cross compilers, canadian crosses.
 TOPLEVEL_INCLUDES = -I$(includedir)
 
-LIBMATH_INCLUDES = -I$(top_srcdir)/math
+LIBMATH_INCLUDES = -I$(top_srcdir)/libmath
 
 if GLIBCPP_NEED_LIBIO
 LIBIO_INCLUDES = \
@@ -94,24 +103,6 @@ INCLUDES = \
 	 $(TOPLEVEL_INCLUDES)	
 
 
-# Need to explicitly set this so that AM_CXXFLAGS is last. In
-# addition, we don't use $(DEFS), which tries to set $(top_srcdir) as
-# an include diretory, which screws up shadow headers. (That way,
-# things like -O2 passed down from the toplevel can be overridden by
-# --enable-debug.)
-CXXCOMPILE = $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	     $(CXXFLAGS) $(AM_CXXFLAGS) 
-
-LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(INCLUDES) \
-	       $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) 
-
-# We have a problem when building the shared libstdc++ object if the
-# rules automake generates would be used.  We cannot allow CXX to be used
-# in libtool since this would add -lstdc++ to the link line which of
-# course is impossible.
-CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
-
-
 headers = \
 	bits/cpp_type_traits.h \
 	bits/std_cctype.h bits/ctype_base.h bits/ctype_specializations.h \
@@ -207,7 +198,7 @@ endif
 
 generated_headers = \
 	 $(top_builddir)/bits/std_limits.h $(top_builddir)/bits/c++config.h \
-	 $(top_builddir)/bits/c++threads.h $(top_builddir)/bits/c++io.h
+	 $(top_builddir)/bits/c++io.h $(top_builddir)/bits/c++threads.h 
 
 cpu_headers = \
 	 $(top_srcdir)/@cpu_include_dir@/bits/atomicity.h 
@@ -238,7 +229,7 @@ libstdc___la_SOURCES = $(sources)
 libinst_wstring_la_SOURCES = $(wstring_sources)
 
 libstdc___la_LIBADD = \
-	../math/libmath.la ../libio/libio.la \
+	../libmath/libmath.la ../libio/libio.la \
 	../libsupc++/libsupc++convenience.la \
 	@libinst_wstring_la@
 
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 8ba3606bc7e2d36eca471cac590e4dbaa746fc14..31a7757a798aee300188c0bcb6914ca897d62ed4 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -117,21 +117,30 @@ MAINT_CHARSET = latin1
 toolexeclib_LTLIBRARIES = libstdc++.la
 EXTRA_LTLIBRARIES = libinst-string.la libinst-wstring.la
 
-# Using these options is probably a good idea for thrill-seekers. Just
-# uncomment the lines below and make, everything else is ready to go... 
-# OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way.
+# Need to manually set this option because CONFIG_CXXFLAGS has to be at
+# the end of the compile line so that -O2 can be overridden as the
+# occasion call for it. (ie, --enable-debug)
+AM_CXXFLAGS =  	-fno-implicit-templates 	$(WARN_CXXFLAGS) 	$(OPTIMIZE_CXXFLAGS) 	$(CONFIG_CXXFLAGS) 
 
-# These bits are all figured out from configure. Look in acinclude.m4
-# or configure.in to see how they are set.
-# NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden.
-AC_CXXFLAGS =  	$(WERROR) @WFMT_FLAGS@ @CPU_FLAGS@ @EXTRA_CXX_FLAGS@ 	@SECTION_FLAGS@ @CSHADOWFLAGS@ @DEBUG_FLAGS@ 
 
+# Need to explicitly set this so that AM_CXXFLAGS is last. In
+# addition, we don't use $(DEFS), which tries to set $(top_srcdir) as
+# an include diretory, which screws up shadow headers. (That way,
+# things like -O2 passed down from the toplevel can be overridden by
+# --enable-debug.)
+CXXCOMPILE = $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) 	     $(CXXFLAGS) $(AM_CXXFLAGS) 
 
-# Need to manually set this option because AC_CXXFLAGS has to be at
-# the end of the compile line so that -O2 can be overridden as the
-# occasion call for it. (ie, --enable-debug)
-AM_CXXFLAGS =  	-fno-implicit-templates $(OPTIMIZE_CXXFLAGS) 	-Wall -Wno-format -W -Wwrite-strings -Winline 	$(AC_CXXFLAGS) 
 
+LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(INCLUDES) 	       $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) 
+
+
+# We have a problem when building the shared libstdc++ object if the
+# rules automake generates would be used.  We cannot allow CXX to be used
+# in libtool since this would add -lstdc++ to the link line which of
+# course is impossible.
+CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
 
 # Root level of the include sources.
 glibcpp_includedir = $(top_srcdir)/include
@@ -139,7 +148,7 @@ glibcpp_includedir = $(top_srcdir)/include
 # Passed down for cross compilers, canadian crosses.
 TOPLEVEL_INCLUDES = -I$(includedir)
 
-LIBMATH_INCLUDES = -I$(top_srcdir)/math
+LIBMATH_INCLUDES = -I$(top_srcdir)/libmath
 @GLIBCPP_NEED_LIBIO_TRUE@LIBIO_INCLUDES = 	-I$(top_builddir)/libio -I$(top_srcdir)/libio 
 @GLIBCPP_NEED_LIBIO_FALSE@LIBIO_INCLUDES = -I$(top_srcdir)/libio
 @GLIBCPP_USE_CSHADOW_TRUE@CSHADOW_INCLUDES = 	-I$(glibcpp_includedir)/std -I$(top_srcdir)/shadow 
@@ -151,23 +160,6 @@ CONFIG_INCLUDES =  	-I$(top_srcdir)/@cpu_include_dir@ 	-I$(top_srcdir)/@ctype_in
 INCLUDES =  	-D_GNU_SOURCE -D_ISOC99_SOURCE -nostdinc++ $(CSHADOW_INCLUDES) 	-I$(top_builddir) -I$(glibcpp_includedir) 	 $(CONFIG_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES) 	 $(TOPLEVEL_INCLUDES)	
 
 
-# Need to explicitly set this so that AM_CXXFLAGS is last. In
-# addition, we don't use $(DEFS), which tries to set $(top_srcdir) as
-# an include diretory, which screws up shadow headers. (That way,
-# things like -O2 passed down from the toplevel can be overridden by
-# --enable-debug.)
-CXXCOMPILE = $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) 	     $(CXXFLAGS) $(AM_CXXFLAGS) 
-
-
-LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(INCLUDES) 	       $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) 
-
-
-# We have a problem when building the shared libstdc++ object if the
-# rules automake generates would be used.  We cannot allow CXX to be used
-# in libtool since this would add -lstdc++ to the link line which of
-# course is impossible.
-CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
-
 headers =  	bits/cpp_type_traits.h 	bits/std_cctype.h bits/ctype_base.h bits/ctype_specializations.h 	bits/char_traits.h bits/codecvt.h 	bits/basic_string.h bits/std_string.h  bits/string.tcc 	bits/generic_shadow.h bits/std_utility.h 	bits/std_complex.h 	bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h 	bits/std_valarray.h bits/mask_array.h bits/slice.h bits/slice_array.h 	bits/gslice.h bits/gslice_array.h bits/indirect_array.h 	bits/std_cassert.h bits/std_cwctype.h 	bits/std_cerrno.h bits/std_cfloat.h bits/std_climits.h 	bits/std_clocale.h bits/std_cmath.h 	bits/std_csetjmp.h bits/std_csignal.h bits/std_cstdarg.h 	bits/std_cstddef.h bits/std_cstdio.h bits/std_cstdlib.h 	bits/std_cstring.h bits/std_ctime.h bits/std_cwchar.h 	bits/std_typeinfo.h bits/std_new.h 	bits/std_exception.h bits/exception_support.h 	bits/std_fstream.h bits/std_iomanip.h 	bits/ios_base.h bits/fpos.h bits/basic_ios.h bits/basic_ios.tcc 	bits/std_ios.h bits/std_iosfwd.h bits/std_iostream.h 	bits/std_istream.h bits/istream.tcc bits/std_locale.h 	bits/fstream.tcc bits/ostream.tcc bits/sbuf_iter.h bits/sstream.tcc 	bits/std_ostream.h bits/std_sstream.h bits/std_streambuf.h 	bits/streambuf.tcc bits/basic_file.h 	bits/locale_facets.h bits/locale_facets.tcc bits/localefwd.h 	bits/stl_pthread_alloc.h bits/pthread_allocimpl.h 	bits/stl_threads.h bits/stl_iterator_base.h 	backward/algo.h backward/algobase.h backward/alloc.h 	backward/bvector.h backward/defalloc.h backward/deque.h 	backward/function.h backward/hash_map.h backward/hash_set.h 	backward/hashtable.h backward/heap.h backward/iterator.h 	backward/list.h backward/map.h backward/multimap.h backward/new.h 	backward/multiset.h backward/pair.h backward/iostream.h 	backward/rope.h backward/set.h backward/slist.h backward/stack.h 	backward/tempbuf.h backward/tree.h backward/vector.h 	backward/fstream.h 	bits/std_bitset.h bits/std_deque.h bits/std_functional.h 	bits/std_iterator.h bits/std_list.h 	bits/std_map.h bits/std_memory.h bits/std_numeric.h 	bits/std_queue.h bits/std_set.h bits/std_stack.h 	bits/std_stdexcept.h bits/std_vector.h 	bits/stl_algo.h bits/stl_algobase.h bits/stl_alloc.h 	bits/stl_deque.h bits/stl_function.h 	bits/stl_heap.h bits/stl_iterator.h bits/stl_list.h bits/stl_map.h 	bits/stl_multimap.h bits/stl_multiset.h bits/stl_numeric.h 	bits/stl_pair.h bits/stl_queue.h bits/stl_raw_storage_iter.h 	bits/stl_relops.h bits/stl_set.h 	bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h 	bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h 	bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h 	bits/concept_checks.h bits/container_concepts.h 	bits/sequence_concepts.h bits/std_strstream.h 	ext/ropeimpl.h ext/stl_rope.h 	ext/stl_bvector.h bits/stl_config.h bits/stl_construct.h 	ext/stl_hashtable.h ext/stl_hash_fun.h 	ext/hash_map ext/hash_set ext/rope ext/slist 	ext/tree ext/bvector 	shadow/assert.h shadow/ctype.h shadow/errno.h shadow/float.h 	shadow/fcntl.h shadow/libio.h shadow/iolibio.h shadow/libioP.h 	shadow/limits.h shadow/locale.h shadow/math.h shadow/setjmp.h 	shadow/signal.h shadow/stdarg.h shadow/stddef.h shadow/stdio.h 	shadow/stdlib.h shadow/string.h shadow/time.h 	shadow/pthread.h shadow/iconv.h shadow/wchar.h shadow/wctype.h 	shadow/bits/std_cassert.h shadow/bits/std_cctype.h 	shadow/bits/std_cerrno.h shadow/bits/std_cfloat.h 	shadow/bits/std_climits.h shadow/bits/std_clocale.h 	shadow/bits/std_cmath.h shadow/bits/std_csetjmp.h 	shadow/bits/std_csignal.h shadow/bits/std_cstdarg.h 	shadow/bits/std_cstddef.h shadow/bits/std_cstdio.h 	shadow/bits/std_cstdlib.h shadow/bits/std_cstring.h 	shadow/bits/std_ctime.h shadow/bits/std_cwchar.h 	shadow/bits/std_cwctype.h 	shadow/bits/wrap_libio.h shadow/bits/wrap_iolibio.h 	shadow/bits/wrap_libioP.h shadow/bits/wrap_iconv.h 	shadow/bits/wrap_fcntl.h shadow/bits/wrap_pthread.h 	shadow/sys/cdefs.h 
 
 
@@ -176,7 +168,7 @@ std_headers =  	algorithm bitset cassert cctype cerrno cfloat climits clocale ci
 @GLIBCPP_NEED_LIBIO_TRUE@libio_headers = 	$(top_srcdir)/libio/_G_config.h $(top_srcdir)/libio/libio.h
 @GLIBCPP_NEED_LIBIO_FALSE@libio_headers = 
 
-generated_headers =  	 $(top_builddir)/bits/std_limits.h $(top_builddir)/bits/c++config.h 	 $(top_builddir)/bits/c++threads.h $(top_builddir)/bits/c++io.h
+generated_headers =  	 $(top_builddir)/bits/std_limits.h $(top_builddir)/bits/c++config.h 	 $(top_builddir)/bits/c++io.h $(top_builddir)/bits/c++threads.h 
 
 
 cpu_headers =  	 $(top_srcdir)/@cpu_include_dir@/bits/atomicity.h 
@@ -196,7 +188,7 @@ libstdc___la_SOURCES = $(sources)
 
 libinst_wstring_la_SOURCES = $(wstring_sources)
 
-libstdc___la_LIBADD =  	../math/libmath.la ../libio/libio.la 	../libsupc++/libsupc++convenience.la 	@libinst_wstring_la@
+libstdc___la_LIBADD =  	../libmath/libmath.la ../libio/libio.la 	../libsupc++/libsupc++convenience.la 	@libinst_wstring_la@
 
 
 libstdc___la_LDFLAGS = -version-info 3:0:0 -lm