+AM_CONDITIONAL([TEST_JAVA_JUL_AGENT], [test "x$test_java_agent_jul" = "xyes"])
+AM_CONDITIONAL([TEST_JAVA_LOG4J_AGENT], [test "x$test_java_agent_log4j" = "xyes"])
+
+if test "x$test_java_agent_jul" = "xyes" || test "x$test_java_agent_log4j" = "xyes"; then
+ AX_JAVA_OPTIONS
+ AX_PROG_JAVAC
+ AX_PROG_JAVA
+ AX_PROG_JAR
+
+ AX_CHECK_CLASSPATH
+
+ # Check for Java UST agent common class first
+ AX_CHECK_CLASS(org.lttng.ust.agent.AbstractLttngAgent)
+ if test "x$ac_cv_class_org_lttng_ust_agent_AbstractLttngAgent" = "xno"; then
+ AC_MSG_ERROR([The UST Java agent common class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/lttng-ust-agent-common.jar"])
+ fi
+
+ if test "x$test_java_agent_jul" = "xyes"; then
+ # Check for JUL agent class
+ AX_CHECK_CLASS(org.lttng.ust.agent.jul.LttngLogHandler)
+ if test "x$ac_cv_class_org_lttng_ust_agent_jul_LttngLogHandler" = "xno"; then
+ AC_MSG_ERROR([The UST Java agent JUL class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/lttng-ust-agent-jul.jar"])
+ fi
+ fi
+
+ if test "x$test_java_agent_log4j" = "xyes"; then
+ # Check for Log4j agent class
+ AX_CHECK_CLASS(org.lttng.ust.agent.log4j.LttngLogAppender)
+ if test "x$ac_cv_class_org_lttng_ust_agent_log4j_LttngLogAppender" = "xno"; then
+ AC_MSG_ERROR([The UST Java agent Log4j class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/lttng-ust-agent-log4j.jar"])
+ fi
+
+ # Check for Log4j class
+ AX_CHECK_CLASS(org.apache.log4j.Logger)
+ if test "x$ac_cv_class_org_apache_log4j_Logger" = "xno"; then
+ AC_MSG_ERROR([The Log4j class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/log4j.jar"])
+ fi
+ fi
+fi
+
+# Python agent test
+UST_PYTHON_AGENT="lttngust"
+
+AC_ARG_ENABLE(test-python2-agent,
+ AS_HELP_STRING([--enable-test-python2-agent],
+ [enable tests for python2 agent. Python2 interpreter path can be overridden by setting the PYTHON2 environment variable. Default: Autodetect]
+ ),[:],[test_python2_agent_autodetect=yes]
+)
+
+AC_ARG_ENABLE(test-python3-agent,
+ AS_HELP_STRING([--enable-test-python3-agent],
+ [enable tests for python3 agent. Python3 interpreter path can be overridden by setting the PYTHON3 environment variable. Default: Autodetect]
+ ),[:],[test_python3_agent_autodetect=yes]
+)
+
+AC_ARG_ENABLE(test-python-agent-all,
+ AS_HELP_STRING([--enable-test-python-agent-all],
+ [enable test for all python{2/3} agent.]
+ ),
+)
+
+AS_IF([test ! -z "$enable_test_python_agent_all"], [
+ unset test_python2_agent_autodetect
+ unset test_python3_agent_autodetect
+])
+
+AS_IF([test "x$enable_test_python_agent_all" = "xyes"], [
+ enable_test_python2_agent=yes
+ enable_test_python3_agent=yes
+])
+
+AS_IF([test "x$enable_test_python_agent_all" = "xno"], [
+ enable_test_python2_agent=no
+ enable_test_python3_agent=no
+])
+
+
+AS_IF([test "x$enable_test_python2_agent" = "xyes" -o "x$test_python2_agent_autodetect" = "xyes" ], [
+ AS_IF([test -z "$PYTHON2"], [
+ PYTHON2=python2
+ ], [
+ AC_MSG_WARN([Using user-defined PYTHON2 ($PYTHON2) for lttng-ust python2 agent check])
+ ])
+
+ AC_PATH_PROG([PYTHON2_BIN],[$PYTHON2])
+ AS_IF([test -z "$PYTHON2_BIN"], [
+ AS_IF([test -z "$test_python2_agent_autodetect"],[
+ AC_MSG_ERROR([No python2 interpreter found. PYTHON2 can be set to override default interpreter path])
+ ])
+ ], [
+ AC_MSG_CHECKING([for python2 lttng-ust agent])
+ AS_IF([$PYTHON2_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [
+ PYTHON2_AGENT=$PYTHON2_BIN
+ AC_MSG_RESULT([yes])
+ RUN_PYTHON_AGENT_TEST=yes
+ ], [
+ AC_MSG_RESULT([no])
+ AS_IF([test -z "$test_python2_agent_autodetect"],[
+ AC_MSG_ERROR([No python2 agent found. The path to the agent can be specified by setting the PYTHONPATH environment variable.])
+ ])
+ ])
+
+ ])
+
+])
+
+AS_IF([test "x$enable_test_python3_agent" = "xyes" -o "x$test_python3_agent_autodetect" = "xyes" ], [
+ AS_IF([test -z "$PYTHON3"], [
+ PYTHON3=python3
+ ], [
+ AC_MSG_WARN([Using user-defined PYTHON3 ($PYTHON3) for lttng-ust python3 agent check])
+ ])
+
+ AC_PATH_PROG([PYTHON3_BIN],[$PYTHON3])
+ AS_IF([test -z "$PYTHON3_BIN"], [
+ AS_IF([test -z "$test_python3_agent_autodetect"],[
+ AC_MSG_ERROR([No python3 interpreter found. PYTHON3 can be set to override default interpreter path])
+ ])
+ ], [
+ AC_MSG_CHECKING([for python3 lttng-ust agent])
+ AS_IF([$PYTHON3_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [
+ PYTHON3_AGENT=$PYTHON3_BIN
+ AC_MSG_RESULT([yes])
+ RUN_PYTHON_AGENT_TEST=yes
+ ], [
+ AC_MSG_RESULT([no])
+ AS_IF([test -z "$test_python3_agent_autodetect"],[
+ AC_MSG_ERROR([No python3 agent found. The path to the agent can be specified by setting the PYTHONPATH environment variable.])
+ ])
+ ])
+
+ ])
+])
+
+AC_SUBST([RUN_PYTHON_AGENT_TEST])
+AC_SUBST([PYTHON2_AGENT])
+AC_SUBST([PYTHON3_AGENT])
+