diff --git a/libjava/classpath/ChangeLog.gcj b/libjava/classpath/ChangeLog.gcj
index 691c3c536af4e41de15cfe0f5e3ccb491a6e67f8..56ade6d6efcc5cfabdad8c9da5bd6ef255b7226e 100644
--- a/libjava/classpath/ChangeLog.gcj
+++ b/libjava/classpath/ChangeLog.gcj
@@ -1,15 +1,3 @@
-2006-04-04  Mark Wielaard  <mark@klomp.org>
-
-	* lib/gen-classlist.sh.in: Use classes.tmp, not classes.2
-	as temporary file name.
-
-2006-04-04  Tom Tromey  <tromey@redhat.com>
-
-	* lib/split-for-gcj.sh: Updated for multi-field format.
-	* lib/Makefile.am (CLEANFILES): Added classes.2.
-	* lib/gen-classlist.sh.in (GCJ): Removed.  Create classes.1 and
-	classes.2 using multiple fields.
-
 2006-03-29  Tom Tromey  <tromey@redhat.com>
 
 	PR gcc/26901:
diff --git a/libjava/classpath/lib/Makefile.am b/libjava/classpath/lib/Makefile.am
index c9e00191eb708a67dcffd6e1672ab3360de7e705..d73be80a09a55a3bfbe9cb228af2cb049229eeea 100644
--- a/libjava/classpath/lib/Makefile.am
+++ b/libjava/classpath/lib/Makefile.am
@@ -159,7 +159,7 @@ endif
 
 EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
 CLEANFILES = compile-classes resources classes \
-	glibj.zip classes.1 classes.2 \
+	glibj.zip classes.1 \
 	$(top_builddir)/java/util/LocaleData.java \
 	$(JAVA_DEPEND)
 
diff --git a/libjava/classpath/lib/Makefile.in b/libjava/classpath/lib/Makefile.in
index de14acf55993b97c7b9e25d3b3ed537292956099..e9b4f228f21e210589fb5abf581677630caedee1 100644
--- a/libjava/classpath/lib/Makefile.in
+++ b/libjava/classpath/lib/Makefile.in
@@ -42,11 +42,9 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
 	$(srcdir)/copy-vmresources.sh.in $(srcdir)/gen-classlist.sh.in \
 	$(srcdir)/mkcollections.pl.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
-	$(top_srcdir)/../../config/lead-dot.m4 \
-	$(top_srcdir)/../../config/no-executables.m4 \
-	$(top_srcdir)/../../libtool.m4 $(top_srcdir)/m4/acattribute.m4 \
-	$(top_srcdir)/m4/accross.m4 $(top_srcdir)/m4/acinclude.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+	$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+	$(top_srcdir)/m4/acinclude.m4 \
 	$(top_srcdir)/m4/ax_create_stdint_h.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
 	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
@@ -278,7 +276,7 @@ JAVAH = $(USER_JAVAH) -jni -classpath .:$(USER_CLASSLIB)
 @BUILD_CLASS_FILES_TRUE@noinst_DATA = genclasses compile-classes resources
 EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
 CLEANFILES = compile-classes resources classes \
-	glibj.zip classes.1 classes.2 \
+	glibj.zip classes.1 \
 	$(top_builddir)/java/util/LocaleData.java \
 	$(JAVA_DEPEND)
 
diff --git a/libjava/classpath/lib/gen-classlist.sh.in b/libjava/classpath/lib/gen-classlist.sh.in
index 4e57ceb8e2b3c6f9dc12476287426c4ecca4896c..4c3a836eb49a92535bac3f9ceecfe1d24c06d94e 100755
--- a/libjava/classpath/lib/gen-classlist.sh.in
+++ b/libjava/classpath/lib/gen-classlist.sh.in
@@ -7,34 +7,16 @@
 LC_ALL=C; export LC_ALL
 LANG=C; export LANG
 
-echo "Adding java source files from srcdir '@top_srcdir@'."
-# We construct 'classes.1' as a series of lines.  Each line
-# has three fields, which are separated by spaces.  The first
-# field is the package of this class (separated by "/"s).
-# The second field is the name of the top-level directory for
-# this file, relative to the build directory.  E.g., it might
-# look like "../../classpath/vm/reference".
-# The third field is the file name, like "java/lang/Object.java".
-# We do this because it makes splitting for the gcj build much
-# cheaper.
-(cd @top_srcdir@
- @FIND@ java javax gnu org -follow -name '*.java' -print |
- sort -r | sed -e 's,/\([^/]*\)$, \1,' |
- while read pkg file; do
-    echo $pkg @top_srcdir@ $pkg/$file
- done) > ${top_builddir}/lib/classes.1
+# We use this to decide whether we need to invoke the split script.
+GCJ="@GCJ@"
 
