package org.rocksdb.util;

public class Environment {
  private static String OS = System.getProperty("os.name").toLowerCase();
  private static String ARCH = System.getProperty("os.arch").toLowerCase();

  public static boolean isWindows() {
    return (OS.contains("win"));
  }

  public static boolean isMac() {
    return (OS.contains("mac"));
  }

  public static boolean isUnix() {
    return (OS.contains("nix") ||
        OS.contains("nux") ||
        OS.contains("aix"));
  }

  public static boolean isSolaris() {
     return OS.contains("sunos");
  }

  public static boolean is64Bit() {
    return (ARCH.indexOf("64") > 0);
  }

  public static String getSharedLibraryName(final String name) {
    return name + "jni";
  }

  public static String getSharedLibraryFileName(final String name) {
    return appendLibOsSuffix("lib" + getSharedLibraryName(name), true);
  }

  public static String getJniLibraryName(final String name) {
    if (isUnix()) {
      final String arch = (is64Bit()) ? "64" : "32";
      return String.format("%sjni-linux%s", name, arch);
    } else if (isMac()) {
      return String.format("%sjni-osx", name);
    } else if (isSolaris()) {
      return String.format("%sjni-solaris%d", name, is64Bit() ? 64 : 32);
    } else if (isWindows() && is64Bit()) {
      return String.format("%sjni-win64", name);
    }
    throw new UnsupportedOperationException();
  }

  public static String getJniLibraryFileName(final String name) {
    return appendLibOsSuffix("lib" + getJniLibraryName(name), false);
  }

  private static String appendLibOsSuffix(final String libraryFileName, final boolean shared) {
    if (isUnix() || isSolaris()) {
      return libraryFileName + ".so";
    } else if (isMac()) {
      return libraryFileName + (shared ? ".dylib" : ".jnilib");
    } else if (isWindows()) {
      return libraryFileName + ".dll";
    }
    throw new UnsupportedOperationException();
  }

  public static String getJniLibraryExtension() {
    if (isWindows()) {
      return ".dll";
    }
    return (isMac()) ? ".jnilib" : ".so";
  }
}

@@ -198,16 +198,92 @@
 ase();%0A%0A
+  public static boolean isPowerPC() %7B%0A    return ARCH.contains(%22ppc%22);%0A  %7D%0A%0A
   public
@@ -1059,17 +1059,16 @@
  arch = 
-(
 is64Bit(
@@ -1068,17 +1068,16 @@
 s64Bit()
-)
  ? %2264%22 
@@ -1084,16 +1084,42 @@
 : %2232%22;%0A
+      if(isPowerPC()) %7B%0A  
       re
@@ -1149,16 +1149,20 @@
 ni-linux
+-ppc
 %25s%22, nam
@@ -1171,16 +1171,98 @@
  arch);%0A
+      %7D else %7B%0A        return String.format(%22%25sjni-linux%25s%22, name, arch);%0A      %7D%0A
     %7D el
@@ -1348,32 +1348,83 @@
 (isSolaris()) %7B%0A
+      final String arch = is64Bit() ? %2264%22 : %2232%22;%0A
       return Str
@@ -1449,17 +1449,17 @@
 solaris%25
-d
+s
 %22, name,
@@ -1463,27 +1463,12 @@
 me, 
-is64Bit() ? 64 : 32
+arch
 );%0A 
@@ -1556,32 +1556,33 @@
 %22, name);%0A    %7D%0A
+%0A
     throw new Un
@@ -1601,32 +1601,130 @@
 rationException(
+String.format(%22Cannot determine JNI library name for ARCH='%25s' OS='%25s' name='%25s'%22, ARCH, OS, name)
 );%0A  %7D%0A%0A  public

Add support for JNI Library on Linux on PowerPC.