# DP: - Add /usr/lib/jni and /usr/lib//jni to java.library.path. # DP: - When running the i386 binaries on amd64, look in # DP: - /usr/lib32/gcj-x.y and /usr/lib32/jni instead. Index: b/src/libjava/configure.ac =================================================================== --- a/src/libjava/configure.ac +++ b/src/libjava/configure.ac @@ -1525,6 +1525,9 @@ AC_C_BIGENDIAN +MULTIARCH_DIR=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || true) +AC_SUBST(MULTIARCH_DIR) + ZLIBS= SYS_ZLIBS= ZINCS= Index: b/src/libjava/Makefile.am =================================================================== --- a/src/libjava/Makefile.am +++ b/src/libjava/Makefile.am @@ -362,6 +362,7 @@ $(WARNINGS) \ -D_GNU_SOURCE \ -DPREFIX="\"$(prefix)\"" \ + -DMULTIARCH_DIR="\"$(MULTIARCH_DIR)\"" \ -DTOOLEXECLIBDIR="\"$(toolexeclibdir)\"" \ -DJAVA_HOME="\"$(JAVA_HOME_DIR)\"" \ -DBOOT_CLASS_PATH="\"$(BOOT_CLASS_PATH_DIR)\"" \ Index: b/src/libjava/Makefile.in =================================================================== --- a/src/libjava/Makefile.in +++ b/src/libjava/Makefile.in @@ -631,6 +631,7 @@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MULTIARCH_DIR = @MULTIARCH_DIR@ NM = nm NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ @@ -1013,6 +1014,7 @@ $(WARNINGS) \ -D_GNU_SOURCE \ -DPREFIX="\"$(prefix)\"" \ + -DMULTIARCH_DIR="\"$(MULTIARCH_DIR)\"" \ -DTOOLEXECLIBDIR="\"$(toolexeclibdir)\"" \ -DJAVA_HOME="\"$(JAVA_HOME_DIR)\"" \ -DBOOT_CLASS_PATH="\"$(BOOT_CLASS_PATH_DIR)\"" \ Index: b/src/libjava/gnu/classpath/natSystemProperties.cc =================================================================== --- a/src/libjava/gnu/classpath/natSystemProperties.cc +++ b/src/libjava/gnu/classpath/natSystemProperties.cc @@ -141,6 +141,44 @@ return retval; } +static char* +AppendJniLibdir (char *path, struct utsname *u) +{ + char* retval; + const char* jnilibdir = "/usr/lib/jni"; +#ifdef MULTIARCH_DIR + const char* jnilibdir2 = "/usr/lib/" MULTIARCH_DIR "/jni"; + jsize len2 = strlen (jnilibdir2) + 2; +#else + jsize len2 = 0; +#endif + +#if defined(__linux__) && defined (__i386__) + if (! strcmp ("x86_64", u->machine)) + jnilibdir = "/usr/lib32/jni"; +#endif + + if (path) + { + jsize total = strlen (path) + + (sizeof (PATH_SEPARATOR) - 1) + strlen (jnilibdir) +len2 + 1; + retval = (char*) _Jv_Malloc (total); + strcpy (retval, path); + strcat (retval, PATH_SEPARATOR); + strcat (retval, jnilibdir); + } + else + { + retval = (char*) _Jv_Malloc (strlen (jnilibdir) + len2 + 1); + strcpy (retval, jnilibdir); + } +#ifdef MULTIARCH_DIR + strcat (retval, PATH_SEPARATOR); + strcat (retval, jnilibdir2); +#endif + return retval; +} + void gnu::classpath::SystemProperties::insertSystemProperties (::java::util::Properties *newprops) { @@ -373,8 +411,13 @@ // Prepend GCJ_VERSIONED_LIBDIR to the module load path so that // libgcj will find its own JNI libraries, like libgtkpeer.so. char* val = PrependVersionedLibdir (path); - _Jv_SetDLLSearchPath (val); + + // Append jnilibdir + char* val2 = AppendJniLibdir (val, &u); + + _Jv_SetDLLSearchPath (val2); _Jv_Free (val); + _Jv_Free (val2); } else { @@ -382,9 +425,12 @@ #ifdef USE_LTDL char *libpath = getenv (LTDL_SHLIBPATH_VAR); char* val = _Jv_PrependVersionedLibdir (libpath); - SET ("java.library.path", val); - _Jv_SetDLLSearchPath (val); + // Append jnilibdir + char* val2 = AppendJniLibdir (val, &u); + SET ("java.library.path", val2); + _Jv_SetDLLSearchPath (val2); _Jv_Free (val); + _Jv_Free (val2); #else SET ("java.library.path", ""); #endif