pandora_enable_dtrace.m4 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. dnl Copyright (C) 2009 Sun Microsystems, Inc.
  2. dnl This file is free software; Sun Microsystems, Inc.
  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([--enable-dtrace],
  11. [Build with support for the DTRACE. @<:@default=no@:>@])],
  12. [ac_cv_enable_dtrace="$enableval"],
  13. [ac_cv_enable_dtrace="no"])
  14. AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[
  15. AC_CHECK_PROGS([DTRACE], [dtrace])
  16. AC_CHECK_HEADERS(sys/sdt.h)
  17. AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace" -a "x${ac_cv_header_sys_sdt_h}" = "xyes"],[
  18. AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[
  19. cat >conftest.d <<_ACEOF
  20. provider Example {
  21. probe increment(int);
  22. };
  23. _ACEOF
  24. $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero
  25. AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes],
  26. [ac_cv_dtrace_works=no])
  27. rm -f conftest.h conftest.d
  28. ])
  29. AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[
  30. AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support])
  31. ])
  32. AC_CACHE_CHECK([if dtrace should instrument object files],
  33. [ac_cv_dtrace_needs_objects],[
  34. dnl DTrace on MacOSX does not use -G option
  35. cat >conftest.d <<_ACEOF
  36. provider Example {
  37. probe increment(int);
  38. };
  39. _ACEOF
  40. $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero
  41. AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes],
  42. [ac_cv_dtrace_needs_objects=no])
  43. rm -f conftest.d.o conftest.d
  44. ])
  45. AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX
  46. ac_cv_have_dtrace=yes
  47. ])])
  48. AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"])
  49. AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS],
  50. [test "x$ac_cv_dtrace_needs_objects" = "xyes"])
  51. ])
  52. dnl ---------------------------------------------------------------------------
  53. dnl End Macro: PANDORA_ENABLE_DTRACE
  54. dnl ---------------------------------------------------------------------------