Build the liblttng-ust-java library using the new M4 macros
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 15 Sep 2014 03:30:45 +0000 (23:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 19 Sep 2014 19:59:27 +0000 (15:59 -0400)
The liblttng-ust-java can now be built without passing paths to
the JDK:

$ ./configure --enable-jni-interface

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
liblttng-ust-java/Makefile.am
liblttng-ust-java/README

index 175a0a65117039e05f1681940dc50db0bf4009f2..bf626697ff34ad2b09ea2265783b99c804235d68 100644 (file)
@@ -262,19 +262,12 @@ AS_IF([test $JAVA_JDK],[
 ])
 
 # 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
index c66dd79c32b17d408ff481b4d1bea5cc527ab648..203a9ffc43335ca827dbe53c444c4305ad1b54f2 100644 (file)
@@ -1,37 +1,28 @@
-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
index e3ad8494e48cf3cfcaacc8b4d53533cf3f49b25f..d2ca47810d11b2f34f63ee46a34680084efff3d8 100644 (file)
@@ -3,7 +3,7 @@ This directory contains a simple API for instrumenting java applications.
 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
This page took 0.027957 seconds and 4 git commands to generate.