Fix: Use env CLASSPATH when building log4j example
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 25 Jun 2015 23:00:22 +0000 (19:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 25 Jun 2015 23:04:18 +0000 (19:04 -0400)
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 <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/java-log4j/Makefile
doc/examples/java-log4j/run

index 4b5996422c6f3768f184033fecf8f1f04997ea8c..2c629c37efe0fb23f03cf7d0966942319c8c7676 100644 (file)
@@ -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):."
index 5e3cbeb4b20e84bb16a9cd2ab9830dde9dfb7318..9dca6087690d15bff9bd6b149a2f978762d726e0 100755 (executable)
@@ -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
This page took 0.026277 seconds and 4 git commands to generate.