|
|
e63c38 |
diff --git a/Makefile b/Makefile
|
|
|
e63c38 |
new file mode 100644
|
|
|
e63c38 |
index 0000000..01934f1
|
|
|
e63c38 |
--- /dev/null
|
|
|
e63c38 |
+++ b/Makefile
|
|
|
e63c38 |
@@ -0,0 +1,33 @@
|
|
|
e63c38 |
+CC = gcc
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+BUILD_DIR = build
|
|
|
e63c38 |
+OBJECTS_DIR = $(BUILD_DIR)/objects
|
|
|
e63c38 |
+JNI_HEADERS_DIR = $(BUILD_DIR)/jni-headers
|
|
|
e63c38 |
+JNI_SOURCES_DIR = src/jni
|
|
|
e63c38 |
+INCLUDE = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+LIBS = -llz4 -lxxhash
|
|
|
e63c38 |
+JNI_PREFIX = net_jpountz_
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+default: all move_objects generate_so
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+all:
|
|
|
e63c38 |
+ $(CC) -fPIC -I $(JNI_HEADERS_DIR) \
|
|
|
e63c38 |
+ $(INCLUDE) \
|
|
|
e63c38 |
+ $(LIBS) \
|
|
|
e63c38 |
+ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)lz4_LZ4JNI.c
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+ $(CC) -fPIC -I $(JNI_HEADERS_DIR) \
|
|
|
e63c38 |
+ $(INCLUDE) \
|
|
|
e63c38 |
+ $(LIBS) \
|
|
|
e63c38 |
+ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)xxhash_XXHashJNI.c
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+move_objects:
|
|
|
e63c38 |
+ mv *.o $(OBJECTS_DIR)
|
|
|
e63c38 |
+
|
|
|
e63c38 |
+generate_so:
|
|
|
e63c38 |
+ gcc -fPIC -shared \
|
|
|
e63c38 |
+ $(OBJECTS_DIR)/*.o \
|
|
|
e63c38 |
+ $(LIB_DIR)/liblz4.so \
|
|
|
e63c38 |
+ $(LIB_DIR)/libxxhash.so \
|
|
|
e63c38 |
+ -o $(BUILD_DIR)/jni/net/jpountz/util/$(PLATFORM)/$(ARCH)/liblz4-java.so
|
|
|
e63c38 |
diff --git a/build.xml b/build.xml
|
|
|
e63c38 |
index 1d4cff5..13d8ce3 100644
|
|
|
e63c38 |
--- a/build.xml
|
|
|
e63c38 |
+++ b/build.xml
|
|
|
e63c38 |
@@ -13,7 +13,6 @@
|
|
|
e63c38 |
-->
|
|
|
e63c38 |
|
|
|
e63c38 |
|
|
|
e63c38 |
- xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
|
|
|
e63c38 |
xmlns:ivy="antlib:org.apache.ivy.ant"
|
|
|
e63c38 |
xmlns:junit4="antlib:com.carrotsearch.junit4"
|
|
|
e63c38 |
xmlns:mvn="antlib:org.apache.maven.artifact.ant">
|
|
|
e63c38 |
@@ -78,13 +77,6 @@
|
|
|
e63c38 |
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.version}/${ivy.jar.name}" dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
|
|
|
e63c38 |
</target>
|
|
|
e63c38 |
|
|
|
e63c38 |
- <target name="install-cpptasks" unless="cpptasks.available">
|
|
|
e63c38 |
-
|
|
|
e63c38 |
- inline="true" conf="default" transitive="true" pathid="cpptasks.classpath"/>
|
|
|
e63c38 |
- <taskdef uri="antlib:net.sf.antcontrib.cpptasks" resource="net/sf/antcontrib/cpptasks/antlib.xml" classpathref="cpptasks.classpath"/>
|
|
|
e63c38 |
- <property name="cpptasks.available" value="true"/>
|
|
|
e63c38 |
- </target>
|
|
|
e63c38 |
-
|
|
|
e63c38 |
<target name="install-maven-ant-tasks" unless="maven-ant-tasks.available">
|
|
|
e63c38 |
|
|
|
e63c38 |
inline="true" conf="default" transitive="true" pathid="maven-ant-tasks.classpath"/>
|
|
|
e63c38 |
@@ -184,27 +176,13 @@
|
|
|
e63c38 |
</javah>
|
|
|
e63c38 |
</target>
|
|
|
e63c38 |
|
|
|
e63c38 |
- <target name="compile-jni" depends="install-cpptasks,generate-headers" unless="${skip.jni}">
|
|
|
e63c38 |
+ <target name="compile-jni" depends="generate-headers" unless="${skip.jni}">
|
|
|
e63c38 |
<mkdir dir="${build}/objects" />
|
|
|
e63c38 |
<mkdir dir="${build}/jni/net/jpountz/util/${platform}/${os.arch}" />
|
|
|
e63c38 |
-
|
|
|
e63c38 |
- debug="false"
|
|
|
e63c38 |
- optimize="extreme"
|
|
|
e63c38 |
- objdir="${build}/objects"
|
|
|
e63c38 |
- outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
|
|
|
e63c38 |
- outtype="shared">
|
|
|
e63c38 |
- <includepath path="${src}/lz4/lib" />
|
|
|
e63c38 |
- <includepath path="${java.home}/../include" />
|
|
|
e63c38 |
- <includepath path="${java.home}/../include/${platform}/" />
|
|
|
e63c38 |
-
|
|
|
e63c38 |
- <includepath path="${java.home}/include" />
|
|
|
e63c38 |
- <includepath path="${java.home}/include/${platform}/" />
|
|
|
e63c38 |
- <includepath path="${build}/jni-headers" />
|
|
|
e63c38 |
- <fileset dir="${src}/lz4/lib" includes="lz4.c, lz4hc.c, xxhash.c" />
|
|
|
e63c38 |
- <fileset dir="${src}/jni" includes="*.c" />
|
|
|
e63c38 |
- <linker />
|
|
|
e63c38 |
- <compilerarg value="-mmacosx-version-min=10.9" if="isMacOS"/>
|
|
|
e63c38 |
- </cpptasks:cc>
|
|
|
e63c38 |
+ <exec executable="make" failonerror="true">
|
|
|
e63c38 |
+ <env key="ARCH" value="${os.arch}"/>
|
|
|
e63c38 |
+ <env key="PLATFORM" value="${platform}"/>
|
|
|
e63c38 |
+ </exec>
|
|
|
e63c38 |
</target>
|
|
|
e63c38 |
|
|
|
e63c38 |
<target name="compile" depends="compile-java, compile-jni" />
|