1dnl -------------------------------------------------------- -*- autoconf -*-
2dnl Licensed to the Apache Software Foundation (ASF) under one or more
3dnl contributor license agreements.  See the NOTICE file distributed with
4dnl this work for additional information regarding copyright ownership.
5dnl The ASF licenses this file to You under the Apache License, Version 2.0
6dnl (the "License"); you may not use this file except in compliance with
7dnl the License.  You may obtain a copy of the License at
8dnl
9dnl     http://www.apache.org/licenses/LICENSE-2.0
10dnl
11dnl Unless required by applicable law or agreed to in writing, software
12dnl distributed under the License is distributed on an "AS IS" BASIS,
13dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14dnl See the License for the specific language governing permissions and
15dnl limitations under the License.
16
17dnl
18dnl tcmalloc.m4: Trafficserver's tcmalloc autoconf macros
19dnl
20
21dnl This is kinda fugly, but need a way to both specify a directory and which
22dnl of the many tcmalloc libraries to use ...
23AC_DEFUN([TS_CHECK_TCMALLOC], [
24AC_ARG_WITH([tcmalloc-lib],
25  [AS_HELP_STRING([--with-tcmalloc-lib],[specify the tcmalloc library to use [default=tcmalloc]])],
26  [
27  with_tcmalloc_lib="$withval"
28  ],[
29  with_tcmalloc_lib="tcmalloc"
30  ]
31)
32
33has_tcmalloc=0
34AC_ARG_WITH([tcmalloc], [AC_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc library])],
35[
36  if test "$withval" != "no"; then
37    if test "x${enable_jemalloc}" = "xyes"; then
38      AC_MSG_ERROR([Cannot compile with both tcmalloc and jemalloc])
39    fi
40    tcmalloc_have_libs=0
41    if test "x$withval" != "xyes" && test "x$withval" != "x"; then
42      tcmalloc_ldflags="$withval/lib"
43      TS_ADDTO(LDFLAGS, [-L${tcmalloc_ldflags}])
44      TS_ADDTO_RPATH(${tcmalloc_ldflags})
45    fi
46    AC_SEARCH_LIBS([tc_cfree], ${with_tcmalloc_lib}, [tcmalloc_have_lib=1])
47    if test "$tcmalloc_have_lib" != "0"; then
48      has_tcmalloc=1
49    fi
50  fi
51])
52AC_SUBST(has_tcmalloc)
53])
54