1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
Index: libjna-java-3.2.7/src/com/sun/jna/Platform.java
===================================================================
--- libjna-java-3.2.7.orig/src/com/sun/jna/Platform.java 2009-07-07 05:41:18.000000000 +0100
+++ libjna-java-3.2.7/src/com/sun/jna/Platform.java 2011-05-25 23:24:11.725855192 +0100
@@ -99,4 +99,57 @@
}
return Native.POINTER_SIZE == 8;
}
+ public static final boolean isGNU() {
+ String name = System.getProperty("os.name").toLowerCase().trim();
+ return "gnu".equals(name);
+ }
+ public static final boolean iskFreeBSD() {
+ String name = System.getProperty("os.name").toLowerCase().trim();
+ return "gnu/kfreebsd".equals(name);
+ }
+ public static final String getBaseArch() {
+ String arch =
+ System.getProperty("os.arch").toLowerCase().trim();
+ if("amd64".equals(arch))
+ arch = "x86_64";
+ if("i686-at386".equals(arch))
+ arch = "i386";
+ if("ppc".equals(arch))
+ arch = "powerpc";
+ if("ppc64".equals(arch))
+ arch = "powerpc64";
+ return arch;
+ }
+ public static final boolean isIntel() {
+ String arch =
+ System.getProperty("os.arch").toLowerCase().trim();
+ if (arch.equals("i386") ||
+ arch.equals("x86_64") ||
+ arch.equals("amd64")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static final boolean isPPC() {
+ String arch =
+ System.getProperty("os.arch").toLowerCase().trim();
+ if (arch.equals("ppc") ||
+ arch.equals("ppc64")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static final boolean isARM() {
+ String arch =
+ System.getProperty("os.arch").toLowerCase().trim();
+ if (arch.equals("arm")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
Index: libjna-java-3.2.7/src/com/sun/jna/NativeLibrary.java
===================================================================
--- libjna-java-3.2.7.orig/src/com/sun/jna/NativeLibrary.java 2010-07-19 08:57:18.000000000 +0100
+++ libjna-java-3.2.7/src/com/sun/jna/NativeLibrary.java 2011-05-25 23:27:45.045855352 +0100
@@ -618,7 +618,7 @@
// 64bit machines, so we have to explicitly search the 64bit one when
// running a 64bit JVM.
//
- if (Platform.isLinux() || Platform.isSolaris() || Platform.isFreeBSD()) {
+ if (Platform.isLinux() || Platform.isSolaris() || Platform.isFreeBSD() || Platform.iskFreeBSD()) {
// Linux & FreeBSD use /usr/lib32, solaris uses /usr/lib/32
archPath = (Platform.isSolaris() ? "/" : "") + Pointer.SIZE * 8;
}
@@ -628,11 +628,48 @@
"/usr/lib",
"/lib",
};
- // Linux 64-bit does not use /lib or /usr/lib
- if (Platform.isLinux() && Pointer.SIZE == 8) {
+ // Fix for multi-arch support on Ubuntu (and other
+ // multi-arch distributions)
+ // paths is scanned against real directory
+ // so for platforms which are not multi-arch
+ // this should continue to work.
+ if (Platform.isLinux() || Platform.iskFreeBSD()) {
+ // Defaults - overridden below
+ String cpu = Platform.getBaseArch();
+ String kernel = "linux";
+ String libc = "gnu";
+
+ if (Platform.isARM()) {
+ libc = "gnueabi";
+ }
+
+ String multiArchPath =
+ cpu + "-" + kernel + "-" + libc;
+
+ // Assemble path with all possible options
+ paths = new String[] {
+ "/usr/lib/" + multiArchPath,
+ "/lib/" + multiArchPath,
+ "/usr/lib" + archPath,
+ "/lib" + archPath,
+ "/usr/lib",
+ "/lib",
+ };
+ }
+ if (Platform.isGNU()) {
+ String cpu = Platform.getBaseArch();
+ String libc = "gnu";
+ String multiArchPath =
+ cpu + "-" + libc;
+
+ // Assemble path with all possible options
paths = new String[] {
+ "/usr/lib/" + multiArchPath,
+ "/lib/" + multiArchPath,
"/usr/lib" + archPath,
"/lib" + archPath,
+ "/usr/lib",
+ "/lib",
};
}
for (int i=0;i < paths.length;i++) {
Index: libjna-java-3.2.7/build.xml
===================================================================
--- libjna-java-3.2.7.orig/build.xml 2011-05-25 21:26:05.084188334 +0100
+++ libjna-java-3.2.7/build.xml 2011-05-25 21:28:42.574188163 +0100
@@ -72,6 +72,8 @@
<echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
<echo>java.home=${java.home}</echo>
<echo>java.library.path=${java.library.path}</echo>
+ <echo>os.name=${os.name}</echo>
+ <echo>os.arch=${os.arch}</echo>
<replaceregexp match="(<version>).*(</version>)"
replace="\1${jna.version}\2"
|