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