])
# Check for JNI header files if requested
-AC_ARG_WITH([jni-interface],
- [AS_HELP_STRING([--with-jni-interface],[build JNI interface between C and Java. Needs Java include files [default=no]])],
+AC_ARG_ENABLE([jni-interface],
+ [AS_HELP_STRING([--enable-jni-interface],[build JNI interface between C and Java. Needs Java include files [default=no]])],
[jni_interface=$withval],
[jni_interface=no]
)
-AS_IF([test "x$jni_interface" = "xyes"],[
- AC_CHECK_HEADERS([jni.h],[],[
- AC_MSG_ERROR([missing jni.h
-Make sure Sun Java, OpenJDK or GCJ is installed and that this header file exists in the system path.
-Use the --with-java-jdk=DIR option to point to your JDK directory, or disable the JNI interface.])
- ])
-])
AM_CONDITIONAL([BUILD_JNI_INTERFACE], [test "x$jni_interface" = "xyes"])
# sdt.h integration
-LTTNG_JUST_SRCDIR = $(srcdir)/org/lttng/ust
-LTTNG_JUST_DESTDIR = $(builddir)/org/lttng/ust
-
-if BUILD_JNI_INTERFACE
-
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(builddir) -I$(top_builddir)/include
+JAVAROOT = .
+jarfile = liblttng-ust-java.jar
+jardir = $(datadir)/java
+pkgpath = org/lttng/ust
+dist_noinst_JAVA = $(pkgpath)/LTTngUst.java
+jar_DATA = $(jarfile)
BUILT_SOURCES = org_lttng_ust_LTTngUst.h
+
+AM_CPPFLAGS = -I$(top_srcdir)/include
lib_LTLIBRARIES = liblttng-ust-java.la
liblttng_ust_java_la_SOURCES = LTTngUst.c lttng_ust_java.h
nodist_liblttng_ust_java_la_SOURCES = org_lttng_ust_LTTngUst.h
-dist_noinst_DATA = $(LTTNG_JUST_SRCDIR)/LTTngUst.java
-liblttng_ust_java_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-ust
-
-if HAVE_JAVA_JDK
-JCC=$(JAVA_JDK)/bin
-else
-JCC=javac
-endif
-all: $(LTTNG_JUST_DESTDIR)/LTTngUst.class org_lttng_ust_LTTngUst.h liblttng-ust-java.jar
+liblttng_ust_java_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-ust
-clean-local:
- rm -f org_lttng_ust_LTTngUst.h
- rm -f liblttng-ust-java.jar
- rm -rf org/lttng/ust/*.class
+$(jarfile): classnoinst.stamp
+ $(JAR) cf $(JARFLAGS) $@ $(pkgpath)/*.class
-$(LTTNG_JUST_DESTDIR)/LTTngUst.class: $(LTTNG_JUST_SRCDIR)/LTTngUst.java
- $(JCC)/javac -d "$(builddir)" "$(LTTNG_JUST_SRCDIR)/LTTngUst.java"
+org_lttng_ust_LTTngUst.h: jni-header.stamp
-org_lttng_ust_LTTngUst.h: $(LTTNG_JUST_DESTDIR)/LTTngUst.class
- $(JCC)/javah org.lttng.ust.LTTngUst
+jni-header.stamp: $(dist_noinst_JAVA)
+ $(JAVAH) -cp . $(JAVAHFLAGS) org.lttng.ust.LTTngUst && \
+ echo "JNI header generated" > jni-header.stamp
-liblttng-ust-java.jar: $(LTTNG_JUST_DESTDIR)/LTTngUst.class
- $(JCC)/jar cf liblttng-ust-java.jar $(LTTNG_JUST_DESTDIR)/*.class
+all-local: org_lttng_ust_LTTngUst.h
-endif
+CLEANFILES = $(jarfile) $(pkgpath)/*.class jni-header.stamp org_lttng_ust_LTTngUst.h
Configuration examples to build this library:
dependency: openjdk-7-jdk
-./configure --with-java-jdk=/usr/lib/jvm/java-7-openjdk --with-jni-interface
+./configure --enable-jni-interface
Note that the OpenJDK 7 is used for development and continuous integration thus
we directly support that version for this library. However, it has been tested