+# optional linux/perf_event.h
+AC_CHECK_HEADERS([linux/perf_event.h], [have_perf_event=yes], [])
+
+# Perf event counters are supported on all architectures supported by
+# perf, using the read system call as fallback.
+AM_CONDITIONAL([HAVE_PERF_EVENT], [test "x$have_perf_event" = "xyes"])
+
+AS_IF([test "x$have_perf_event" = "xyes"], [
+ AC_DEFINE([LTTNG_UST_HAVE_PERF_EVENT], [1])
+])
+
+AC_MSG_CHECKING([host system alignment requirements])
+AS_CASE([$host_cpu],
+ [i[[3456]]86], [],
+ [x86_64], [],
+ [amd64], [],
+ [powerpc], [],
+ [ppc64], [],
+ [ppc64le], [],
+ [powerpc64], [],
+ [powerpc64le], [],
+ [s390], [NO_UNALIGNED_ACCESS=1],
+ [s390x], [NO_UNALIGNED_ACCESS=1],
+ [arm*], [NO_UNALIGNED_ACCESS=1],
+ [aarch64*], [NO_UNALIGNED_ACCESS=1],
+ [mips*], [NO_UNALIGNED_ACCESS=1],
+ [tile*], [NO_UNALIGNED_ACCESS=1],
+ [
+ UNSUPPORTED_ARCH=1
+ NO_UNALIGNED_ACCESS=1
+ ])
+AC_MSG_RESULT([$host_cpu])
+
+AS_IF([test "x$NO_UNALIGNED_ACCESS" = "x"], [
+ AC_DEFINE([LTTNG_UST_HAVE_EFFICIENT_UNALIGNED_ACCESS], [1])
+])
+
+# Check for JNI header files if requested
+AC_ARG_ENABLE([jni-interface], [
+ AS_HELP_STRING([--enable-jni-interface], [build JNI interface between C and Java. Needs Java include files [default=no]])
+], [
+ jni_interface=$enableval
+], [
+ jni_interface=no
+])
+
+AM_CONDITIONAL([BUILD_JNI_INTERFACE], [test "x$jni_interface" = "xyes"])
+
+
+AC_ARG_ENABLE([java-agent-jul], [
+ AS_HELP_STRING([--enable-java-agent-jul], [build the LTTng UST Java agent with JUL support [default=no]])
+], [
+ java_agent_jul=$enableval
+], [
+ java_agent_jul=no
+])
+
+AC_ARG_ENABLE([java-agent-log4j], [
+ AS_HELP_STRING([--enable-java-agent-log4j], [build the LTTng UST Java agent with Log4j support [default=no]])
+], [
+ java_agent_log4j=$enableval
+], [
+ java_agent_log4j=no
+])
+
+AC_ARG_ENABLE([java-agent-all], [
+ AS_HELP_STRING([--enable-java-agent-all], [build the LTTng UST Java agent with all supported backends [default=no]])
+], [
+ java_agent_jul=$enableval
+ java_agent_log4j=$enableval
+], [:])
+
+AM_CONDITIONAL([BUILD_JAVA_AGENT], [test "x$java_agent_jul" = "xyes" || test "x$java_agent_log4j" = "xyes"])
+AM_CONDITIONAL([BUILD_JAVA_AGENT_WITH_JUL], [test "x$java_agent_jul" = "xyes"])
+AM_CONDITIONAL([BUILD_JAVA_AGENT_WITH_LOG4J], [test "x$java_agent_log4j" = "xyes"])
+
+AS_IF([test "x$jni_interface" = "xyes" || test "x$java_agent_jul" = "xyes" || test "x$java_agent_log4j" = "xyes"], [
+ AX_JAVA_OPTIONS
+ AX_PROG_JAVAC
+ AX_PROG_JAVA
+ AX_PROG_JAR