From 2345c46783b35d7d0aafb16e0544a77aa19bd810 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 25 Jun 2015 19:00:22 -0400 Subject: [PATCH] Fix: Use env CLASSPATH when building log4j example The location of the log4j jar file is specified during configure with the CLASSPATH envvar, reuse it when building the example. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- doc/examples/java-log4j/Makefile | 10 +++++++--- doc/examples/java-log4j/run | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/examples/java-log4j/Makefile b/doc/examples/java-log4j/Makefile index 4b599642..2c629c37 100644 --- a/doc/examples/java-log4j/Makefile +++ b/doc/examples/java-log4j/Makefile @@ -20,7 +20,11 @@ JFLAGS = -g # Default JUL jar name. JARFILE=liblttng-ust-agent.jar -LOG4J=/usr/share/java/log4j.jar + +# If system classpath is empty, try to guess log4j location +ifeq "$(CLASSPATH)" "" + CLASSPATH="/usr/local/share/java/log4j.jar:/usr/share/java/log4j.jar" +endif # Check if the top level makefile overrides the JUL Jar file name. ifneq "$(JAVA_JARFILE_OVERRIDE)" "" @@ -29,9 +33,9 @@ endif # Check if the top level makefile overrides the JUL classpath. ifeq "$(JAVA_CLASSPATH_OVERRIDE)" "" - CLASSPATH=/usr/local/share/java/$(JARFILE):/usr/share/java/$(JARFILE):$(LOG4J) + CLASSPATH:=/usr/local/share/java/$(JARFILE):/usr/share/java/$(JARFILE):$(CLASSPATH) else - CLASSPATH=$(JAVA_CLASSPATH_OVERRIDE)/$(JARFILE):$(LOG4J) + CLASSPATH:=$(JAVA_CLASSPATH_OVERRIDE)/$(JARFILE):$(CLASSPATH) endif JC = javac -classpath "$(CLASSPATH):." diff --git a/doc/examples/java-log4j/run b/doc/examples/java-log4j/run index 5e3cbeb4..9dca6087 100755 --- a/doc/examples/java-log4j/run +++ b/doc/examples/java-log4j/run @@ -8,15 +8,19 @@ DIR=`dirname $0` JARFILE="liblttng-ust-agent.jar" -LOG4J="/usr/local/share/java/log4j.jar:/usr/share/java/log4j.jar" + +# If system classpath is empty, try to guess log4j location +if [ "x$CLASSPATH" = "x" ]; then + CLASSPATH="/usr/local/share/java/log4j.jar:/usr/share/java/log4j.jar" +fi cd $DIR if [ -f "$DIR/.intree" ]; then - CLASSPATH="../../../liblttng-ust-java-agent/java/$JARFILE:$LOG4J" + CLASSPATH="../../../liblttng-ust-java-agent/java/$JARFILE:$CLASSPATH" LIBPATH="../../../liblttng-ust-java-agent/jni/log4j/.libs" else - CLASSPATH="/usr/local/share/java/$JARFILE:/usr/share/java/$JARFILE:$LOG4J" + CLASSPATH="/usr/local/share/java/$JARFILE:/usr/share/java/$JARFILE:$CLASSPATH" # Use system defined java.library.path #LIBPATH="/usr/local/lib:/usr/lib" fi -- 2.34.1