2 dnl enable automatically if dtrace and sdt.h are available
3 AC_DEFUN([CM_SYSTEMTAP],[
4 AC_CHECK_PROGS(DTRACE, dtrace)
5 dnl require stap for now, too, as there are compatibility issues with
6 dnl dtrace under FreeBSD
7 AC_CHECK_PROGS(STAP, stap)
8 AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'], [SDT_H_FOUND='no'])
9 AS_IF([test "x$STAP" != x && test "x$DTRACE" != x && test $SDT_H_FOUND = yes],
10 AC_CACHE_CHECK([for sys/sdt.h usability],
11 [cm_cv_sdt_h_usable], [
14 void foo(void) { STAP_PROBE(foo, foo); }
16 [cm_cv_sdt_h_usable=yes],
17 [cm_cv_sdt_h_usable=no])]))
18 AS_IF([test x"$cm_cv_sdt_h_usable" = xyes],
19 [ENABLE_SYSTEMTAP=yes], [ENABLE_SYSTEMTAP=no])
21 dnl support explicit --disable-systemtap or --enable-systemtap
22 AC_MSG_CHECKING([whether to include systemtap tracing support])
23 AC_ARG_ENABLE([systemtap],
24 [AS_HELP_STRING([--enable-systemtap],
25 [Enable inclusion of systemtap trace support])],
26 [ENABLE_SYSTEMTAP="${enableval}"])
27 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
28 AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
30 dnl maybe somebody forced --enable-systemtap w/o dtrace or sdt.h
31 if test "x${ENABLE_SYSTEMTAP}" = xyes
33 AS_IF([test "x${DTRACE}" = x], [AC_MSG_ERROR([dtrace not found])])
34 AS_IF([test $SDT_H_FOUND = no],
35 [ AC_MSG_ERROR([systemtap support needs sys/sdt.h header]) ])
36 AS_IF([test x"$cm_cv_sdt_h_usable" = xno],
37 [ AC_MSG_ERROR([sys/sdt.h header is not usable (clang?)]) ])
38 AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using sdt probes.])