[lttng-dev] [PATCH lttng-ust] Fix: build log4j example when enabled

Michael Jeanson mjeanson at efficios.com
Thu Jun 25 17:13:07 EDT 2015


Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 .gitignore                      |  2 +-
 doc/examples/Makefile.am        | 26 +++++++++++++++++++++++---
 doc/examples/java-jul/run       |  3 ++-
 doc/examples/java-log4j/.intree |  0
 doc/examples/java-log4j/run     |  5 +++--
 5 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 doc/examples/java-log4j/.intree

diff --git a/.gitignore b/.gitignore
index 166a260..6ff01a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,7 +54,7 @@ tests/benchmark/bench2
 
 # Java agent library
 *.class
-liblttng-ust-agent.jar
+liblttng-ust-agent*.jar
 classnoinst.stamp
 jni-header.stamp
 jul-jni-header.stamp
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 0d22602..9404054 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -8,7 +8,7 @@ doc_examples_demo_tracelogdir = ${docdir}/examples/demo-tracelog
 doc_examples_clock_overridedir = ${docdir}/examples/clock-override
 doc_examples_getcpu_overridedir = ${docdir}/examples/getcpu-override
 
-if BUILD_JAVA_AGENT
+if BUILD_JAVA_AGENT_WITH_JUL
 doc_examples_java_juldir = ${docdir}/examples/java-jul
 dist_doc_examples_java_jul_DATA = java-jul/Makefile \
 				  java-jul/Hello.java \
@@ -16,6 +16,14 @@ dist_doc_examples_java_jul_DATA = java-jul/Makefile \
 SUBDIRS_JUL = java-jul
 endif
 
+if BUILD_JAVA_AGENT_WITH_LOG4J
+doc_examples_java_log4jdir = ${docdir}/examples/java-log4j
+dist_doc_examples_java_log4j_DATA = java-log4j/Makefile \
+				  java-log4j/Hello.java \
+				  java-log4j/run
+SUBDIRS_LOG4J = java-log4j
+endif
+
 dist_doc_examples_DATA = README
 
 dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \
@@ -74,7 +82,7 @@ endif
 
 all-local:
 	@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
-		for subdir in $(SUBDIRS_PROXY) $(SUBDIRS_JUL); do \
+		for subdir in $(SUBDIRS_PROXY) $(SUBDIRS_JUL) $(SUBDIRS_LOG4J); do \
 			cp -pfR $(srcdir)/$$subdir $(builddir); \
 		done; \
 	fi; \
@@ -99,6 +107,11 @@ all-local:
 		for subdir in $(SUBDIRS_JUL); do \
 			(cd $(SUBDIRS_JUL) && $(MAKE) JAVA_CLASSPATH_OVERRIDE="../../../liblttng-ust-java-agent/java" JAVA_JARFILE_OVERRIDE="liblttng-ust-agent.jar" $(AM_MAKEFLAGS) all && cd ..) || exit 1; \
 		done; \
+	fi; \
+	if [ x"$(SUBDIRS_LOG4J)" != x"" ]; then \
+		for subdir in $(SUBDIRS_LOG4J); do \
+			(cd $(SUBDIRS_LOG4J) && $(MAKE) JAVA_CLASSPATH_OVERRIDE="../../../liblttng-ust-java-agent/java" JAVA_JARFILE_OVERRIDE="liblttng-ust-agent.jar" $(AM_MAKEFLAGS) all && cd ..) || exit 1; \
+		done; \
 	fi;
 
 clean-local:
@@ -114,8 +127,15 @@ clean-local:
 			fi; \
 		done; \
 	fi; \
+	if [ x"$(SUBDIRS_LOG4J)" != x"" ]; then \
+		for subdir in $(SUBDIRS_LOG4J); do \
+			if [ -d $$subdir ]; then \
+				(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) clean && cd ..) || exit 1; \
+			fi; \
+		done; \
+	fi; \
 	if [ x"$(srcdir)" != x"$(builddir)" ]; then \
-		for subdir in $(SUBDIRS_PROXY) $(SUBDIRS_JUL); do \
+		for subdir in $(SUBDIRS_PROXY) $(SUBDIRS_JUL) $(SUBDIRS_LOG4J); do \
 			rm -rf $(builddir)/$$subdir; \
 		done; \
 	fi;
diff --git a/doc/examples/java-jul/run b/doc/examples/java-jul/run
index 1beac85..37a3cfd 100755
--- a/doc/examples/java-jul/run
+++ b/doc/examples/java-jul/run
@@ -16,7 +16,8 @@ if [ -f "$DIR/.intree" ]; then
 	LIBPATH="../../../liblttng-ust-java-agent/jni/jul/.libs"
 else
 	CLASSPATH="/usr/local/share/java/$JARFILE:/usr/share/java/$JARFILE"
-	LIBPATH="/usr/local/lib:/usr/lib"
+	# Use system defined java.library.path
+	#LIBPATH="/usr/local/lib:/usr/lib"
 fi
 
 java -classpath "$CLASSPATH:." -Djava.library.path="$LIBPATH" Hello
diff --git a/doc/examples/java-log4j/.intree b/doc/examples/java-log4j/.intree
new file mode 100644
index 0000000..e69de29
diff --git a/doc/examples/java-log4j/run b/doc/examples/java-log4j/run
index 128725f..5e3cbeb 100755
--- a/doc/examples/java-log4j/run
+++ b/doc/examples/java-log4j/run
@@ -17,9 +17,10 @@ if [ -f "$DIR/.intree" ]; then
 	LIBPATH="../../../liblttng-ust-java-agent/jni/log4j/.libs"
 else
 	CLASSPATH="/usr/local/share/java/$JARFILE:/usr/share/java/$JARFILE:$LOG4J"
-	LIBPATH="/usr/local/lib:/usr/lib"
+	# Use system defined java.library.path
+	#LIBPATH="/usr/local/lib:/usr/lib"
 fi
 
-java -classpath "$CLASSPATH:." Hello
+java -classpath "$CLASSPATH:." -Djava.library.path="$LIBPATH" Hello
 
 cd -
-- 
1.9.1




More information about the lttng-dev mailing list