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