2007-03-22 03:00:33 +00:00
|
|
|
## Process this file with autoconf to produce configure.
|
2007-07-18 18:30:50 +00:00
|
|
|
## In general, the safest way to proceed is to run ./autogen.sh
|
2007-03-22 03:00:33 +00:00
|
|
|
|
|
|
|
# make sure we're interpreted by some minimal autoconf
|
2013-08-29 15:51:48 +00:00
|
|
|
AC_PREREQ([2.59])
|
2007-03-22 03:00:33 +00:00
|
|
|
|
2014-06-21 22:45:44 +00:00
|
|
|
AC_INIT([gperftools],[2.2.1],[google-perftools@googlegroups.com])
|
2011-02-05 00:19:37 +00:00
|
|
|
# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
|
|
|
|
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
2014-06-21 22:45:44 +00:00
|
|
|
TCMALLOC_SO_VERSION=6:2:2
|
|
|
|
PROFILER_SO_VERSION=4:1:4
|
2010-11-18 01:07:25 +00:00
|
|
|
|
|
|
|
AC_SUBST(TCMALLOC_SO_VERSION)
|
|
|
|
AC_SUBST(PROFILER_SO_VERSION)
|
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# The argument here is just something that should be in the current directory
|
|
|
|
# (for sanity checking)
|
|
|
|
AC_CONFIG_SRCDIR(README)
|
2010-11-18 01:07:25 +00:00
|
|
|
AC_CONFIG_MACRO_DIR([m4])
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_CANONICAL_HOST
|
2007-07-18 18:30:50 +00:00
|
|
|
AM_INIT_AUTOMAKE([dist-zip])
|
2012-11-04 17:21:00 +00:00
|
|
|
AC_CONFIG_HEADERS([src/config.h])
|
2007-03-22 03:00:33 +00:00
|
|
|
|
2013-12-06 20:23:48 +00:00
|
|
|
AM_MAINTAINER_MODE()
|
|
|
|
|
2009-09-11 18:42:32 +00:00
|
|
|
# Export the version information (for tc_version and friends)
|
|
|
|
TC_VERSION_MAJOR=`expr "$PACKAGE_VERSION" : '\([[0-9]]*\)'`
|
2011-08-11 22:06:22 +00:00
|
|
|
TC_VERSION_MINOR=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.\([[0-9]]*\)'`
|
|
|
|
TC_VERSION_PATCH=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.[[0-9]]*\(.*\)$'`
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_SUBST(TC_VERSION_MAJOR)
|
|
|
|
AC_SUBST(TC_VERSION_MINOR)
|
|
|
|
AC_SUBST(TC_VERSION_PATCH)
|
|
|
|
AC_SUBST(PACKAGE_STRING)
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# The user can choose not to compile in the heap-profiler, the
|
|
|
|
# heap-checker, or the cpu-profiler. There's also the possibility
|
|
|
|
# for a 'fully minimal' compile, which leaves out the stacktrace
|
|
|
|
# code as well. By default, we include all of these that the
|
|
|
|
# target system supports.
|
|
|
|
default_enable_cpu_profiler=yes
|
|
|
|
default_enable_heap_profiler=yes
|
|
|
|
default_enable_heap_checker=yes
|
2009-09-11 18:42:32 +00:00
|
|
|
default_enable_debugalloc=yes
|
2009-03-11 20:50:03 +00:00
|
|
|
default_enable_minimal=no
|
|
|
|
need_nanosleep=yes # Used later, to decide if to run ACX_NANOSLEEP
|
|
|
|
case "$host" in
|
2009-09-11 18:42:32 +00:00
|
|
|
*-mingw*) default_enable_minimal=yes; default_enable_debugalloc=no;
|
|
|
|
need_nanosleep=no;;
|
2009-04-18 00:02:25 +00:00
|
|
|
*-cygwin*) default_enable_heap_checker=no; default_enable_cpu_profiler=no;;
|
2009-03-11 20:50:03 +00:00
|
|
|
*-freebsd*) default_enable_heap_checker=no;;
|
|
|
|
*-darwin*) default_enable_heap_checker=no;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
AC_ARG_ENABLE([cpu-profiler],
|
|
|
|
[AS_HELP_STRING([--disable-cpu-profiler],
|
|
|
|
[do not build the cpu profiler])],
|
|
|
|
[],
|
|
|
|
[enable_cpu_profiler="$default_enable_cpu_profiler"])
|
|
|
|
AC_ARG_ENABLE([heap-profiler],
|
|
|
|
[AS_HELP_STRING([--disable-heap-profiler],
|
|
|
|
[do not build the heap profiler])],
|
|
|
|
[],
|
|
|
|
[enable_heap_profiler="$default_enable_heap_profiler"])
|
|
|
|
AC_ARG_ENABLE([heap-checker],
|
|
|
|
[AS_HELP_STRING([--disable-heap-checker],
|
|
|
|
[do not build the heap checker])],
|
|
|
|
[],
|
|
|
|
[enable_heap_checker="$default_enable_heap_checker"])
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_ARG_ENABLE([debugalloc],
|
|
|
|
[AS_HELP_STRING([--disable-debugalloc],
|
|
|
|
[do not build versions of libs with debugalloc])],
|
|
|
|
[],
|
|
|
|
[enable_debugalloc="$default_enable_debugalloc"])
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_ARG_ENABLE([minimal],
|
|
|
|
[AS_HELP_STRING([--enable-minimal],
|
2009-09-11 18:42:32 +00:00
|
|
|
[build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)])],
|
2009-03-11 20:50:03 +00:00
|
|
|
[],
|
|
|
|
[enable_minimal="$default_enable_minimal"])
|
|
|
|
if test "$enable_minimal" = yes; then
|
|
|
|
enable_cpu_profiler=no
|
|
|
|
enable_heap_profiler=no
|
|
|
|
enable_heap_checker=no
|
|
|
|
fi
|
2014-04-12 19:38:19 +00:00
|
|
|
AC_ARG_ENABLE([stacktrace-via-backtrace],
|
|
|
|
[AS_HELP_STRING([--enable-stacktrace-via-backtrace],
|
|
|
|
[enable use of backtrace() for stacktrace capturing (may deadlock)])],
|
|
|
|
[enable_backtrace=yes],
|
|
|
|
[])
|
2009-03-11 20:50:03 +00:00
|
|
|
|
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# Checks for programs.
|
2011-10-18 20:57:45 +00:00
|
|
|
AC_PROG_CXX
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_PROG_CC
|
|
|
|
AC_PROG_CPP
|
2007-08-17 20:56:15 +00:00
|
|
|
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
|
2009-04-18 00:02:25 +00:00
|
|
|
AM_PROG_CC_C_O # shrug: autogen.sh suddenly needs this for some reason
|
|
|
|
|
2009-06-10 02:04:26 +00:00
|
|
|
# Check if we have an objcopy installed that supports -W
|
|
|
|
AC_CHECK_TOOL([OBJCOPY], [objcopy], [])
|
2011-05-19 21:37:12 +00:00
|
|
|
AS_IF([test -n "$OBJCOPY"], [dnl
|
|
|
|
AC_CACHE_CHECK([if $OBJCOPY supports -W], gpt_cv_objcopy_weaken, [dnl
|
2012-11-04 17:21:00 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([void foo() {} int main() {return 0;}])], [dnl
|
2011-05-19 21:37:12 +00:00
|
|
|
AS_IF(["$OBJCOPY" -W foo conftest$ac_exeext /dev/null],
|
|
|
|
[gpt_cv_objcopy_weaken=yes], [gpt_cv_objcopy_weaken=no])],
|
|
|
|
[gpt_cv_objcopy_weaken=no])])],
|
|
|
|
[gpt_cv_objcopy_weaken=no])
|
|
|
|
AM_CONDITIONAL(HAVE_OBJCOPY_WEAKEN, test $gpt_cv_objcopy_weaken = yes)
|
2009-06-10 02:04:26 +00:00
|
|
|
|
2013-11-16 23:05:45 +00:00
|
|
|
AC_PROG_LIBTOOL
|
2007-03-22 03:00:33 +00:00
|
|
|
|
|
|
|
AC_C_INLINE
|
|
|
|
AX_C___ATTRIBUTE__
|
|
|
|
|
|
|
|
# Check whether some low-level functions/files are available
|
|
|
|
AC_HEADER_STDC
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# TODO(csilvers): we could remove a lot when WITH_CPU_PROFILER etc is "no".
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_CHECK_TYPES([__int64]) # defined in some windows platforms
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_CHECK_TYPES([struct mallinfo],,, [#include <malloc.h>])
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_CHECK_TYPES([Elf32_Versym],,, [#include <elf.h>]) # for vdso_support.h
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_CHECK_FUNCS(sbrk) # for tcmalloc to get memory
|
2007-07-18 18:30:50 +00:00
|
|
|
AC_CHECK_FUNCS(geteuid) # for turning off services when run as root
|
2013-03-10 20:17:21 +00:00
|
|
|
AC_CHECK_FUNCS(fork) # for the pthread_atfork setup
|
2009-06-10 02:04:26 +00:00
|
|
|
AC_CHECK_HEADERS(features.h) # for vdso_support.h
|
2007-07-18 18:30:50 +00:00
|
|
|
AC_CHECK_HEADERS(malloc.h) # some systems define stuff there, others not
|
2011-03-02 08:10:05 +00:00
|
|
|
AC_CHECK_HEADERS(sys/malloc.h) # where some versions of OS X put malloc.h
|
|
|
|
AC_CHECK_HEADERS(malloc/malloc.h) # another place OS X puts malloc.h (?)
|
2007-07-18 18:30:50 +00:00
|
|
|
AC_CHECK_HEADERS(glob.h) # for heap-profile-table (cleaning up profiles)
|
2007-03-22 03:28:56 +00:00
|
|
|
AC_CHECK_HEADERS(execinfo.h) # for stacktrace? and heapchecker_unittest
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_CHECK_HEADERS(libunwind.h) # for stacktrace
|
|
|
|
AC_CHECK_HEADERS(unwind.h) # for stacktrace
|
2009-06-10 02:04:26 +00:00
|
|
|
AC_CHECK_HEADERS(sched.h) # for being nice in our spinlock code
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_CHECK_HEADERS(conflict-signal.h) # defined on some windows platforms?
|
2007-08-17 20:56:15 +00:00
|
|
|
AC_CHECK_HEADERS(sys/prctl.h) # for thread_lister (needed by leak-checker)
|
|
|
|
AC_CHECK_HEADERS(linux/ptrace.h)# also needed by leak-checker
|
|
|
|
AC_CHECK_HEADERS(sys/syscall.h)
|
2009-03-11 20:50:03 +00:00
|
|
|
AC_CHECK_HEADERS(sys/socket.h) # optional; for forking out to symbolizer
|
|
|
|
AC_CHECK_HEADERS(sys/wait.h) # optional; for forking out to symbolizer
|
2009-09-11 18:42:32 +00:00
|
|
|
AC_CHECK_HEADERS(poll.h) # optional; for forking out to symbolizer
|
2007-08-17 20:56:15 +00:00
|
|
|
AC_CHECK_HEADERS(fcntl.h) # for tcmalloc_unittest
|
2007-03-22 03:28:56 +00:00
|
|
|
AC_CHECK_HEADERS(grp.h) # for heapchecker_unittest
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_CHECK_HEADERS(pwd.h) # for heapchecker_unittest
|
2008-06-14 02:30:53 +00:00
|
|
|
AC_CHECK_HEADERS(sys/resource.h) # for memalign_unittest.cc
|
2010-03-23 20:39:55 +00:00
|
|
|
AC_CHECK_HEADERS(valgrind.h) # we have a local copy if this isn't found
|
2011-05-19 21:37:12 +00:00
|
|
|
AC_CHECK_HEADERS(sys/cdefs.h) # Where glibc defines __THROW
|
|
|
|
AC_CHECK_HEADERS(features.h) # Where __GLIBC__ is defined
|
2010-03-23 20:39:55 +00:00
|
|
|
# We also need <ucontext.h>/<sys/ucontext.h>, but we get those from
|
|
|
|
# AC_PC_FROM_UCONTEXT, below.
|
|
|
|
|
2007-07-18 18:30:50 +00:00
|
|
|
# We override a lot of memory allocation routines, not all of which are
|
|
|
|
# standard. For those the system doesn't declare, we'll declare ourselves.
|
|
|
|
AC_CHECK_DECLS([cfree,
|
|
|
|
posix_memalign,
|
|
|
|
memalign,
|
|
|
|
valloc,
|
|
|
|
pvalloc],,,
|
|
|
|
[#define _XOPEN_SOURCE 600
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>])
|
|
|
|
|
2009-06-10 02:04:26 +00:00
|
|
|
if test "$ac_cv_type_struct_mallinfo" = yes; then
|
2012-02-04 00:07:36 +00:00
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo, 1) # gperftools/tcmalloc.h needs this
|
2009-06-10 02:04:26 +00:00
|
|
|
else
|
|
|
|
AC_SUBST(ac_cv_have_struct_mallinfo, 0)
|
|
|
|
fi
|
|
|
|
|
2008-06-14 02:30:53 +00:00
|
|
|
# We need to check for mmap. cygwin supports mmap, but the autoconf
|
|
|
|
# test doesn't work on cygwin:
|
|
|
|
# http://www.cygwin.com/ml/cygwin/2002-04/msg00412.html
|
|
|
|
# This workaround comes from
|
|
|
|
# http://cygwin.com/ml/cygwin/2004-11/msg00138.html
|
|
|
|
case "$host" in
|
2013-03-11 19:15:46 +00:00
|
|
|
*-*-mingw*)
|
|
|
|
dnl mingw doesn't have mmap, not worth
|
|
|
|
dnl checking. Especially given that mingw can be a
|
|
|
|
dnl cross-compiler
|
|
|
|
;;
|
2011-05-19 21:37:12 +00:00
|
|
|
*-*-cygwin*)
|
|
|
|
ac_cv_func_mmap_fixed_mapped=yes
|
2008-06-14 02:30:53 +00:00
|
|
|
AC_DEFINE(HAVE_MMAP, 1,
|
|
|
|
[Define to 1 if you have a working `mmap' system call.])
|
|
|
|
;;
|
2012-11-04 19:12:42 +00:00
|
|
|
*) if test "$cross_compiling" = yes; then
|
|
|
|
ac_cv_func_mmap_fixed_mapped=yes
|
|
|
|
AC_DEFINE(HAVE_MMAP, 1,
|
|
|
|
[Define to 1 if you have a working `mmap' system call.])
|
|
|
|
else
|
|
|
|
AC_FUNC_MMAP
|
|
|
|
fi
|
2008-06-14 02:30:53 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2007-07-18 18:30:50 +00:00
|
|
|
# If AtomicWord != Atomic32, we need to define two versions of all the
|
|
|
|
# atomicops functions. If they're the same, we want to define only one.
|
|
|
|
AC_MSG_CHECKING([if int32_t is the same type as intptr_t])
|
2012-11-04 17:21:00 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]], [[int32_t v1 = 0; intptr_t v2 = 0; return (&v1 - &v2)]])],[AC_DEFINE(INT32_EQUALS_INTPTR, 1,
|
2007-07-18 18:30:50 +00:00
|
|
|
Define to 1 if int32_t is equivalent to intptr_t)
|
2012-11-04 17:21:00 +00:00
|
|
|
AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
|
2007-04-16 20:49:32 +00:00
|
|
|
|
2007-08-17 20:56:15 +00:00
|
|
|
# We want to access the "PC" (Program Counter) register from a struct
|
|
|
|
# ucontext. Every system has its own way of doing that. We try all the
|
|
|
|
# possibilities we know about. Note REG_PC should come first (REG_RIP
|
2009-03-11 20:50:03 +00:00
|
|
|
# is also defined on solaris, but does the wrong thing). But don't
|
|
|
|
# bother if we're not doing cpu-profiling.
|
|
|
|
# [*] means that we've not actually tested one of these systems
|
|
|
|
if test "$enable_cpu_profiler" = yes; then
|
2009-11-10 16:24:57 +00:00
|
|
|
AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not try to compile libprofiler...);
|
2009-09-11 18:42:32 +00:00
|
|
|
enable_cpu_profiler=no)
|
2007-08-17 20:56:15 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-10 16:24:57 +00:00
|
|
|
# Some tests test the behavior of .so files, and only make sense for dynamic.
|
|
|
|
AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes)
|
|
|
|
|
2014-02-25 20:41:28 +00:00
|
|
|
# We want to link in libunwind or libexecinfo if it exists
|
2014-03-01 20:38:08 +00:00
|
|
|
AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind,
|
|
|
|
[AC_CHECK_LIB(execinfo, backtrace, UNWIND_LIBS=-lexecinfo, UNWIND_LIBS=)])
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_SUBST(UNWIND_LIBS)
|
|
|
|
|
2012-11-03 14:13:21 +00:00
|
|
|
# On x86_64, instead of libunwind, we can choose to compile with frame-pointers.
|
2008-02-13 00:55:09 +00:00
|
|
|
AC_ARG_ENABLE(frame_pointers,
|
|
|
|
AS_HELP_STRING([--enable-frame-pointers],
|
2007-04-16 20:49:32 +00:00
|
|
|
[On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),
|
2008-02-13 00:55:09 +00:00
|
|
|
, enable_frame_pointers=no)
|
2009-11-10 16:24:57 +00:00
|
|
|
AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
|
|
|
|
|
2014-02-17 03:41:37 +00:00
|
|
|
AC_MSG_CHECKING([for x86 without frame pointers])
|
2012-11-03 14:13:21 +00:00
|
|
|
# Some x86_64 systems do not insert frame pointers by default.
|
2009-11-10 16:24:57 +00:00
|
|
|
# We want to see if the current system is one of those.
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
|
|
|
|
[is_x86_64=yes], [is_x86_64=no])
|
2009-11-10 16:24:57 +00:00
|
|
|
OLD_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -S -O2 -o fp.s"
|
|
|
|
# This test will always fail because we don't name our output file properly.
|
|
|
|
# We do our own determination of success/failure in the grep, below.
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int f(int x) {return x;}], [return f(0);])],
|
|
|
|
[:], [:])
|
2014-02-17 03:41:37 +00:00
|
|
|
x86_no_fp_by_default=no
|
|
|
|
AS_IF([test "$is_x86_64" = yes && ! grep 'mov.*rsp.*rbp' fp.s >/dev/null 2>&1], [x86_no_fp_by_default=yes])
|
2009-11-10 16:24:57 +00:00
|
|
|
AM_CONDITIONAL(X86_64_AND_NO_FP_BY_DEFAULT,
|
2014-02-17 03:41:37 +00:00
|
|
|
test "$x86_no_fp_by_default" = yes)
|
2009-11-10 16:24:57 +00:00
|
|
|
rm fp.s
|
|
|
|
CFLAGS="$OLD_CFLAGS"
|
2014-02-17 03:41:37 +00:00
|
|
|
AC_MSG_RESULT([$x86_no_fp_by_default])
|
|
|
|
|
2009-11-10 16:24:57 +00:00
|
|
|
|
2011-12-23 00:45:49 +00:00
|
|
|
# We need to know if we're i386 so we can turn on -mmms, which is not
|
|
|
|
# on by default for i386 (it is for x86_64).
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __i386__ == 1 ? 0 : 1])],
|
|
|
|
[is_i386=yes], [is_i386=no])
|
|
|
|
AM_CONDITIONAL(I386, test "$is_i386" = yes)
|
|
|
|
|
2011-07-16 01:07:10 +00:00
|
|
|
# See if the compiler supports -Wno-unused-result.
|
|
|
|
# Newer ubuntu's turn on -D_FORTIFY_SOURCE=2, enabling
|
|
|
|
# __attribute__((warn_unused_result)) for things like write(),
|
|
|
|
# which we don't care about.
|
|
|
|
AC_CACHE_CHECK([if the compiler supports -Wno-unused-result],
|
|
|
|
perftools_cv_w_no_unused_result,
|
|
|
|
[OLD_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Wno-error -Wno-unused-result"
|
|
|
|
# gcc doesn't warn about unknown flags unless it's
|
|
|
|
# also warning for some other purpose, hence the
|
|
|
|
# divide-by-0. (We use -Wno-error to make sure the
|
|
|
|
# divide-by-0 doesn't cause this test to fail!)
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, return 1/0)],
|
|
|
|
perftools_cv_w_no_unused_result=yes,
|
|
|
|
perftools_cv_w_no_unused_result=no)
|
|
|
|
CFLAGS="$OLD_CFLAGS"])
|
|
|
|
AM_CONDITIONAL(HAVE_W_NO_UNUSED_RESULT,
|
|
|
|
test "$perftools_cv_w_no_unused_result" = yes)
|
2007-03-22 03:00:33 +00:00
|
|
|
|
|
|
|
# Defines PRIuS
|
|
|
|
AC_COMPILER_CHARACTERISTICS
|
|
|
|
|
2007-08-17 20:56:15 +00:00
|
|
|
# Also make sure we get standard PRI... definitions, even with glibc.
|
|
|
|
# We have to use AH_VERBATIM because we need the #ifdef guard (gcc buglet)
|
|
|
|
AH_VERBATIM([__STDC_FORMAT_MACROS],
|
|
|
|
[/* C99 says: define this to get the PRI... macros from stdint.h */
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
# define __STDC_FORMAT_MACROS 1
|
|
|
|
#endif])
|
|
|
|
|
2007-03-22 03:28:56 +00:00
|
|
|
# Check if __builtin_stack_pointer() is available (for elfcore.h)
|
|
|
|
AC_MSG_CHECKING([for __builtin_stack_pointer()])
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(, [void *sp = __builtin_stack_pointer()])],
|
2007-03-22 03:28:56 +00:00
|
|
|
[AC_DEFINE(HAVE_BUILTIN_STACK_POINTER, 1,
|
|
|
|
Define to 1 if compiler supports __builtin_stack_pointer)
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2012-12-22 20:06:47 +00:00
|
|
|
# Check for __builtin_expect()
|
|
|
|
AC_MSG_CHECKING([for __builtin_expect()])
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(, return __builtin_expect(main != 0, 1))],
|
|
|
|
[AC_DEFINE(HAVE_BUILTIN_EXPECT, 1,
|
|
|
|
Define to 1 if compiler supports __builtin_expect)
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2009-12-02 18:15:13 +00:00
|
|
|
# Check if __environ is available (for GetenvBeforeMain)
|
|
|
|
AC_MSG_CHECKING([for __environ])
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
|
|
|
|
[char **env = __environ])],
|
|
|
|
[AC_DEFINE(HAVE___ENVIRON, 1,
|
|
|
|
[Define to 1 if compiler supports __environ])
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2007-04-16 20:49:32 +00:00
|
|
|
# If we support __thread, that can speed up tcmalloc a bit.
|
2008-12-13 01:35:42 +00:00
|
|
|
# Note, however, that our code tickles a bug in gcc < 4.1.2
|
|
|
|
# involving TLS and -fPIC (which our libraries will use) on x86:
|
|
|
|
# http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
|
2013-03-11 19:16:47 +00:00
|
|
|
#
|
|
|
|
# And mingw also does compile __thread but resultant code actually
|
|
|
|
# fails to work correctly at least in some not so ancient version:
|
|
|
|
# http://mingw-users.1079350.n2.nabble.com/gcc-4-4-multi-threaded-exception-handling-amp-thread-specifier-not-working-td3440749.html
|
2014-01-11 03:39:53 +00:00
|
|
|
#
|
|
|
|
# Also it was reported that earlier gcc versions for mips compile
|
|
|
|
# __thread but it doesn't really work
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_MSG_CHECKING([for __thread])
|
2014-01-11 03:39:53 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2))
|
2008-12-13 01:35:42 +00:00
|
|
|
#error gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
|
2013-08-29 16:00:31 +00:00
|
|
|
#elif defined(__MINGW32__)
|
2014-01-12 00:28:15 +00:00
|
|
|
#error mingw doesnt really support tls
|
2013-08-29 16:00:31 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#error OSX __thread support is known to call malloc which makes it unsafe to use from malloc replacement
|
2013-03-11 19:16:47 +00:00
|
|
|
#endif
|
|
|
|
], [static __thread int p = 0])],
|
2007-04-16 20:49:32 +00:00
|
|
|
[AC_DEFINE(HAVE_TLS, 1,
|
2011-07-16 01:07:10 +00:00
|
|
|
Define to 1 if compiler supports __thread)
|
2007-04-16 20:49:32 +00:00
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2011-07-16 01:07:10 +00:00
|
|
|
# glibc's __malloc_hook/etc were declared volatile starting in glibc 2.14
|
|
|
|
AC_MSG_CHECKING([if __malloc_hook is declared volatile])
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <malloc.h>
|
|
|
|
void* (* volatile __malloc_hook)(size_t, const void*) = 0;],)],
|
|
|
|
[AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, volatile,
|
|
|
|
Define to 'volatile' if __malloc_hook is declared volatile)
|
|
|
|
AC_MSG_RESULT([yes])],
|
2011-07-27 04:18:01 +00:00
|
|
|
[AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, )
|
2011-07-16 01:07:10 +00:00
|
|
|
AC_MSG_RESULT([no])])
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# Nanosleep requires extra libraries on some architectures (solaris).
|
|
|
|
# This sets NANOSLEEP_LIBS. nanosleep doesn't exist on mingw, which
|
|
|
|
# is fine for us because we don't compile libspinlock, which uses it.
|
|
|
|
if test "$need_nanosleep" = yes; then
|
|
|
|
ACX_NANOSLEEP
|
|
|
|
AC_SUBST(NANOSLEEP_LIBS)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Solaris 10 6/06 has a bug where /usr/sfw/lib/libstdc++.la is empty.
|
|
|
|
# If so, we replace it with our own version.
|
|
|
|
LIBSTDCXX_LA_LINKER_FLAG=
|
|
|
|
if test -f /usr/sfw/lib/libstdc++.la && ! test -s /usr/sfw/lib/libstdc++.la
|
|
|
|
then
|
|
|
|
LIBSTDCXX_LA_LINKER_FLAG='-L$(top_srcdir)/src/solaris'
|
|
|
|
fi
|
|
|
|
AC_SUBST(LIBSTDCXX_LA_LINKER_FLAG)
|
|
|
|
|
2007-04-16 20:49:32 +00:00
|
|
|
# We also need to check if the kernel supports __thread, which requires uname()
|
|
|
|
AC_CHECK_DECLS(uname,,, [#include <sys/utsname.h>])
|
|
|
|
|
|
|
|
# In fact, a lot of the code in this directory depends on pthreads
|
2007-03-22 03:00:33 +00:00
|
|
|
ACX_PTHREAD
|
|
|
|
|
2014-01-05 02:28:36 +00:00
|
|
|
AC_LANG_SAVE
|
|
|
|
AC_LANG_CPLUSPLUS
|
|
|
|
AC_MSG_CHECKING([whether pthread symbols are available in C++ without including pthread.h])
|
|
|
|
acx_pthread_despite_asking_for=no
|
|
|
|
AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
],[
|
|
|
|
pthread_t th; pthread_join(th, 0);
|
|
|
|
])],[
|
|
|
|
acx_pthread_despite_asking_for=yes
|
|
|
|
AC_DEFINE(HAVE_PTHREAD_DESPITE_ASKING_FOR, 1, [defined to 1 if pthread symbols are exposed even without include pthread.h])
|
|
|
|
AC_DEFINE(HAVE_PTHREAD, 1, [])
|
|
|
|
])
|
|
|
|
AC_MSG_RESULT([$acx_pthread_despite_asking_for])
|
|
|
|
AC_LANG_RESTORE
|
|
|
|
|
2014-02-25 20:41:07 +00:00
|
|
|
AM_CONDITIONAL(HAVE_PTHREAD_DESPITE_ASKING_FOR, test x"$acx_pthread_despite_asking_for" = xyes)
|
2014-01-05 02:28:36 +00:00
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# Find out what namespace 'normal' STL code lives in
|
|
|
|
AC_CXX_STL_NAMESPACE
|
|
|
|
|
|
|
|
# Figure out where libc has program_invocation_name
|
|
|
|
AC_PROGRAM_INVOCATION_NAME
|
|
|
|
|
|
|
|
# Make the install prefix available, to figure out where to look for pprof
|
|
|
|
AC_INSTALL_PREFIX
|
|
|
|
|
2013-07-20 21:35:14 +00:00
|
|
|
dnl only very recent mingw has sleep and nanosleep
|
|
|
|
case "$host" in
|
|
|
|
*-mingw*)
|
|
|
|
AC_CHECK_DECLS([sleep], [], [], [#include <unistd.h>])
|
|
|
|
AC_CHECK_DECLS([nanosleep], [], [], [#include <time.h>])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-04-12 19:38:19 +00:00
|
|
|
if test "x$enable_backtrace" = xyes; then
|
|
|
|
AC_CHECK_DECLS([backtrace], [], [], [#include <execinfo.h>])
|
|
|
|
fi
|
2013-07-20 21:35:14 +00:00
|
|
|
|
2007-07-18 18:30:50 +00:00
|
|
|
# For windows, this has a non-trivial value (__declspec(export)), but any
|
|
|
|
# system that uses configure wants this to be the empty string.
|
|
|
|
AC_DEFINE(PERFTOOLS_DLL_DECL,,
|
|
|
|
[Always the empty-string on non-windows systems.
|
|
|
|
On windows, should be "__declspec(dllexport)".
|
|
|
|
This way, when we compile the dll, we export our functions/classes.
|
|
|
|
It's safe to define this here because config.h is only used
|
|
|
|
internally, to compile the DLL, and every DLL source file
|
|
|
|
#includes "config.h" before anything else.])
|
|
|
|
|
2010-06-21 15:59:56 +00:00
|
|
|
# In theory, config.h files shouldn't need a header guard, but we do,
|
|
|
|
# because we (maybe) #include windows/mingw.h from within config.h,
|
|
|
|
# and it #includes other .h files. These all have header guards, so
|
|
|
|
# the end result is if config.h is #included twice, its #undefs get
|
|
|
|
# evaluated twice, but all the ones in mingw.h/etc only get evaluated
|
|
|
|
# once, potentially causing trouble. c.f.
|
2012-02-04 00:07:36 +00:00
|
|
|
# http://code.google.com/p/gperftools/issues/detail?id=246
|
2010-06-21 15:59:56 +00:00
|
|
|
AH_TOP([
|
2012-02-04 00:07:36 +00:00
|
|
|
#ifndef GPERFTOOLS_CONFIG_H_
|
|
|
|
#define GPERFTOOLS_CONFIG_H_
|
2010-06-21 15:59:56 +00:00
|
|
|
])
|
|
|
|
|
2011-08-26 21:08:59 +00:00
|
|
|
AH_VERBATIM([PTHREADS_CRASHES_IF_RUN_TOO_EARLY],
|
|
|
|
[/* Mark the systems where we know it's bad if pthreads runs too
|
|
|
|
early before main (before threads are initialized, presumably). */
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#define PTHREADS_CRASHES_IF_RUN_TOO_EARLY 1
|
|
|
|
#endif])
|
|
|
|
|
2007-11-29 23:39:24 +00:00
|
|
|
# MinGW uses autoconf, but also needs the windows shim routines
|
|
|
|
# (since it doesn't have its own support for, say, pthreads).
|
|
|
|
# This requires us to #include a special header file, and also to
|
|
|
|
# link in some windows versions of .o's instead of the unix versions.
|
2011-07-16 01:07:10 +00:00
|
|
|
#
|
|
|
|
# Also, manually mark systems where we have to be careful how early
|
|
|
|
# we run pthreads. TODO(csilvers): turn this into an autoconf check.
|
2007-11-29 23:39:24 +00:00
|
|
|
AH_BOTTOM([
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include "windows/mingw.h"
|
|
|
|
#endif
|
2010-06-21 15:59:56 +00:00
|
|
|
|
2012-02-04 00:07:36 +00:00
|
|
|
#endif /* #ifndef GPERFTOOLS_CONFIG_H_ */
|
2007-11-29 23:39:24 +00:00
|
|
|
])
|
2009-03-11 20:50:03 +00:00
|
|
|
AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
|
2011-07-16 01:07:10 +00:00
|
|
|
AM_CONDITIONAL(OSX, expr $host : '.*-apple-darwin.*' >/dev/null 2>&1)
|
2009-03-11 20:50:03 +00:00
|
|
|
|
2010-03-23 20:39:55 +00:00
|
|
|
# Redhat 7 (and below?) has sys/ucontext.h, but if you try to #include
|
|
|
|
# it directly, the compiler gets upset. So we pretend we don't have
|
|
|
|
# it.
|
|
|
|
if cat /etc/redhat-release 2>/dev/null | grep "Red Hat Linux release 7" >/dev/null 2>&1; then
|
|
|
|
AC_DEFINE(HAVE_SYS_UCONTEXT_H, 0, [<sys/ucontext.h> is broken on redhat 7])
|
|
|
|
fi
|
|
|
|
|
2009-03-11 20:50:03 +00:00
|
|
|
# Export the --enable flags we set above. We do this at the end so
|
|
|
|
# other configure rules can enable or disable targets based on what
|
|
|
|
# they find.
|
|
|
|
AM_CONDITIONAL(WITH_CPU_PROFILER, test "$enable_cpu_profiler" = yes)
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_PROFILER, test "$enable_heap_profiler" = yes)
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_CHECKER, test "$enable_heap_checker" = yes)
|
2009-09-11 18:42:32 +00:00
|
|
|
AM_CONDITIONAL(WITH_DEBUGALLOC, test "$enable_debugalloc" = yes)
|
2009-03-11 20:50:03 +00:00
|
|
|
# We make tcmalloc.so if either heap-profiler or heap-checker is asked for.
|
|
|
|
AM_CONDITIONAL(WITH_HEAP_PROFILER_OR_CHECKER,
|
|
|
|
test "$enable_heap_profiler" = yes -o \
|
|
|
|
"$enable_heap_checker" = yes)
|
|
|
|
# If we don't use any profilers, we don't need stack traces (or pprof)
|
|
|
|
AM_CONDITIONAL(WITH_STACK_TRACE, test "$enable_cpu_profiler" = yes -o \
|
|
|
|
"$enable_heap_profiler" = yes -o \
|
|
|
|
"$enable_heap_checker" = yes)
|
2007-11-29 23:39:24 +00:00
|
|
|
|
2007-03-22 03:00:33 +00:00
|
|
|
# Write generated configuration file
|
2012-02-04 00:07:36 +00:00
|
|
|
AC_CONFIG_FILES([Makefile
|
|
|
|
src/gperftools/tcmalloc.h src/windows/gperftools/tcmalloc.h])
|
2007-03-22 03:00:33 +00:00
|
|
|
AC_OUTPUT
|
2014-02-17 03:41:37 +00:00
|
|
|
|
2014-04-12 19:38:19 +00:00
|
|
|
AS_IF([test "$x86_no_fp_by_default" = yes && test "x$enable_frame_pointers" != xyes && test "x$UNWIND_LIBS" = x && test "x$enable_minimal" != xyes],
|
|
|
|
[AS_IF([test "x$enable_backtrace" = xyes],
|
|
|
|
[AC_MSG_WARN([No frame pointers and no libunwind. Expect backtrace capturing and unittests to fail])],
|
|
|
|
[AC_MSG_FAILURE([No frame pointers and no libunwind. The compilation will fail])])])
|