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