diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7d1d6262861832a4ee1fbeb3d914c31bed1fe067..e00b406ed1a4d04231ff5e894fcec24b69a04ffe 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2003-07-05  Phil Edwards  <pme@gcc.gnu.org>
+
+	* scripts/create_testsuite_files:  New file.
+	* testsuite/Makefile.am (all-local, check-performance):  Use it.
+	* testsuite/lib/libstdc++-v3-dg.exp (v3-computer-tests):  Remove.
+	* testsuite/Makefile.in:  Regenerated.
+
+	* testsuite/performance/filebuf_sputc.cc:  Remove the temporary
+	files at the end.
+	* testsuite/performance/fstream_seek_write.cc:  Likewise.
+	* testsuite/performance/ofstream_insert_float.cc:  Likewise.
+	* testsuite/performance/ofstream_insert_int.cc:  Likewise.
+	* testsuite/abi_check.cc (main):  Nicer spacing in usage output.
+
 2003-07-05  Gawain Bolton  <gp.bolton@computer.org>
 
 	* include/bits/stl_list.h: Performance and memory usage
diff --git a/libstdc++-v3/scripts/create_testsuite_files b/libstdc++-v3/scripts/create_testsuite_files
new file mode 100755
index 0000000000000000000000000000000000000000..7fbcbdb2fb3a0e5640cca0397e228c24ead20302
--- /dev/null
+++ b/libstdc++-v3/scripts/create_testsuite_files
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Constructs lists of source files (full pathnames) to test.  Two
+# files are constructed: testsuite_files, which is used to test with
+# the default dg-runtest command, and testsuite_files_interactive,
+# which is used to test cases that require input to be entered. In
+# addition, both lists are pruned of wchar_t tests if the toolchain
+# under test does not support wchar_t functionality.
+#
+# We mimic the mkcheck script in that the first time this is run, all
+# existing files are listed in "testsuite_files" in the output
+# directory.  Subsequent runs pull the list from that file, allowing
+# users to trim the list down to problematic tests, or just run
+# paticular directories or sub-directories of tests.
+#
+# Selecting individual tests can also be done with RUNTESTFLAGS, but
+# that doesn't really do all that we are trying to accomplish here.
+
+LC_ALL=C
+export LC_ALL
+
+# Both of these are in the appropriate testsuite subdirectories.
+srcdir="$1"
+outdir="$2"
+
+tmp="${TMPDIR:-/tmp}/ctt$$"
+tests_file_normal="$outdir/testsuite_files"
+tests_file_inter="$outdir/testsuite_files_interactive"
+tests_file_perf="$outdir/testsuite_files_performance"
+
+cd $srcdir
+# This is the ugly version of "everything but the current directory".  It's
+# what has to happen when find(1) doesn't support -mindepth.
+dlist=`echo [0-9][0-9]*`
+for d in [a-z]*; do
+  test -d $d && dlist="$dlist $d"
+done
+find $dlist -type f -name "*.cc" | sort > $tmp.1
+
+# If the library is not configured to support wchar_t, don't run those tests.
+if test -f "$outdir/testsuite_wchar_t"; then
+  mv $tmp.1 $tmp.2
+else
+  grep -v wchar_t $tmp.1 > $tmp.2
+fi
+
+# Now filter out classes of tests.  These classes are run using special rules.
+grep _xin $tmp.2 > $tests_file_inter
+grep -v _xin $tmp.2 > $tmp.3
+
+grep performance $tmp.3 > $tests_file_perf
+grep -v performance $tmp.3 > $tmp.4
+
+# ...more filters go here.
+cp $tmp.4 $tests_file_normal
+
+rm $tmp*
+exit 0
diff --git a/libstdc++-v3/testsuite/Makefile.am b/libstdc++-v3/testsuite/Makefile.am
index 1261e3d1262f45f3a42f8b956d1ca3428600057f..bbe1fe5f45b29b9ca72d8ac7e8dba074e6440eee 100644
--- a/libstdc++-v3/testsuite/Makefile.am
+++ b/libstdc++-v3/testsuite/Makefile.am
@@ -38,6 +38,7 @@ RUNTEST = `if [ -f @glibcxx_srcdir@/../dejagnu/runtest ] ; then \
 AM_MAKEFLAGS = -j1
 AM_RUNTESTFLAGS =
 RUNTESTFLAGS =
+PWD_COMMAND = $${PWDCMD-pwd}
 
 ## CXX is actually a "C" compiler. These are real C++ programs.
 glibcxx_srcdir=@glibcxx_srcdir@
@@ -57,6 +58,13 @@ INCLUDES = \
 	-nostdinc++ \
 	@GLIBCXX_INCLUDES@ @LIBSUPCXX_INCLUDES@ @TOPLEVEL_INCLUDES@ 
 
+# Generated lists of files to run.  All of these names are valid make
+# targets, if you wish to generate a list manually.
+lists_of_files = \
+   testsuite_files \
+   testsuite_files_interactive \
+   testsuite_files_performance
+
 ## Build support library.
 noinst_LIBRARIES = libv3test.a
 libv3test_a_SOURCES = testsuite_hooks.cc testsuite_allocator.cc
@@ -69,7 +77,7 @@ noinst_PROGRAMS =
 endif
 abi_check_SOURCES = abi_check.cc
 
-all-local: stamp_wchar
+all-local: stamp_wchar testsuite_files
 
 # Enable wchar_t tests if capable.
 if GLIBCXX_TEST_WCHAR_T
@@ -144,10 +152,17 @@ check-script-install: ${survey_script}
 # ammounts of memory, or otherwise tie up machine resources. Thus,
 # running this is off by default.
 performance_script=${glibcxx_srcdir}/scripts/check_performance
-check-performance: ${performance_script}
+check-performance: testsuite_files_performance ${performance_script}
 	-@(chmod + ${performance_script}; \
 	  ${performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
 
+
+# This rule generates all of the testsuite_files* lists at once.
+${lists_of_files}:
+	${glibcxx_srcdir}/scripts/create_testsuite_files \
+	  ${glibcxx_srcdir}/testsuite `${PWD_COMMAND}`
+
+
 .PHONY: baseline_symbols new-abi-baseline check-abi check-abi-verbose \
 check-script check-script-install check-performance
 
diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in
index c4fe41e9673c420e0fd83c27d23cd1728c07cb9a..1752949b54224e44007824f12f78cb89222f99b2 100644
--- a/libstdc++-v3/testsuite/Makefile.in
+++ b/libstdc++-v3/testsuite/Makefile.in
@@ -143,42 +143,39 @@ mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
 
 DEJATOOL = libstdc++-v3
 
-EXPECT = `if [ -f @glibcxx_builddir@/../../expect/expect ] ; then \
-            echo @glibcxx_builddir@/../../expect/expect ; \
-          else echo expect ; fi`
+EXPECT = `if [ -f @glibcxx_builddir@/../../expect/expect ] ; then             echo @glibcxx_builddir@/../../expect/expect ;           else echo expect ; fi`
 
 
-RUNTEST = `if [ -f @glibcxx_srcdir@/../dejagnu/runtest ] ; then \
-	       echo @glibcxx_srcdir@/../dejagnu/runtest ; \
-	    else echo runtest; fi`
+RUNTEST = `if [ -f @glibcxx_srcdir@/../dejagnu/runtest ] ; then 	       echo @glibcxx_srcdir@/../dejagnu/runtest ; 	    else echo runtest; fi`
 
 
 AM_MAKEFLAGS = -j1
 AM_RUNTESTFLAGS = 
 RUNTESTFLAGS = 
+PWD_COMMAND = $${PWDCMD-pwd}
 
 glibcxx_srcdir = @glibcxx_srcdir@
 glibcxx_builddir = @glibcxx_builddir@
 testsuite_flags_script = ${glibcxx_builddir}/scripts/testsuite_flags
 CXX = `${testsuite_flags_script} --build-cxx`
 
-CXXLINK = \
-	LD_RUN_PATH=$${LD_RUN_PATH:+$$LD_RUN_PATH:}${glibcxx_builddir}/src/.libs\
-	$(LIBTOOL) --tag=CXX --mode=link $(CXX) \
-	$(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
+CXXLINK =  	LD_RUN_PATH=$${LD_RUN_PATH:+$$LD_RUN_PATH:}${glibcxx_builddir}/src/.libs 	$(LIBTOOL) --tag=CXX --mode=link $(CXX) 	$(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
 
 
 GLIBCXX_INCLUDES = @GLIBCXX_INCLUDES@
 LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
 TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
-INCLUDES = \
-	-nostdinc++ \
-	@GLIBCXX_INCLUDES@ @LIBSUPCXX_INCLUDES@ @TOPLEVEL_INCLUDES@ 
+INCLUDES =  	-nostdinc++ 	@GLIBCXX_INCLUDES@ @LIBSUPCXX_INCLUDES@ @TOPLEVEL_INCLUDES@ 
+
+
+# Generated lists of files to run.  All of these names are valid make
+# targets, if you wish to generate a list manually.
+lists_of_files =     testsuite_files    testsuite_files_interactive    testsuite_files_performance
 
 
 noinst_LIBRARIES = libv3test.a
 libv3test_a_SOURCES = testsuite_hooks.cc testsuite_allocator.cc
-@GLIBCXX_TEST_ABI_TRUE@noinst_PROGRAMS = @GLIBCXX_TEST_ABI_TRUE@abi_check
+@GLIBCXX_TEST_ABI_TRUE@noinst_PROGRAMS = abi_check
 @GLIBCXX_TEST_ABI_FALSE@noinst_PROGRAMS = 
 abi_check_SOURCES = abi_check.cc
 
@@ -200,8 +197,7 @@ survey_script = ${glibcxx_builddir}/scripts/check_survey
 performance_script = ${glibcxx_srcdir}/scripts/check_performance
 
 # By adding these files here, automake will remove them for 'make clean'
-CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \
-	     testsuite_* site.exp abi_check baseline_symbols 
+CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum 	     testsuite_* site.exp abi_check baseline_symbols 
 
 CONFIG_HEADER = ../config.h
 CONFIG_CLEAN_FILES = 
@@ -231,7 +227,7 @@ DIST_COMMON =  Makefile.am Makefile.in
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 SOURCES = $(libv3test_a_SOURCES) $(abi_check_SOURCES)
 OBJECTS = $(libv3test_a_OBJECTS) $(abi_check_OBJECTS)
@@ -342,7 +338,7 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
 	  awk '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
 	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	  || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags  $$unique $(LISP))
 
 mostlyclean-tags:
 
@@ -399,7 +395,7 @@ site.exp: Makefile
 	@echo 'set build_alias $(build_alias)' >> $@-t
 	@echo 'set build_triplet $(build_triplet)' >> $@-t
 	@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
-	@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
+	@test ! -f $(srcdir)/site.exp || sed '1,/^## All variables above are.*##/ d' $(srcdir)/site.exp >> $@-t
 	@test ! -f site.exp || mv site.exp site.bak
 	@mv $@-t site.exp
 info-am:
@@ -485,7 +481,7 @@ distclean-generic clean-generic maintainer-clean-generic clean \
 mostlyclean distclean maintainer-clean
 
 
-all-local: stamp_wchar
+all-local: stamp_wchar testsuite_files
 
 # Enable wchar_t tests if capable.
 @GLIBCXX_TEST_WCHAR_T_TRUE@stamp_wchar:
@@ -535,10 +531,15 @@ check-script: ${survey_script}
 check-script-install: ${survey_script}
 	-@(chmod + ${survey_script}; \
 	  ${survey_script} 0)
-check-performance: ${performance_script}
+check-performance: testsuite_files_performance ${performance_script}
 	-@(chmod + ${performance_script}; \
 	  ${performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
 
+# This rule generates all of the testsuite_files* lists at once.
+${lists_of_files}:
+	${glibcxx_srcdir}/scripts/create_testsuite_files \
+	  ${glibcxx_srcdir}/testsuite `${PWD_COMMAND}`
+
 .PHONY: baseline_symbols new-abi-baseline check-abi check-abi-verbose \
 check-script check-script-install check-performance
 
diff --git a/libstdc++-v3/testsuite/abi_check.cc b/libstdc++-v3/testsuite/abi_check.cc
index 7b98319707b700c85c025efdb4de04fbf8697d64..2116f7a6b30c420c3c228847e9f6f3871d390d95 100644
--- a/libstdc++-v3/testsuite/abi_check.cc
+++ b/libstdc++-v3/testsuite/abi_check.cc
@@ -317,7 +317,7 @@ main(int argc, char** argv)
   string argv1 = argc > 1 ? argv[1] : "";
   if (argv1 == "--help" || argc < 4)
     {
-      cerr << "usage: abi_check --check current baseline\n"
+      cerr << "usage: abi_check --check         current baseline\n"
               "                 --check-verbose current baseline\n"
               "                 --help\n\n"
               "Where CURRENT is a file containing the current results from\n"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp b/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp
index 401c397ae6bafef0d8e08dea013bcfce4af1e3e4..c7e2a9b909d883ebb0a112b1a0086c3879780c42 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp
@@ -59,9 +59,6 @@ proc libstdc++-v3-init { args } {
     libstdc++-v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"] $outdir
     libstdc++-v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"] $outdir
 
-    # Compute lists of files to test.
-    v3-compute-tests
-
     # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
     # locate libgcc.a so we don't need to account for different values of
     # SHLIB_EXT on different platforms
@@ -218,115 +215,6 @@ proc libstdc++-v3_target_compile { source dest type options } {
 }
 
 
-# Constructs lists of source files (full pathnames) to test.  Two
-# files are constructed: testsuite_files, which is used to test with
-# the default dg-runtest command, and testsuite_files_interactive,
-# which is used to test cases that require input to be entered. In
-# addition, both lists are pruned of wchar_t tests if the toolchain
-# under test does not support wchar_t functionality.
-#
-# We mimic the mkcheck script in that the first time this is run, all
-# existing files are listed in "testsuite_files" in the output
-# directory.  Subsequent runs pull the list from that file, allowing
-# users to trim the list down to problematic tests, or just run
-# paticular directories or sub-directories of tests.
-#
-# Selecting individual tests can also be done with RUNTESTFLAGS, but
-# that doesn't really do all that we are trying to accomplish here.
-#
-# Essentially "static" to this file.
-proc v3-compute-tests { } {
-    global srcdir
-    global outdir
-
-    set tests_file "${outdir}/testsuite_files"
-    set tests_file_inter "${outdir}/testsuite_files_interactive"
-    set tests_file_perf "${outdir}/testsuite_files_performance"
-    set sfiles ""
-
-    # If there is a testsuite_file, use it. 
-    if { [file exists $tests_file] } {
-	return 
-    } 
-
-    # If not, generate it. 
-    set where_we_were [pwd]
-    cd $srcdir
-    foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] {
-	lappend sfiles ${s}
-    }
-    cd $where_we_were
-
-    # Filter wchar_t tests.
-    # Disable wchar_t tests if library not configured to support
-    # wchar_t testing. 
-    set wchar_file "${outdir}/testsuite_wchar_t"    
-    if { ! [file exists $wchar_file] } {
-	# Remove wchar_t tests files from list.
-	set res {}
-	foreach w $sfiles {
-	    if [regexp "wchar_t" $w] {
-		verbose "element wchar list is $w"
-	    } else {
-		verbose "element non-wchar list is $w"
-		lappend res $w
-	    }
-	}
-	set sfiles ${res}
-    }
-
-    # Filter interactive tests.
-    # Use special rules to run these tests.
-    set restwo {}
-    set sfiles_inter {}
-    foreach i $sfiles {
-	if [regexp "_xin" $i] {
-	    verbose "element interactive list is $i"
-	    lappend sfiles_inter $i
-	} else {
-	    verbose "element non-interactive list is $i"
-	    lappend restwo $i
-	}
-    }
-    set sfiles ${restwo}
-
-    # Filter performance analysis tests.
-    # Use special rules to run these tests.
-    set resthree {}
-    set sfiles_perf {}
-    foreach i $sfiles {
-	if [regexp "performance" $i] {
-	    verbose "element performance list is $i"
-	    lappend sfiles_perf $i
-	} else {
-	    verbose "element non-performancet list is $i"
-	    lappend resthree $i
-	}
-    }
-    set sfiles ${resthree}
-
-    # Write out testsuite_files.
-    set f [open $tests_file "w"]
-    foreach t $sfiles {
-	puts $f $t
-    }
-    close $f
-
-    # Write out testsuite_files_interactive.
-    set f [open $tests_file_inter "w"]
-    foreach t $sfiles_inter {
-	puts $f $t
-    }
-    close $f
-
-    # Write out testsuite_files_performance.
-    set f [open $tests_file_perf "w"]
-    foreach t $sfiles_perf {
-	puts $f $t
-    }
-    close $f
-}
-
 # Called once, from libstdc++-v3.dg/dg.exp.
 proc v3-list-tests { filename } {
     global srcdir
diff --git a/libstdc++-v3/testsuite/performance/filebuf_sputc.cc b/libstdc++-v3/testsuite/performance/filebuf_sputc.cc
index 513f75d44f596cc71407b4d444e249e92fe522cf..cdf030d0fba40c2a38571f9deb27359a58171b25 100644
--- a/libstdc++-v3/testsuite/performance/filebuf_sputc.cc
+++ b/libstdc++-v3/testsuite/performance/filebuf_sputc.cc
@@ -69,5 +69,6 @@ int main()
   stop_counters(time, resource);
   report_performance(__FILE__, "C++", time, resource);
 
+  unlink("tmp");
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/performance/fstream_seek_write.cc b/libstdc++-v3/testsuite/performance/fstream_seek_write.cc
index d14fd610f0eb59bf607df4d60cddd56b5915e24c..6c56c27a76b8da9ac62be1d79654f3ebfc42b917 100644
--- a/libstdc++-v3/testsuite/performance/fstream_seek_write.cc
+++ b/libstdc++-v3/testsuite/performance/fstream_seek_write.cc
@@ -53,5 +53,6 @@ int main()
       report_performance(__FILE__, "", time, resource);
     }
 
+  unlink("tmp_perf_seek");
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc b/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc
index 549e2030ddd496de747026f46f7374552b8ab09f..910291a4e01b65ff004a528872c32ec9027d4ae4 100644
--- a/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc
+++ b/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc
@@ -48,5 +48,6 @@ int main()
   stop_counters(time, resource);
   report_performance(__FILE__, "", time, resource);
 
+  unlink("tmp_perf_float.txt");
   return 0;
 };
diff --git a/libstdc++-v3/testsuite/performance/ofstream_insert_int.cc b/libstdc++-v3/testsuite/performance/ofstream_insert_int.cc
index f068767a1784b0da4184b7d593c64abc5325e29c..c2e591a0f226468777e7e5b6a0c8d84dc046d28b 100644
--- a/libstdc++-v3/testsuite/performance/ofstream_insert_int.cc
+++ b/libstdc++-v3/testsuite/performance/ofstream_insert_int.cc
@@ -45,5 +45,6 @@ int main()
   stop_counters(time, resource);
   report_performance(__FILE__, "", time, resource);
 
+  unlink("tmp_perf_int.txt");
   return 0;
 };