Updating for 1.0.2 release
[awesomized/libmemcached] / m4 / pandora_have_better_malloc.m4
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
6 AC_DEFUN([PANDORA_HAVE_BETTER_MALLOC],[
7 AC_REQUIRE([AC_LIB_PREFIX])
8
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
23 AC_ARG_ENABLE([tcmalloc],
24 [AS_HELP_STRING([--enable-tcmalloc],
25 [Enable linking with tcmalloc @<:@default=off@:>@])],
26 [ac_enable_tcmalloc="$enableval"],
27 [ac_enable_tcmalloc="no"])
28
29 AC_ARG_ENABLE([mtmalloc],
30 [AS_HELP_STRING([--disable-mtmalloc],
31 [Enable linking with mtmalloc @<:@default=on@:>@])],
32 [ac_enable_mtmalloc="$enableval"],
33 [ac_enable_mtmalloc="yes"])
34
35 save_LIBS="${LIBS}"
36 LIBS=
37 AS_IF([test "x$ac_enable_umem" = "xyes"],[
38 AC_CHECK_LIB(umem,malloc,[],[])
39 ],[
40 case "$target_os" in
41 *linux*)
42 AS_IF([test "x$ac_enable_tcmalloc" != "xno"],[
43 AC_CHECK_LIB(tcmalloc-minimal,malloc,[],[])
44 AS_IF([test "x$ac_cv_lib_tcmalloc_minimal_malloc" != "xyes"],[
45 AC_CHECK_LIB(tcmalloc,malloc,[],[])
46 ])
47 ])
48 ;;
49 *solaris*)
50 AS_IF([test "x$ac_enable_mtmalloc" != "xno"],[
51 AC_CHECK_LIB(mtmalloc,malloc,[],[])
52 ])
53 ;;
54 esac
55 ])
56 BETTER_MALLOC_LIBS="${LIBS}"
57 LIBS="${save_LIBS}"
58 AC_SUBST([BETTER_MALLOC_LIBS])
59
60 ])
61
62 AC_DEFUN([PANDORA_USE_BETTER_MALLOC],[
63 AC_REQUIRE([PANDORA_HAVE_BETTER_MALLOC])
64 LIBS="${LIBS} ${BETTER_MALLOC_LIBS}"
65 ])
66