dtrace.m4 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.
  5. dnl ---------------------------------------------------------------------------
  6. dnl Macro: PANDORA_ENABLE_DTRACE
  7. dnl ---------------------------------------------------------------------------
  8. AC_DEFUN([PANDORA_ENABLE_DTRACE],[
  9. AC_ARG_ENABLE([dtrace],
  10. [AS_HELP_STRING([--disable-dtrace],
  11. [enable DTrace USDT probes. @<:@default=yes@:>@])],
  12. [ac_cv_enable_dtrace="$enableval"],
  13. [ac_cv_enable_dtrace="yes"])
  14. AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[
  15. AC_CHECK_PROGS([DTRACE], [dtrace])
  16. AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[
  17. AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[
  18. cat >conftest.d <<_ACEOF
  19. provider Example {
  20. probe increment(int);
  21. };
  22. _ACEOF
  23. $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero
  24. AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes],
  25. [ac_cv_dtrace_works=no])
  26. rm -f conftest.h conftest.d
  27. ])
  28. AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[
  29. AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support])
  30. ])
  31. AC_CACHE_CHECK([if dtrace should instrument object files],
  32. [ac_cv_dtrace_needs_objects],[
  33. dnl DTrace on MacOSX does not use -G option
  34. cat >conftest.d <<_ACEOF
  35. provider Example {
  36. probe increment(int);
  37. };
  38. _ACEOF
  39. $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero
  40. AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes],
  41. [ac_cv_dtrace_needs_objects=no])
  42. rm -f conftest.d.o conftest.d
  43. ])
  44. AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX
  45. ac_cv_have_dtrace=yes
  46. ])])
  47. AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"])
  48. AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS],
  49. [test "x$ac_cv_dtrace_needs_objects" = "xyes"])
  50. ])
  51. dnl ---------------------------------------------------------------------------
  52. dnl End Macro: PANDORA_ENABLE_DTRACE
  53. dnl ---------------------------------------------------------------------------