]> arthur.barton.de Git - netdata.git/blob - m4/jemalloc.m4
dns_query_time plugin: added
[netdata.git] / m4 / jemalloc.m4
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
8 dnl
9 dnl     http://www.apache.org/licenses/LICENSE-2.0
10 dnl
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.
16
17 dnl
18 dnl jemalloc.m4: Trafficserver's jemalloc autoconf macros
19 dnl modified to skip other TS_ helpers
20 dnl
21
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=""]])],
25   [
26   jemalloc_prefix="$withval"
27   ],[
28   if test "`uname -s`" = "Darwin"; then
29     jemalloc_prefix="je_"
30   else
31     jemalloc_prefix=""
32   fi
33   ]
34 )
35 AC_DEFINE_UNQUOTED([prefix_jemalloc], [${jemalloc_prefix}], [jemalloc prefix])
36
37 enable_jemalloc=no
38 AC_ARG_WITH([jemalloc], [AS_HELP_STRING([--with-jemalloc=DIR], [use a specific jemalloc library])],
39 [
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])
43     fi
44     enable_jemalloc=yes
45     jemalloc_base_dir="$withval"
46     case "$withval" in
47       yes)
48         jemalloc_base_dir="/usr"
49         AC_MSG_CHECKING(checking for jemalloc includes standard directories)
50         ;;
51       *":"*)
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)
55         ;;
56       *)
57         jemalloc_include="$withval/include"
58         jemalloc_ldflags="$withval/lib"
59         AC_MSG_CHECKING(checking for jemalloc includes in $withval)
60         ;;
61     esac
62   fi
63 ])
64
65 has_jemalloc=0
66 if test "$enable_jemalloc" != "no"; then
67   jemalloc_have_headers=0
68   jemalloc_have_libs=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}"
73   fi
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])
78   fi
79   if test "$jemalloc_have_headers" != "0"; then
80     has_jemalloc=1
81     LIBS="${LIBS} -ljemalloc"
82     AC_DEFINE(has_jemalloc, [1], [Link/compile against jemalloc])
83   else
84     AC_MSG_ERROR([Couldn't find a jemalloc installation])
85   fi
86 fi
87 AC_SUBST(has_jemalloc)
88 ])