pandora_have_better_malloc.m4 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. AC_DEFUN([PANDORA_HAVE_BETTER_MALLOC],[
  6. AC_REQUIRE([AC_FUNC_MALLOC])
  7. AC_REQUIRE([AC_FUNC_REALLOC])
  8. AC_REQUIRE([AC_LIB_PREFIX])
  9. AC_ARG_ENABLE([umem],
  10. [AS_HELP_STRING([--enable-umem],
  11. [Enable linking with libumem @<:@default=off@:>@])],
  12. [ac_enable_umem="$enableval"],[
  13. case "$target_os" in
  14. *solaris*)
  15. ac_enable_umem="yes"
  16. ;;
  17. *)
  18. ac_enable_umem="no"
  19. ;;
  20. esac
  21. ])
  22. AC_ARG_ENABLE([tcmalloc],
  23. [AS_HELP_STRING([--enable-tcmalloc],
  24. [Enable linking with tcmalloc @<:@default=off@:>@])],
  25. [ac_enable_tcmalloc="$enableval"],
  26. [ac_enable_tcmalloc="no"])
  27. AC_ARG_ENABLE([mtmalloc],
  28. [AS_HELP_STRING([--disable-mtmalloc],
  29. [Enable linking with mtmalloc @<:@default=on@:>@])],
  30. [ac_enable_mtmalloc="$enableval"],
  31. [ac_enable_mtmalloc="yes"])
  32. save_LIBS="${LIBS}"
  33. LIBS=
  34. AS_IF([test "x$ac_enable_umem" = "xyes"],[
  35. AC_CHECK_LIB(umem,malloc,[],[])
  36. ],[
  37. case "$target_os" in
  38. *linux*)
  39. AS_IF([test "x$ac_enable_tcmalloc" != "xno"],[
  40. AC_CHECK_LIB(tcmalloc-minimal,malloc,[],[])
  41. AS_IF([test "x$ac_cv_lib_tcmalloc_minimal_malloc" != "xyes"],[
  42. AC_CHECK_LIB(tcmalloc,malloc,[],[])
  43. ])
  44. ])
  45. ;;
  46. *solaris*)
  47. AS_IF([test "x$ac_enable_mtmalloc" != "xno"],[
  48. AC_CHECK_LIB(mtmalloc,malloc,[],[])
  49. ])
  50. ;;
  51. esac
  52. ])
  53. BETTER_MALLOC_LIBS="${LIBS}"
  54. LIBS="${save_LIBS}"
  55. AC_SUBST([BETTER_MALLOC_LIBS])
  56. ])
  57. AC_DEFUN([PANDORA_USE_BETTER_MALLOC],[
  58. AC_REQUIRE([PANDORA_HAVE_BETTER_MALLOC])
  59. LIBS="${LIBS} ${BETTER_MALLOC_LIBS}"
  60. ])