| 1 | Description: fml headers are got through libfml-dev, not by downloading anything |
| 2 | Also loading the shared library from the Debian canonical location. |
| 3 | Author: Pierre Gruet <[email protected]> |
| 4 | Forwarded: not-needed |
| 5 | Last-Update: 2022-03-25 |
| 6 | |
| 7 | --- a/src/main/c/Makefile |
| 8 | +++ b/src/main/c/Makefile |
| 9 | @@ -6,31 +6,18 @@ |
| 10 | CFLAGS=-g -O2 -Wall -fPIC $(JNI_INCLUDE_DIRS) |
| 11 | CC=gcc |
| 12 | |
| 13 | -#OS-dependent extension lookup |
| 14 | -UNAME := $(shell uname) |
| 15 | -ifeq ($(UNAME),Darwin) |
| 16 | -LIB_EXT=Darwin.dylib |
| 17 | -else |
| 18 | -LIB_EXT=Linux.so |
| 19 | -endif |
| 20 | +LIB_EXT=so |
| 21 | |
| 22 | -FERMI_LITE_COMMIT=562638112b7992f4d7a243ccd9ab2b3bd08c6b08 |
| 23 | JNI_BASE_NAME=org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler |
| 24 | |
| 25 | all: libfml.$(LIB_EXT) |
| 26 | |
| 27 | -libfml.$(LIB_EXT): $(JNI_BASE_NAME).o fermi-lite/libfml.a |
| 28 | +libfml.$(LIB_EXT): $(JNI_BASE_NAME).o /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so |
| 29 | $(CC) -dynamiclib -shared -o $@ $^ -lm -lz -lpthread |
| 30 | |
| 31 | -fermi-lite: |
| 32 | - git clone https://github.com/lh3/fermi-lite && cd fermi-lite && git checkout $(FERMI_LITE_COMMIT) && echo '#define FML_COMMIT "'$(FERMI_LITE_COMMIT)'"' > fml_commit.h |
| 33 | +$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so |
| 34 | |
| 35 | -fermi-lite/libfml.a: fermi-lite |
| 36 | - $(MAKE) CFLAGS="$(CFLAGS)" -C fermi-lite libfml.a |
| 37 | - |
| 38 | -$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c fermi-lite/libfml.a |
| 39 | - |
| 40 | -test: test.o fermi-lite/libfml.a |
| 41 | +test: test.o /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so |
| 42 | $(CC) -o $@ $^ -lm -lz -lpthread |
| 43 | |
| 44 | clean: |
| 45 | --- a/src/main/c/org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler.c |
| 46 | +++ b/src/main/c/org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler.c |
| 47 | @@ -1,8 +1,7 @@ |
| 48 | #include <jni.h> |
| 49 | #include <stdlib.h> |
| 50 | #include <string.h> |
| 51 | -#include "fermi-lite/fml.h" |
| 52 | -#include "fermi-lite/fml_commit.h" |
| 53 | +#include <fml.h> |
| 54 | |
| 55 | JNIEXPORT jobject JNICALL |
| 56 | Java_org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler_createDefaultOptions( JNIEnv* env, jclass cls ) { |
| 57 | --- a/src/main/java/org/broadinstitute/hellbender/utils/fermi/FermiLiteAssembler.java |
| 58 | +++ b/src/main/java/org/broadinstitute/hellbender/utils/fermi/FermiLiteAssembler.java |
| 59 | @@ -125,41 +125,7 @@ |
| 60 | if ( !nativeLibLoaded ) { |
| 61 | synchronized(FermiLiteAssembler.class) { |
| 62 | if ( !nativeLibLoaded ) { |
| 63 | - final String libNameOverride = System.getProperty("LIBFML_PATH"); |
| 64 | - if ( libNameOverride != null ) { |
| 65 | - System.load(libNameOverride); |
| 66 | - } |
| 67 | - else { |
| 68 | - final String osName = System.getProperty("os.name", "unknown").toUpperCase(); |
| 69 | - final String osArch = System.getProperty("os.arch"); |
| 70 | - final String libName; |
| 71 | - if ( !"x86_64".equals(osArch) && !"amd64".equals(osArch) ) { |
| 72 | - throw new IllegalStateException( |
| 73 | - "We have pre-built fermi-lite binaries only for x86_64 and amd64. "+ |
| 74 | - "Your os.arch is "+osArch+"."+ |
| 75 | - "Set property LIBFML_PATH to point to a native library for your architecture."); |
| 76 | - } |
| 77 | - if ( osName.startsWith("MAC") ) libName = "/libfml.Darwin.dylib"; |
| 78 | - else if ( osName.startsWith("LINUX") ) libName = "/libfml.Linux.so"; |
| 79 | - else { |
| 80 | - throw new IllegalStateException( |
| 81 | - "We have pre-built fermi-lite binaries only for Linux and Mac. "+ |
| 82 | - "Your os.name is "+osName+"."+ |
| 83 | - "Set property LIBFML_PATH to point to a native library for your operating system."); |
| 84 | - } |
| 85 | - try ( final InputStream is = FermiLiteAssembler.class.getResourceAsStream(libName) ) { |
| 86 | - if ( is == null ) { |
| 87 | - throw new IllegalStateException("Can't find resource "+libName); |
| 88 | - } |
| 89 | - final File tmpFile = File.createTempFile("libfml.",".jnilib"); |
| 90 | - tmpFile.deleteOnExit(); |
| 91 | - Files.copy(is, tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| 92 | - System.load(tmpFile.getPath()); |
| 93 | - } |
| 94 | - catch (IOException ioe ) { |
| 95 | - throw new IllegalStateException("Misconfiguration: Unable to load fermi-lite native library "+libName, ioe); |
| 96 | - } |
| 97 | - } |
| 98 | + System.loadLibrary("fml"); |
| 99 | nativeLibLoaded = true; |
| 100 | } |
| 101 | } |