From 8d17995998aa11ffeecbe2cf7701106283544253 Mon Sep 17 00:00:00 2001 From: Christian Babeux Date: Sun, 14 Sep 2014 23:30:45 -0400 Subject: [PATCH] Build the liblttng-ust-java library using the new M4 macros The liblttng-ust-java can now be built without passing paths to the JDK: $ ./configure --enable-jni-interface Signed-off-by: Christian Babeux Signed-off-by: Mathieu Desnoyers --- configure.ac | 11 ++------- liblttng-ust-java/Makefile.am | 43 ++++++++++++++--------------------- liblttng-ust-java/README | 2 +- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/configure.ac b/configure.ac index 175a0a65..bf626697 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/liblttng-ust-java/Makefile.am b/liblttng-ust-java/Makefile.am index c66dd79c..203a9ffc 100644 --- a/liblttng-ust-java/Makefile.am +++ b/liblttng-ust-java/Makefile.am @@ -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 diff --git a/liblttng-ust-java/README b/liblttng-ust-java/README index e3ad8494..d2ca4781 100644 --- a/liblttng-ust-java/README +++ b/liblttng-ust-java/README @@ -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 -- 2.34.1