diff --git a/src/com/sun/jna/NativeLibrary.java b/src/com/sun/jna/NativeLibrary.java index 27eb569423..7c8458f047 100644 --- a/src/com/sun/jna/NativeLibrary.java +++ b/src/com/sun/jna/NativeLibrary.java @@ -944,7 +944,7 @@ static double parseVersion(String ver) { // so for platforms which are not multi-arch // this should continue to work. if (Platform.isLinux() || Platform.iskFreeBSD() || Platform.isGNU()) { - String multiArchPath = getMultiArchPath(); + String multiArchPath = Platform.getMultiArchPath(); // Assemble path with all possible options paths = new String[] { @@ -990,30 +990,6 @@ static double parseVersion(String ver) { librarySearchPath.addAll(initPaths("jna.platform.library.path")); } - private static String getMultiArchPath() { - String cpu = Platform.ARCH; - String kernel = Platform.iskFreeBSD() - ? "-kfreebsd" - : (Platform.isGNU() ? "" : "-linux"); - String libc = "-gnu"; - - if (Platform.isIntel()) { - cpu = (Platform.is64Bit() ? "x86_64" : "i386"); - } - else if (Platform.isPPC()) { - cpu = (Platform.is64Bit() ? "powerpc64" : "powerpc"); - } - else if (Platform.isARM()) { - cpu = "arm"; - libc = "-gnueabi"; - } - else if (Platform.ARCH.equals("mips64el")) { - libc = "-gnuabi64"; - } - - return cpu + kernel + libc; - } - /** * Get the library paths from ldconfig cache. Tested against ldconfig 2.13. */ diff --git a/src/com/sun/jna/Platform.java b/src/com/sun/jna/Platform.java index ac1395e95d..9004d17a72 100644 --- a/src/com/sun/jna/Platform.java +++ b/src/com/sun/jna/Platform.java @@ -352,4 +352,30 @@ static String getNativeLibraryResourcePrefix(int osType, String arch, String nam } return osPrefix; } + + public static String getMultiArchPath() { + String cpu = ARCH; + String kernel = iskFreeBSD() + ? "-kfreebsd" + : (isGNU() ? "" : "-linux"); + String libc = "-gnu"; + + if (isIntel()) { + cpu = (is64Bit() ? "x86_64" : "i386"); + } + else if (isPPC()) { + cpu = cpu.replace("ppc", "powerpc"); + } + else if (isARM()) { + cpu = (is64Bit() ? "aarch64" : "arm"); + libc = is64Bit() + ? "-gnu" + : ("armel".equals(ARCH) ? "-gnueabi" : "-gnueabihf"); + } + else if (ARCH.equals("mips64el")) { + libc = "-gnuabi64"; + } + + return cpu + kernel + libc; + } }