1 dnl Copyright (C) 2009 Sun Microsystems
2 dnl This file is free software; Sun Microsystems
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
6 dnl ---------------------------------------------------------------------------
7 dnl Macro: PANDORA_ENABLE_DTRACE
8 dnl ---------------------------------------------------------------------------
9 AC_DEFUN([PANDORA_ENABLE_DTRACE],[
10 AC_ARG_ENABLE([dtrace],
11 [AS_HELP_STRING([--disable-dtrace],
12 [Build with support for the DTRACE. @<:@default=on@:>@])],
13 [ac_cv_enable_dtrace="$enableval"],
14 [ac_cv_enable_dtrace="yes"])
16 AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[
17 AC_CHECK_PROGS([DTRACE], [dtrace])
18 AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[
20 AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[
21 cat >conftest.d <<_ACEOF
26 $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero
27 AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes],
28 [ac_cv_dtrace_works=no])
29 rm -f conftest.h conftest.d
31 AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[
32 AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support])
34 AC_CACHE_CHECK([if dtrace should instrument object files],
35 [ac_cv_dtrace_needs_objects],[
36 dnl DTrace on MacOSX does not use -G option
37 cat >conftest.d <<_ACEOF
42 $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero
43 AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes],
44 [ac_cv_dtrace_needs_objects=no])
45 rm -f conftest.d.o conftest.d
47 AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX
51 AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"])
52 AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS],
53 [test "x$ac_cv_dtrace_needs_objects" = "xyes"])
56 dnl ---------------------------------------------------------------------------
57 dnl End Macro: PANDORA_ENABLE_DTRACE
58 dnl ---------------------------------------------------------------------------