1 dnl -------------------------------------------------------- -*- autoconf -*-
2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements. See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License. You may obtain a copy of the License at
9 dnl http://www.apache.org/licenses/LICENSE-2.0
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
18 dnl jemalloc.m4: Trafficserver's jemalloc autoconf macros
19 dnl modified to skip other TS_ helpers
22 AC_DEFUN([TS_CHECK_JEMALLOC], [
23 AC_ARG_WITH([jemalloc-prefix],
24 [AS_HELP_STRING([--with-jemalloc-prefix=PREFIX],[Specify the jemalloc prefix [default=""]])],
26 jemalloc_prefix="$withval"
28 if test "`uname -s`" = "Darwin"; then
35 AC_DEFINE_UNQUOTED([prefix_jemalloc], [${jemalloc_prefix}], [jemalloc prefix])
38 AC_ARG_WITH([jemalloc], [AS_HELP_STRING([--with-jemalloc=DIR], [use a specific jemalloc library])],
40 if test "$withval" != "no"; then
41 if test "x${enable_tcmalloc}" = "xyes"; then
42 AC_MSG_ERROR([Cannot compile with both jemalloc and tcmalloc])
45 jemalloc_base_dir="$withval"
48 jemalloc_base_dir="/usr"
49 AC_MSG_CHECKING(checking for jemalloc includes standard directories)
52 jemalloc_include="`echo $withval |sed -e 's/:.*$//'`"
53 jemalloc_ldflags="`echo $withval |sed -e 's/^.*://'`"
54 AC_MSG_CHECKING(checking for jemalloc includes in $jemalloc_include libs in $jemalloc_ldflags)
57 jemalloc_include="$withval/include"
58 jemalloc_ldflags="$withval/lib"
59 AC_MSG_CHECKING(checking for jemalloc includes in $withval)
66 if test "$enable_jemalloc" != "no"; then
67 jemalloc_have_headers=0
69 if test "$jemalloc_base_dir" != "/usr"; then
70 CFLAGS="${CFLAGS} -I${jemalloc_include}"
71 LDFLAGS="${LDFLAGS} -L${jemalloc_ldflags}"
72 LIBTOOL_LINK_FLAGS="${LIBTOOL_LINK_FLAGS} -R${jemalloc_ldflags}"
74 func="${jemalloc_prefix}malloc_stats_print"
75 AC_CHECK_LIB(jemalloc, ${func}, [jemalloc_have_libs=1])
76 if test "$jemalloc_have_libs" != "0"; then
77 AC_CHECK_HEADERS([jemalloc/jemalloc.h], [jemalloc_have_headers=1])
79 if test "$jemalloc_have_headers" != "0"; then
81 LIBS="${LIBS} -ljemalloc"
82 AC_DEFINE(has_jemalloc, [1], [Link/compile against jemalloc])
84 AC_MSG_ERROR([Couldn't find a jemalloc installation])
87 AC_SUBST(has_jemalloc)