pandora_have_better_malloc.m4 1.8 KB

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