Description: fml headers are got through libfml-dev, not by downloading anything Also loading the shared library from the Debian canonical location. Author: Pierre Gruet Forwarded: not-needed Last-Update: 2022-03-25 --- a/src/main/c/Makefile +++ b/src/main/c/Makefile @@ -6,31 +6,18 @@ CFLAGS=-g -O2 -Wall -fPIC $(JNI_INCLUDE_DIRS) CC=gcc -#OS-dependent extension lookup -UNAME := $(shell uname) -ifeq ($(UNAME),Darwin) -LIB_EXT=Darwin.dylib -else -LIB_EXT=Linux.so -endif +LIB_EXT=so -FERMI_LITE_COMMIT=562638112b7992f4d7a243ccd9ab2b3bd08c6b08 JNI_BASE_NAME=org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler all: libfml.$(LIB_EXT) -libfml.$(LIB_EXT): $(JNI_BASE_NAME).o fermi-lite/libfml.a +libfml.$(LIB_EXT): $(JNI_BASE_NAME).o /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so $(CC) -dynamiclib -shared -o $@ $^ -lm -lz -lpthread -fermi-lite: - 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 +$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so -fermi-lite/libfml.a: fermi-lite - $(MAKE) CFLAGS="$(CFLAGS)" -C fermi-lite libfml.a - -$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c fermi-lite/libfml.a - -test: test.o fermi-lite/libfml.a +test: test.o /usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libfml.so $(CC) -o $@ $^ -lm -lz -lpthread clean: --- a/src/main/c/org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler.c +++ b/src/main/c/org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler.c @@ -1,8 +1,7 @@ #include #include #include -#include "fermi-lite/fml.h" -#include "fermi-lite/fml_commit.h" +#include JNIEXPORT jobject JNICALL Java_org_broadinstitute_hellbender_utils_fermi_FermiLiteAssembler_createDefaultOptions( JNIEnv* env, jclass cls ) { --- a/src/main/java/org/broadinstitute/hellbender/utils/fermi/FermiLiteAssembler.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/fermi/FermiLiteAssembler.java @@ -125,41 +125,7 @@ if ( !nativeLibLoaded ) { synchronized(FermiLiteAssembler.class) { if ( !nativeLibLoaded ) { - final String libNameOverride = System.getProperty("LIBFML_PATH"); - if ( libNameOverride != null ) { - System.load(libNameOverride); - } - else { - final String osName = System.getProperty("os.name", "unknown").toUpperCase(); - final String osArch = System.getProperty("os.arch"); - final String libName; - if ( !"x86_64".equals(osArch) && !"amd64".equals(osArch) ) { - throw new IllegalStateException( - "We have pre-built fermi-lite binaries only for x86_64 and amd64. "+ - "Your os.arch is "+osArch+"."+ - "Set property LIBFML_PATH to point to a native library for your architecture."); - } - if ( osName.startsWith("MAC") ) libName = "/libfml.Darwin.dylib"; - else if ( osName.startsWith("LINUX") ) libName = "/libfml.Linux.so"; - else { - throw new IllegalStateException( - "We have pre-built fermi-lite binaries only for Linux and Mac. "+ - "Your os.name is "+osName+"."+ - "Set property LIBFML_PATH to point to a native library for your operating system."); - } - try ( final InputStream is = FermiLiteAssembler.class.getResourceAsStream(libName) ) { - if ( is == null ) { - throw new IllegalStateException("Can't find resource "+libName); - } - final File tmpFile = File.createTempFile("libfml.",".jnilib"); - tmpFile.deleteOnExit(); - Files.copy(is, tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - System.load(tmpFile.getPath()); - } - catch (IOException ioe ) { - throw new IllegalStateException("Misconfiguration: Unable to load fermi-lite native library "+libName, ioe); - } - } + System.loadLibrary("fml"); nativeLibLoaded = true; } }