+# Set compile flags to java include files if given. This is only used to
+# compile java agent tests.
+AC_ARG_WITH([java-jdk],
+ [AS_HELP_STRING([--with-java-jdk=DIR],[use the Java JDK in DIR. Ex : $JAVA_HOME.])],
+ [JAVA_JDK=$withval],
+ [JAVA_JDK=""]
+)
+AM_CONDITIONAL([HAVE_JAVA_JDK], [test $JAVA_JDK], [Java JDK path])
+AC_SUBST([JAVA_JDK])
+
+AS_IF([test $JAVA_JDK],[
+ AS_IF([test -d $JAVA_JDK],
+ [
+ AC_MSG_RESULT([using Java includes in $JAVA_SDK])
+ SUBDIRS=`find $JAVA_JDK/include -type d`
+ CPPFLAGS+=" "
+ CPPFLAGS+=`for x in $SUBDIRS; do echo -n "-I$x "; done`
+ CPPFLAGS+=" "
+ ],[AC_MSG_ERROR(Unable to find Java include files in $JAVA_JDK)]
+ )
+])
+
+# Check for the UST agent jar file in the system. Hardcoded path is added here
+# since we have *no* idea where this could be installed. Note that this is only
+# used for agent testing.
+AC_MSG_CHECKING(Java UST agent jar file)
+java_agent_jar_path="${prefix}/share/java/liblttng-ust-agent.jar"
+if test -f $java_agent_jar_path; then
+ build_java_agent=yes
+ AC_MSG_RESULT(found)
+else
+ build_java_agent=no
+ AC_MSG_RESULT(not found)
+fi
+AM_CONDITIONAL([BUILD_JAVA_AGENT], [test "x$build_java_agent" = "xyes"])
+AC_SUBST([java_agent_jar_path])
+
+# Check for log4j support on the system to know if we can build or not the
+# log4j tests.
+if test "x$build_java_agent" = "xyes"; then
+ AC_MSG_CHECKING(Java agent support for log4j)
+ AX_JAVA_OPTIONS
+ AX_PROG_JAR
+ AX_PROG_JAVA
+ AX_PROG_JAVAC
+
+ # By default, use a commonly used classpath on the system to ease things up
+ # for the Java testing in this directory.
+ LOG4J_CLASSPATH="$java_agent_jar_path:$CLASSPATH:.:/usr/share/java/*"
+ JAVAFLAGS="-cp $LOG4J_CLASSPATH"
+ JAVACFLAGS="$JAVAFLAGS"
+ AX_CHECK_CLASS(org.apache.log4j.Logger)
+
+ if test "x$ac_cv_class_org_apache_log4j_Logger" = "xno"; then
+ build_java_log4j_agent=no
+ else
+ build_java_log4j_agent=yes
+ fi
+fi
+AM_CONDITIONAL([BUILD_JAVA_LOG4J_AGENT], [test "x$build_java_log4j_agent" = "xyes"])
+
+AC_SYS_LARGEFILE