-# The same, but for the external code.
-# Right now all external code is in org/.
-for dir in @top_srcdir@/external/w3c_dom \
-   @top_srcdir@/external/sax @top_srcdir@/external/relaxngDatatype; do
-  (cd $dir
-  @FIND@ org -follow -name '*.java' -print |
-  sort -r | sed -e 's,/\([^/]*\)$, \1,' |
-  while read pkg file; do
-     echo $pkg $dir $pkg/$file
-  done)
-done >> ${top_builddir}/lib/classes.1
+echo "Adding java source files from srcdir '@top_srcdir@'."
+@FIND@ @top_srcdir@/java @top_srcdir@/javax @top_srcdir@/gnu \
+       @top_srcdir@/org \
+       @top_srcdir@/external/w3c_dom @top_srcdir@/external/sax \
+       @top_srcdir@/external/relaxngDatatype \
+       -follow -type f -print | sort -r | grep '\.java$' \
+       > ${top_builddir}/lib/classes.1
 
 # Generate files for the VM classes.
 : > vm.omit
@@ -47,19 +29,18 @@ for dir in $vm_dirlist; do
       if test -d $subdir; then
 	 @FIND@ $subdir -name '*.java' -print
       fi
-   done) | sed -e 's,/\([^/]*\)$, \1,' |
-   while read pkg file; do
-      echo $pkg $dir $pkg/$file >> vm.add
-      echo $pkg/$file >> vm.omit
+   done) |
+   while read f; do
+      echo $dir/$f >> vm.add
+      echo $f >> vm.omit
    done
 done
 
 # Only include generated files once.
 if test ! "${top_builddir}" -ef "@top_srcdir@"; then
   echo "Adding generated files in builddir '${top_builddir}'."
-  # Currently the only generated files are in gnu.*.
-  @FIND@ ${top_builddir}/gnu -follow -name '*.java' -print \
-  | sort >> ${top_builddir}/lib/classes.1
+  @FIND@ ${top_builddir}/gnu ${top_builddir}/java -follow -type f -print \
+  | sort | grep '\.java$' >> ${top_builddir}/lib/classes.1
 fi
 
 
@@ -70,10 +51,9 @@ for dir in $vm_dirlist; do
    fi
 done
 
-# FIXME: could be more efficient by constructing a series of greps.
 for filexp in `cat tmp.omit`; do
-   grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
-   mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
+   grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.2
+   mv ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1
 done
 
 
@@ -92,20 +72,18 @@ rm vm.add
 rm tmp.omit
 
 new=
-if test -e ${top_builddir}/lib/classes.2; then
-  p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
+if test -e ${top_builddir}/lib/classes; then
+  p=`diff ${top_builddir}/lib/classes ${top_builddir}/lib/classes.1`
   if test "$p" != ""; then
     new="true"
+    cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
   fi
 else
   new="true"
+  cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
 fi
 
 if test "$new" = "true"; then
-  cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
-  # Strip the package part.
-  sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
-     > ${top_builddir}/lib/classes
   echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
   for i in `cat ${top_builddir}/lib/classes` ; do
     echo $i "\\" >> ${top_builddir}/lib/java.dep
diff --git a/libjava/classpath/lib/split-for-gcj.sh b/libjava/classpath/lib/split-for-gcj.sh
index 4130d56648a07a3e38610d26a28fd16b1103fefd..f69b79797288d14aa38957d1fd33dfe8f19a98f5 100755
--- a/libjava/classpath/lib/split-for-gcj.sh
+++ b/libjava/classpath/lib/split-for-gcj.sh
@@ -22,24 +22,22 @@
 # java/awt/BitwiseXORComposite.class: lists/java-awt.stamp
 # lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
 
+# This uses a somewhat hacky procedure for finding the package of a
+# given file.
+
 echo "Splitting for gcj"
 rm -f Makefile.dtmp > /dev/null 2>&1
 test -d lists || mkdir lists
-# Much more efficient to do processing outside the loop...
-# The first expression computes the .class file name.
-# We only want the first three package components, and
-# we want them separated by '-'; this is the remaining expressions.
-sed -e 's, \(.*\)[.]java$, \1.java \1.class,' \
-   -e 's,^\([^/ ]*\)/\([^/ ]*\) ,\1-\2 ,' \
-   -e 's,^\([^/ ]*\)/\([^/ ]*\)/\([^/ ]*\) ,\1-\2-\3 ,' \
-   -e 's,^\([^/ ]*\)/\([^/ ]*\)/\([^/ ]*\)/[^ ]* ,\1-\2-\3 ,' \
-   classes.2 |
-while read pkg dir file f2; do
-   list=lists/$pkg
-   echo "$dir/$file" >> ${list}.list.1
-
-   echo "$f2: ${list}.stamp" >> Makefile.dtmp
-   echo "${list}.list: $dir/$file" >> Makefile.dtmp
+for dir in java javax gnu org; do
+   fgrep /$dir/ classes | while read file; do
+      pkg=`echo "$file " | sed -n -e "s,^.*/\($dir/.*\)/[^/]*$,\1,p"`
+      list=lists/`echo $pkg | sed -e 's,/,-,g' | cut -f1-3 -d-`
+      echo "$file" >> ${list}.list.1
+      f2=`echo "$file" | sed -n -e "s,^.*/\($dir/.*\)$,\1,p"`
+      f2=`echo "$f2" | sed -e 's/.java$//'`.class
+      echo "$f2: ${list}.stamp" >> Makefile.dtmp
+      echo "${list}.list: $file" >> Makefile.dtmp
+   done
 done
 
 # Only update a .list file if it changed.