--- solenv/bin/deliver.pl.ark	2006-01-20 18:59:33.000000000 +0100
+++ solenv/bin/deliver.pl	2006-01-20 19:02:44.000000000 +0100
@@ -749,6 +749,22 @@
         my $todir = $ENV{'GCJ_CACHEDIR'};
         my $file = shift;
         $lib = basename($file);
+        my $libdir;
+        if ( -d "/usr/lib64") {
+            $libdir = "/usr/lib64/";
+        } else {
+            $libdir = "/usr/lib/";
+        }
+        if ( ! -e $ENV{GCJ_DATABASE} ) {
+            # We need to initialize our gcj database w/ the system one
+            system("cp " . $libdir . "gcj-4.1.0/classmap.db " . $ENV{GCJ_DATABASE});
+        }
+        my $system = $libdir . "lib" . $lib;
+        $system =~ s/\.jar$/.so/;
+        if ( -e $system ) {
+            print "CACHEJAR: Precompiled $lib exists in system - no need to build again.\n";
+            return;
+        }
         my $to = $todir."lib".$lib.".so";
         my $JAVALINKER = "$ENV{JAVACOMPILER} -shared -fPIC -Wl,-Bsymbolic -O2 -findirect-dispatch -fjni -o";
         print "CACHEJAR: $file -> $to with $ENV{GCJ_DATABASE}\n";
