csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 1 | ## Process this file with autoconf to produce configure. |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 2 | ## In general, the safest way to proceed is to run ./autogen.sh |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 3 | |
| 4 | # make sure we're interpreted by some minimal autoconf |
Aliaksey Kandratsenka | 4380908 | 2013-08-29 18:51:48 +0300 | [diff] [blame] | 5 | AC_PREREQ([2.59]) |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 6 | |
Aliaksey Kandratsenka | 632de29 | 2016-03-12 11:48:20 -0800 | [diff] [blame] | 7 | AC_INIT([gperftools],[2.5],[gperftools@googlegroups.com]) |
csilvers | 7375b4f | 2011-02-05 00:19:37 +0000 | [diff] [blame] | 8 | # Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B) |
| 9 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
Aliaksey Kandratsenka | 632de29 | 2016-03-12 11:48:20 -0800 | [diff] [blame] | 10 | TCMALLOC_SO_VERSION=7:0:3 |
| 11 | PROFILER_SO_VERSION=4:8:4 |
csilvers | 3014cf1 | 2010-11-18 01:07:25 +0000 | [diff] [blame] | 12 | |
| 13 | AC_SUBST(TCMALLOC_SO_VERSION) |
| 14 | AC_SUBST(PROFILER_SO_VERSION) |
| 15 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 16 | # The argument here is just something that should be in the current directory |
| 17 | # (for sanity checking) |
| 18 | AC_CONFIG_SRCDIR(README) |
csilvers | 3014cf1 | 2010-11-18 01:07:25 +0000 | [diff] [blame] | 19 | AC_CONFIG_MACRO_DIR([m4]) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 20 | AC_CANONICAL_HOST |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 21 | AM_INIT_AUTOMAKE([dist-zip]) |
chappedm@gmail.com | 1363bc6 | 2012-11-04 17:21:00 +0000 | [diff] [blame] | 22 | AC_CONFIG_HEADERS([src/config.h]) |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 23 | |
Aliaksey Kandratsenka | f8a2163 | 2013-12-06 12:23:48 -0800 | [diff] [blame] | 24 | AM_MAINTAINER_MODE() |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 25 | # Export the version information (for tc_version and friends) |
| 26 | TC_VERSION_MAJOR=`expr "$PACKAGE_VERSION" : '\([[0-9]]*\)'` |
csilvers | f633b40 | 2011-08-11 22:06:22 +0000 | [diff] [blame] | 27 | TC_VERSION_MINOR=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.\([[0-9]]*\)'` |
| 28 | TC_VERSION_PATCH=`expr "$PACKAGE_VERSION" : '[[0-9]]*\.[[0-9]]*\(.*\)$'` |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 29 | AC_SUBST(TC_VERSION_MAJOR) |
| 30 | AC_SUBST(TC_VERSION_MINOR) |
| 31 | AC_SUBST(TC_VERSION_PATCH) |
| 32 | AC_SUBST(PACKAGE_STRING) |
| 33 | |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 34 | # The user can choose not to compile in the heap-profiler, the |
| 35 | # heap-checker, or the cpu-profiler. There's also the possibility |
| 36 | # for a 'fully minimal' compile, which leaves out the stacktrace |
| 37 | # code as well. By default, we include all of these that the |
| 38 | # target system supports. |
| 39 | default_enable_cpu_profiler=yes |
| 40 | default_enable_heap_profiler=yes |
| 41 | default_enable_heap_checker=yes |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 42 | default_enable_debugalloc=yes |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 43 | default_enable_minimal=no |
Raphael Moreira Zinsly | 3f55d87 | 2014-12-23 10:29:49 -0200 | [diff] [blame] | 44 | default_tcmalloc_alignment=16 |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 45 | need_nanosleep=yes # Used later, to decide if to run ACX_NANOSLEEP |
| 46 | case "$host" in |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 47 | *-mingw*) default_enable_minimal=yes; default_enable_debugalloc=no; |
| 48 | need_nanosleep=no;; |
csilvers | beb6a9a | 2009-04-18 00:02:25 +0000 | [diff] [blame] | 49 | *-cygwin*) default_enable_heap_checker=no; default_enable_cpu_profiler=no;; |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 50 | *-freebsd*) default_enable_heap_checker=no;; |
| 51 | *-darwin*) default_enable_heap_checker=no;; |
| 52 | esac |
| 53 | |
Bryan Chan | 644a6bd | 2016-01-22 12:26:47 -0500 | [diff] [blame] | 54 | # Currently only backtrace works on s390x. |
| 55 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __s390x__])], |
| 56 | [default_enable_libunwind=no |
| 57 | default_enable_backtrace=yes], |
| 58 | [default_enable_libunwind=yes |
| 59 | default_enable_backtrace=no]) |
| 60 | |
Raphael Moreira Zinsly | 8eb4ed7 | 2014-11-27 14:11:09 -0200 | [diff] [blame] | 61 | # Disable libunwind linking on ppc64 by default. |
| 62 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __PPC64__])], |
Raphael Moreira Zinsly | b8b027d | 2014-12-23 10:55:22 -0200 | [diff] [blame] | 63 | [default_enable_libunwind=no |
| 64 | default_tcmalloc_pagesize=64], |
| 65 | [default_enable_libunwind=yes |
| 66 | default_tcmalloc_pagesize=8]) |
Raphael Moreira Zinsly | 8eb4ed7 | 2014-11-27 14:11:09 -0200 | [diff] [blame] | 67 | |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 68 | AC_ARG_ENABLE([cpu-profiler], |
| 69 | [AS_HELP_STRING([--disable-cpu-profiler], |
| 70 | [do not build the cpu profiler])], |
| 71 | [], |
| 72 | [enable_cpu_profiler="$default_enable_cpu_profiler"]) |
| 73 | AC_ARG_ENABLE([heap-profiler], |
| 74 | [AS_HELP_STRING([--disable-heap-profiler], |
| 75 | [do not build the heap profiler])], |
| 76 | [], |
| 77 | [enable_heap_profiler="$default_enable_heap_profiler"]) |
| 78 | AC_ARG_ENABLE([heap-checker], |
| 79 | [AS_HELP_STRING([--disable-heap-checker], |
| 80 | [do not build the heap checker])], |
| 81 | [], |
| 82 | [enable_heap_checker="$default_enable_heap_checker"]) |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 83 | AC_ARG_ENABLE([debugalloc], |
| 84 | [AS_HELP_STRING([--disable-debugalloc], |
| 85 | [do not build versions of libs with debugalloc])], |
| 86 | [], |
| 87 | [enable_debugalloc="$default_enable_debugalloc"]) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 88 | AC_ARG_ENABLE([minimal], |
| 89 | [AS_HELP_STRING([--enable-minimal], |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 90 | [build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)])], |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 91 | [], |
| 92 | [enable_minimal="$default_enable_minimal"]) |
| 93 | if test "$enable_minimal" = yes; then |
| 94 | enable_cpu_profiler=no |
| 95 | enable_heap_profiler=no |
| 96 | enable_heap_checker=no |
| 97 | fi |
Aliaksey Kandratsenka | 125e5ed | 2014-04-12 12:38:19 -0700 | [diff] [blame] | 98 | AC_ARG_ENABLE([stacktrace-via-backtrace], |
| 99 | [AS_HELP_STRING([--enable-stacktrace-via-backtrace], |
| 100 | [enable use of backtrace() for stacktrace capturing (may deadlock)])], |
| 101 | [enable_backtrace=yes], |
Bryan Chan | 644a6bd | 2016-01-22 12:26:47 -0500 | [diff] [blame] | 102 | [enable_backtrace="$default_enable_backtrace"]) |
Raphael Moreira Zinsly | 8eb4ed7 | 2014-11-27 14:11:09 -0200 | [diff] [blame] | 103 | AC_ARG_ENABLE([libunwind], |
| 104 | [AS_HELP_STRING([--enable-libunwind], |
| 105 | [enable libunwind linking])], |
| 106 | [], |
| 107 | [enable_libunwind="$default_enable_libunwind"]) |
Raphael Moreira Zinsly | 3f55d87 | 2014-12-23 10:29:49 -0200 | [diff] [blame] | 108 | AC_ARG_WITH([tcmalloc-pagesize], |
| 109 | [AS_HELP_STRING([--with-tcmalloc-pagesize], |
| 110 | [Set the tcmalloc internal page size to 8K, 32K or 64K])], |
| 111 | [], |
| 112 | [with_tcmalloc_pagesize=$default_tcmalloc_pagesize]) |
| 113 | AC_ARG_WITH([tcmalloc-alignment], |
| 114 | [AS_HELP_STRING([--with-tcmalloc-alignment], |
| 115 | [Set the tcmalloc allocation alignment to 8 or 16 bytes])], |
| 116 | [], |
| 117 | [with_tcmalloc_alignment=$default_tcmalloc_alignment]) |
| 118 | |
| 119 | case "$with_tcmalloc_pagesize" in |
| 120 | 8) |
| 121 | #Default tcmalloc page size. |
| 122 | ;; |
| 123 | 32) |
| 124 | AC_DEFINE(TCMALLOC_32K_PAGES, 1, |
| 125 | [Define 32K of internal pages size for tcmalloc]);; |
| 126 | 64) |
| 127 | AC_DEFINE(TCMALLOC_64K_PAGES, 1, |
| 128 | [Define 64K of internal pages size for tcmalloc]);; |
| 129 | *) |
| 130 | AC_MSG_WARN([${with_tcmalloc_pagesize}K size not supported, using default tcmalloc page size.]) |
| 131 | esac |
| 132 | case "$with_tcmalloc_alignment" in |
| 133 | 8) |
| 134 | AC_DEFINE(TCMALLOC_ALIGN_8BYTES, 1, |
| 135 | [Define 8 bytes of allocation alignment for tcmalloc]);; |
| 136 | 16) |
| 137 | #Default tcmalloc allocation alignment. |
| 138 | ;; |
| 139 | *) |
| 140 | AC_MSG_WARN([${with_tcmalloc_alignment} bytes not supported, using default tcmalloc allocation alignment.]) |
| 141 | esac |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 142 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 143 | # Checks for programs. |
csilvers | a6076ed | 2011-10-18 20:57:45 +0000 | [diff] [blame] | 144 | AC_PROG_CXX |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 145 | AC_PROG_CC |
| 146 | AC_PROG_CPP |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 147 | AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc |
csilvers | beb6a9a | 2009-04-18 00:02:25 +0000 | [diff] [blame] | 148 | AM_PROG_CC_C_O # shrug: autogen.sh suddenly needs this for some reason |
| 149 | |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 150 | # Check if we have an objcopy installed that supports -W |
| 151 | AC_CHECK_TOOL([OBJCOPY], [objcopy], []) |
csilvers | 8c7d228 | 2011-05-19 21:37:12 +0000 | [diff] [blame] | 152 | AS_IF([test -n "$OBJCOPY"], [dnl |
| 153 | AC_CACHE_CHECK([if $OBJCOPY supports -W], gpt_cv_objcopy_weaken, [dnl |
chappedm@gmail.com | 1363bc6 | 2012-11-04 17:21:00 +0000 | [diff] [blame] | 154 | AC_LINK_IFELSE([AC_LANG_PROGRAM([void foo() {} int main() {return 0;}])], [dnl |
csilvers | 8c7d228 | 2011-05-19 21:37:12 +0000 | [diff] [blame] | 155 | AS_IF(["$OBJCOPY" -W foo conftest$ac_exeext /dev/null], |
| 156 | [gpt_cv_objcopy_weaken=yes], [gpt_cv_objcopy_weaken=no])], |
| 157 | [gpt_cv_objcopy_weaken=no])])], |
| 158 | [gpt_cv_objcopy_weaken=no]) |
| 159 | AM_CONDITIONAL(HAVE_OBJCOPY_WEAKEN, test $gpt_cv_objcopy_weaken = yes) |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 160 | |
Aliaksey Kandratsenka | f216317 | 2013-11-16 15:05:45 -0800 | [diff] [blame] | 161 | AC_PROG_LIBTOOL |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 162 | |
| 163 | AC_C_INLINE |
| 164 | AX_C___ATTRIBUTE__ |
| 165 | |
| 166 | # Check whether some low-level functions/files are available |
| 167 | AC_HEADER_STDC |
| 168 | |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 169 | # TODO(csilvers): we could remove a lot when WITH_CPU_PROFILER etc is "no". |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 170 | AC_CHECK_TYPES([__int64]) # defined in some windows platforms |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 171 | AC_CHECK_TYPES([struct mallinfo],,, [#include <malloc.h>]) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 172 | AC_CHECK_TYPES([Elf32_Versym],,, [#include <elf.h>]) # for vdso_support.h |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 173 | AC_CHECK_FUNCS(sbrk) # for tcmalloc to get memory |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 174 | AC_CHECK_FUNCS(geteuid) # for turning off services when run as root |
chappedm@gmail.com | bd3b3a7 | 2013-03-10 20:17:21 +0000 | [diff] [blame] | 175 | AC_CHECK_FUNCS(fork) # for the pthread_atfork setup |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 176 | AC_CHECK_HEADERS(features.h) # for vdso_support.h |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 177 | AC_CHECK_HEADERS(malloc.h) # some systems define stuff there, others not |
| 178 | AC_CHECK_HEADERS(glob.h) # for heap-profile-table (cleaning up profiles) |
csilvers | 91fad38 | 2007-03-22 03:28:56 +0000 | [diff] [blame] | 179 | AC_CHECK_HEADERS(execinfo.h) # for stacktrace? and heapchecker_unittest |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 180 | AC_CHECK_HEADERS(unwind.h) # for stacktrace |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 181 | AC_CHECK_HEADERS(sched.h) # for being nice in our spinlock code |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 182 | AC_CHECK_HEADERS(conflict-signal.h) # defined on some windows platforms? |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 183 | AC_CHECK_HEADERS(sys/prctl.h) # for thread_lister (needed by leak-checker) |
| 184 | AC_CHECK_HEADERS(linux/ptrace.h)# also needed by leak-checker |
| 185 | AC_CHECK_HEADERS(sys/syscall.h) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 186 | AC_CHECK_HEADERS(sys/socket.h) # optional; for forking out to symbolizer |
| 187 | AC_CHECK_HEADERS(sys/wait.h) # optional; for forking out to symbolizer |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 188 | AC_CHECK_HEADERS(poll.h) # optional; for forking out to symbolizer |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 189 | AC_CHECK_HEADERS(fcntl.h) # for tcmalloc_unittest |
csilvers | 91fad38 | 2007-03-22 03:28:56 +0000 | [diff] [blame] | 190 | AC_CHECK_HEADERS(grp.h) # for heapchecker_unittest |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 191 | AC_CHECK_HEADERS(pwd.h) # for heapchecker_unittest |
csilvers | 100e657 | 2008-06-14 02:30:53 +0000 | [diff] [blame] | 192 | AC_CHECK_HEADERS(sys/resource.h) # for memalign_unittest.cc |
csilvers | 92beff8 | 2010-03-23 20:39:55 +0000 | [diff] [blame] | 193 | AC_CHECK_HEADERS(valgrind.h) # we have a local copy if this isn't found |
csilvers | 8c7d228 | 2011-05-19 21:37:12 +0000 | [diff] [blame] | 194 | AC_CHECK_HEADERS(sys/cdefs.h) # Where glibc defines __THROW |
| 195 | AC_CHECK_HEADERS(features.h) # Where __GLIBC__ is defined |
csilvers | 92beff8 | 2010-03-23 20:39:55 +0000 | [diff] [blame] | 196 | # We also need <ucontext.h>/<sys/ucontext.h>, but we get those from |
| 197 | # AC_PC_FROM_UCONTEXT, below. |
| 198 | |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 199 | # We override a lot of memory allocation routines, not all of which are |
| 200 | # standard. For those the system doesn't declare, we'll declare ourselves. |
| 201 | AC_CHECK_DECLS([cfree, |
| 202 | posix_memalign, |
| 203 | memalign, |
| 204 | valloc, |
| 205 | pvalloc],,, |
| 206 | [#define _XOPEN_SOURCE 600 |
| 207 | #include <stdlib.h> |
| 208 | #include <malloc.h>]) |
| 209 | |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 210 | if test "$ac_cv_type_struct_mallinfo" = yes; then |
csilvers | 4e9432c | 2012-02-04 00:07:36 +0000 | [diff] [blame] | 211 | AC_SUBST(ac_cv_have_struct_mallinfo, 1) # gperftools/tcmalloc.h needs this |
csilvers | 2197cc6 | 2009-06-10 02:04:26 +0000 | [diff] [blame] | 212 | else |
| 213 | AC_SUBST(ac_cv_have_struct_mallinfo, 0) |
| 214 | fi |
| 215 | |
csilvers | 100e657 | 2008-06-14 02:30:53 +0000 | [diff] [blame] | 216 | # We need to check for mmap. cygwin supports mmap, but the autoconf |
| 217 | # test doesn't work on cygwin: |
| 218 | # http://www.cygwin.com/ml/cygwin/2002-04/msg00412.html |
| 219 | # This workaround comes from |
| 220 | # http://cygwin.com/ml/cygwin/2004-11/msg00138.html |
| 221 | case "$host" in |
alkondratenko@gmail.com | 8bf4522 | 2013-03-11 19:15:46 +0000 | [diff] [blame] | 222 | *-*-mingw*) |
| 223 | dnl mingw doesn't have mmap, not worth |
| 224 | dnl checking. Especially given that mingw can be a |
| 225 | dnl cross-compiler |
| 226 | ;; |
csilvers | 8c7d228 | 2011-05-19 21:37:12 +0000 | [diff] [blame] | 227 | *-*-cygwin*) |
| 228 | ac_cv_func_mmap_fixed_mapped=yes |
csilvers | 100e657 | 2008-06-14 02:30:53 +0000 | [diff] [blame] | 229 | AC_DEFINE(HAVE_MMAP, 1, |
| 230 | [Define to 1 if you have a working `mmap' system call.]) |
| 231 | ;; |
chappedm@gmail.com | 86a5531 | 2012-11-04 19:12:42 +0000 | [diff] [blame] | 232 | *) if test "$cross_compiling" = yes; then |
| 233 | ac_cv_func_mmap_fixed_mapped=yes |
| 234 | AC_DEFINE(HAVE_MMAP, 1, |
| 235 | [Define to 1 if you have a working `mmap' system call.]) |
| 236 | else |
| 237 | AC_FUNC_MMAP |
| 238 | fi |
csilvers | 100e657 | 2008-06-14 02:30:53 +0000 | [diff] [blame] | 239 | ;; |
| 240 | esac |
| 241 | |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 242 | # If AtomicWord != Atomic32, we need to define two versions of all the |
| 243 | # atomicops functions. If they're the same, we want to define only one. |
| 244 | AC_MSG_CHECKING([if int32_t is the same type as intptr_t]) |
chappedm@gmail.com | 1363bc6 | 2012-11-04 17:21:00 +0000 | [diff] [blame] | 245 | 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, |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 246 | Define to 1 if int32_t is equivalent to intptr_t) |
chappedm@gmail.com | 1363bc6 | 2012-11-04 17:21:00 +0000 | [diff] [blame] | 247 | AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])]) |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 248 | |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 249 | # We want to access the "PC" (Program Counter) register from a struct |
| 250 | # ucontext. Every system has its own way of doing that. We try all the |
| 251 | # possibilities we know about. Note REG_PC should come first (REG_RIP |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 252 | # is also defined on solaris, but does the wrong thing). But don't |
| 253 | # bother if we're not doing cpu-profiling. |
| 254 | # [*] means that we've not actually tested one of these systems |
| 255 | if test "$enable_cpu_profiler" = yes; then |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 256 | AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not try to compile libprofiler...); |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 257 | enable_cpu_profiler=no) |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 258 | fi |
| 259 | |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 260 | # Some tests test the behavior of .so files, and only make sense for dynamic. |
| 261 | AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes) |
| 262 | |
Raphael Moreira Zinsly | 8eb4ed7 | 2014-11-27 14:11:09 -0200 | [diff] [blame] | 263 | # We want to link in libunwind or libexecinfo if it it is enabled and exists. |
| 264 | if test "$enable_libunwind" = yes; then |
| 265 | AC_CHECK_HEADERS(libunwind.h) # for stacktrace |
| 266 | AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind, |
| 267 | [AC_CHECK_LIB(execinfo, backtrace, UNWIND_LIBS=-lexecinfo, UNWIND_LIBS=)]) |
| 268 | AC_SUBST(UNWIND_LIBS) |
Aliaksey Kandratsenka | 4f3410e | 2016-02-21 13:52:47 -0800 | [diff] [blame] | 269 | will_use_libunwind=yes |
Raphael Moreira Zinsly | 8eb4ed7 | 2014-11-27 14:11:09 -0200 | [diff] [blame] | 270 | else |
| 271 | AC_CHECK_LIB(execinfo, backtrace, UNWIND_LIBS=-lexecinfo, UNWIND_LIBS=) |
| 272 | AC_SUBST(UNWIND_LIBS) |
| 273 | fi |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 274 | |
chappedm@gmail.com | c566266 | 2012-11-03 14:13:21 +0000 | [diff] [blame] | 275 | # On x86_64, instead of libunwind, we can choose to compile with frame-pointers. |
csilvers | 8a0a310 | 2008-02-13 00:55:09 +0000 | [diff] [blame] | 276 | AC_ARG_ENABLE(frame_pointers, |
| 277 | AS_HELP_STRING([--enable-frame-pointers], |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 278 | [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]), |
csilvers | 8a0a310 | 2008-02-13 00:55:09 +0000 | [diff] [blame] | 279 | , enable_frame_pointers=no) |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 280 | AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes) |
| 281 | |
Aliaksey Kandratsenka | b5e584d | 2014-02-16 19:41:37 -0800 | [diff] [blame] | 282 | AC_MSG_CHECKING([for x86 without frame pointers]) |
chappedm@gmail.com | c566266 | 2012-11-03 14:13:21 +0000 | [diff] [blame] | 283 | # Some x86_64 systems do not insert frame pointers by default. |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 284 | # We want to see if the current system is one of those. |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 285 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])], |
| 286 | [is_x86_64=yes], [is_x86_64=no]) |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 287 | OLD_CFLAGS="$CFLAGS" |
| 288 | CFLAGS="$CFLAGS -S -O2 -o fp.s" |
| 289 | # This test will always fail because we don't name our output file properly. |
| 290 | # We do our own determination of success/failure in the grep, below. |
| 291 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int f(int x) {return x;}], [return f(0);])], |
| 292 | [:], [:]) |
Aliaksey Kandratsenka | b5e584d | 2014-02-16 19:41:37 -0800 | [diff] [blame] | 293 | x86_no_fp_by_default=no |
| 294 | AS_IF([test "$is_x86_64" = yes && ! grep 'mov.*rsp.*rbp' fp.s >/dev/null 2>&1], [x86_no_fp_by_default=yes]) |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 295 | AM_CONDITIONAL(X86_64_AND_NO_FP_BY_DEFAULT, |
Aliaksey Kandratsenka | b5e584d | 2014-02-16 19:41:37 -0800 | [diff] [blame] | 296 | test "$x86_no_fp_by_default" = yes) |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 297 | rm fp.s |
| 298 | CFLAGS="$OLD_CFLAGS" |
Aliaksey Kandratsenka | b5e584d | 2014-02-16 19:41:37 -0800 | [diff] [blame] | 299 | AC_MSG_RESULT([$x86_no_fp_by_default]) |
| 300 | |
csilvers | 5b80f01 | 2009-11-10 16:24:57 +0000 | [diff] [blame] | 301 | |
csilvers | 2a7b3b8 | 2011-12-23 00:45:49 +0000 | [diff] [blame] | 302 | # We need to know if we're i386 so we can turn on -mmms, which is not |
| 303 | # on by default for i386 (it is for x86_64). |
| 304 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __i386__ == 1 ? 0 : 1])], |
| 305 | [is_i386=yes], [is_i386=no]) |
| 306 | AM_CONDITIONAL(I386, test "$is_i386" = yes) |
| 307 | |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 308 | # See if the compiler supports -Wno-unused-result. |
| 309 | # Newer ubuntu's turn on -D_FORTIFY_SOURCE=2, enabling |
| 310 | # __attribute__((warn_unused_result)) for things like write(), |
| 311 | # which we don't care about. |
| 312 | AC_CACHE_CHECK([if the compiler supports -Wno-unused-result], |
| 313 | perftools_cv_w_no_unused_result, |
| 314 | [OLD_CFLAGS="$CFLAGS" |
Aliaksey Kandratsenka | 8cc75ac | 2015-10-04 11:04:12 -0700 | [diff] [blame] | 315 | CFLAGS="$CFLAGS -Wno-error -Wunused-result" |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 316 | # gcc doesn't warn about unknown flags unless it's |
| 317 | # also warning for some other purpose, hence the |
| 318 | # divide-by-0. (We use -Wno-error to make sure the |
| 319 | # divide-by-0 doesn't cause this test to fail!) |
Aliaksey Kandratsenka | 8cc75ac | 2015-10-04 11:04:12 -0700 | [diff] [blame] | 320 | # |
| 321 | # Also gcc is giving only warning for unknown flags of |
| 322 | # -Wno-XXX form. So in order to detect support we're |
| 323 | # using -Wunused-result which will cause gcc to give |
| 324 | # error which we can detect. |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 325 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, return 1/0)], |
| 326 | perftools_cv_w_no_unused_result=yes, |
| 327 | perftools_cv_w_no_unused_result=no) |
| 328 | CFLAGS="$OLD_CFLAGS"]) |
| 329 | AM_CONDITIONAL(HAVE_W_NO_UNUSED_RESULT, |
| 330 | test "$perftools_cv_w_no_unused_result" = yes) |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 331 | |
Aliaksey Kandratsenka | 6fdfc5a | 2015-10-24 23:16:45 -0700 | [diff] [blame] | 332 | AC_ARG_ENABLE([dynamic-sized-delete-support], |
Aliaksey Kandratsenka | 06811b3 | 2016-03-05 15:08:50 -0800 | [diff] [blame] | 333 | [AS_HELP_STRING([--enable-dynamic-sized-delete-support], |
| 334 | [try to build run-time switch for sized delete operator])], |
Aliaksey Kandratsenka | 6fdfc5a | 2015-10-24 23:16:45 -0700 | [diff] [blame] | 335 | [enable_dyn_sized_delete="$enableval"], |
Aliaksey Kandratsenka | 06811b3 | 2016-03-05 15:08:50 -0800 | [diff] [blame] | 336 | [enable_dyn_sized_delete=no]) |
Aliaksey Kandratsenka | 6fdfc5a | 2015-10-24 23:16:45 -0700 | [diff] [blame] | 337 | |
| 338 | AS_IF([test "x$enable_dyn_sized_delete" = xyes], |
| 339 | [AC_DEFINE([ENABLE_DYNAMIC_SIZED_DELETE], 1, |
| 340 | [Build runtime detection for sized delete])]) |
| 341 | |
Aliaksey Kandratsenka | a9db0ae | 2015-10-04 21:12:28 -0700 | [diff] [blame] | 342 | AC_ARG_ENABLE([sized-delete], |
| 343 | [AS_HELP_STRING([--enable-sized-delete], |
| 344 | [build sized delete operator])], |
| 345 | [enable_sized_delete="$enableval"], |
| 346 | [enable_sized_delete="no"]) |
| 347 | AS_IF([test "x$enable_sized_delete" = xyes], |
| 348 | [AC_DEFINE([ENABLE_SIZED_DELETE], 1, [Build sized deletion operators]) |
| 349 | AC_MSG_NOTICE([Will build sized deallocation operators])], |
Aliaksey Kandratsenka | 08e034a | 2016-02-06 16:19:54 -0800 | [diff] [blame] | 350 | [AS_IF([test "x$enable_dyn_sized_delete" = xyes], |
| 351 | [AC_MSG_NOTICE([Will build dynamically detected sized deallocation operators])], |
| 352 | [AC_MSG_NOTICE([Will not build sized deallocation operators])])]) |
Aliaksey Kandratsenka | a9db0ae | 2015-10-04 21:12:28 -0700 | [diff] [blame] | 353 | |
Aliaksey Kandratsenka | 782165f | 2016-03-05 15:47:25 -0800 | [diff] [blame] | 354 | AC_CACHE_CHECK([if C++ compiler supports -fsized-deallocation], |
| 355 | [perftools_cv_sized_deallocation_result], |
| 356 | [AC_LANG_PUSH(C++) |
| 357 | OLD_CXXFLAGS="$CXXFLAGS" |
| 358 | CXXFLAGS="$CXXFLAGS -fsized-deallocation" |
| 359 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], |
| 360 | perftools_cv_sized_deallocation_result=yes, |
| 361 | perftools_cv_sized_deallocation_result=no) |
| 362 | CXXFLAGS="$OLD_CXXFLAGS" |
| 363 | AC_LANG_POP(C++)]) |
Aliaksey Kandratsenka | a9db0ae | 2015-10-04 21:12:28 -0700 | [diff] [blame] | 364 | |
Aliaksey Kandratsenka | 8868697 | 2015-10-04 11:15:37 -0700 | [diff] [blame] | 365 | AM_CONDITIONAL(HAVE_SIZED_DEALLOCATION, |
| 366 | test "$perftools_cv_sized_deallocation_result" = yes) |
| 367 | |
Aliaksey Kandratsenka | 9095ed0 | 2016-02-20 20:33:27 -0800 | [diff] [blame] | 368 | AC_CACHE_CHECK([if target has _Unwind_Backtrace], |
| 369 | [perftools_cv_have_unwind_backtrace], |
| 370 | [AC_LANG_PUSH(C++) |
| 371 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 372 | [[#include <unwind.h>]], |
| 373 | [[&_Unwind_Backtrace]])], |
| 374 | [perftools_cv_have_unwind_backtrace=yes], |
| 375 | [perftools_cv_have_unwind_backtrace=no]) |
| 376 | AC_LANG_POP(C++)]) |
| 377 | AS_IF([test "x$perftools_cv_have_unwind_backtrace" = xyes], |
| 378 | [AC_DEFINE(HAVE_UNWIND_BACKTRACE, 1, [Whether <unwind.h> contains _Unwind_Backtrace])]) |
| 379 | |
Aliaksey Kandratsenka | 4f3410e | 2016-02-21 13:52:47 -0800 | [diff] [blame] | 380 | AS_IF([test "x$enable_backtrace" = xyes], |
| 381 | [default_emergency_malloc=yes], |
| 382 | [default_emergency_malloc=no]) |
| 383 | |
| 384 | AS_IF([test "x$will_use_libunwind" = xyes], |
| 385 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __arm__])], |
| 386 | [default_emergency_malloc=yes])]) |
| 387 | |
Aliaksey Kandratsenka | 7f12051 | 2016-01-31 23:17:50 -0800 | [diff] [blame] | 388 | AC_ARG_ENABLE([emergency-malloc], |
| 389 | [AS_HELP_STRING([--enable-emergency-malloc], |
| 390 | [build emergency malloc feature])], |
| 391 | [enable_emergency_malloc="$enableval"], |
Aliaksey Kandratsenka | 4f3410e | 2016-02-21 13:52:47 -0800 | [diff] [blame] | 392 | [enable_emergency_malloc="$default_emergency_malloc"]) |
Aliaksey Kandratsenka | 7f12051 | 2016-01-31 23:17:50 -0800 | [diff] [blame] | 393 | |
| 394 | AM_CONDITIONAL(BUILD_EMERGENCY_MALLOC, [test "x$enable_emergency_malloc" = xyes]) |
| 395 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 396 | # Defines PRIuS |
| 397 | AC_COMPILER_CHARACTERISTICS |
| 398 | |
csilvers | 49b74b9 | 2007-08-17 20:56:15 +0000 | [diff] [blame] | 399 | # Also make sure we get standard PRI... definitions, even with glibc. |
| 400 | # We have to use AH_VERBATIM because we need the #ifdef guard (gcc buglet) |
| 401 | AH_VERBATIM([__STDC_FORMAT_MACROS], |
| 402 | [/* C99 says: define this to get the PRI... macros from stdint.h */ |
| 403 | #ifndef __STDC_FORMAT_MACROS |
| 404 | # define __STDC_FORMAT_MACROS 1 |
| 405 | #endif]) |
| 406 | |
csilvers | 91fad38 | 2007-03-22 03:28:56 +0000 | [diff] [blame] | 407 | # Check if __builtin_stack_pointer() is available (for elfcore.h) |
| 408 | AC_MSG_CHECKING([for __builtin_stack_pointer()]) |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 409 | AC_LINK_IFELSE([AC_LANG_PROGRAM(, [void *sp = __builtin_stack_pointer()])], |
csilvers | 91fad38 | 2007-03-22 03:28:56 +0000 | [diff] [blame] | 410 | [AC_DEFINE(HAVE_BUILTIN_STACK_POINTER, 1, |
| 411 | Define to 1 if compiler supports __builtin_stack_pointer) |
| 412 | AC_MSG_RESULT([yes])], |
| 413 | [AC_MSG_RESULT([no])]) |
| 414 | |
chappedm@gmail.com | 84b983c | 2012-12-22 20:06:47 +0000 | [diff] [blame] | 415 | # Check for __builtin_expect() |
| 416 | AC_MSG_CHECKING([for __builtin_expect()]) |
| 417 | AC_LINK_IFELSE([AC_LANG_PROGRAM(, return __builtin_expect(main != 0, 1))], |
| 418 | [AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, |
| 419 | Define to 1 if compiler supports __builtin_expect) |
| 420 | AC_MSG_RESULT([yes])], |
| 421 | [AC_MSG_RESULT([no])]) |
| 422 | |
csilvers | a94d5f7 | 2009-12-02 18:15:13 +0000 | [diff] [blame] | 423 | # Check if __environ is available (for GetenvBeforeMain) |
| 424 | AC_MSG_CHECKING([for __environ]) |
| 425 | AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], |
| 426 | [char **env = __environ])], |
| 427 | [AC_DEFINE(HAVE___ENVIRON, 1, |
| 428 | [Define to 1 if compiler supports __environ]) |
| 429 | AC_MSG_RESULT([yes])], |
| 430 | [AC_MSG_RESULT([no])]) |
| 431 | |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 432 | # If we support __thread, that can speed up tcmalloc a bit. |
csilvers | 6fa2a25 | 2008-12-13 01:35:42 +0000 | [diff] [blame] | 433 | # Note, however, that our code tickles a bug in gcc < 4.1.2 |
| 434 | # involving TLS and -fPIC (which our libraries will use) on x86: |
| 435 | # http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html |
alkondratenko@gmail.com | 7896dcb | 2013-03-11 19:16:47 +0000 | [diff] [blame] | 436 | # |
| 437 | # And mingw also does compile __thread but resultant code actually |
| 438 | # fails to work correctly at least in some not so ancient version: |
| 439 | # http://mingw-users.1079350.n2.nabble.com/gcc-4-4-multi-threaded-exception-handling-amp-thread-specifier-not-working-td3440749.html |
xiaoyur347 | 60b1217 | 2014-01-11 11:39:53 +0800 | [diff] [blame] | 440 | # |
| 441 | # Also it was reported that earlier gcc versions for mips compile |
| 442 | # __thread but it doesn't really work |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 443 | AC_MSG_CHECKING([for __thread]) |
xiaoyur347 | 60b1217 | 2014-01-11 11:39:53 +0800 | [diff] [blame] | 444 | AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2)) |
csilvers | 6fa2a25 | 2008-12-13 01:35:42 +0000 | [diff] [blame] | 445 | #error gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html |
Aliaksey Kandratsenka | 819a2b0 | 2013-08-29 19:00:31 +0300 | [diff] [blame] | 446 | #elif defined(__MINGW32__) |
Aliaksey Kandratsenka | e983715 | 2014-01-11 16:28:15 -0800 | [diff] [blame] | 447 | #error mingw doesnt really support tls |
Aliaksey Kandratsenka | 819a2b0 | 2013-08-29 19:00:31 +0300 | [diff] [blame] | 448 | #elif defined(__APPLE__) |
| 449 | #error OSX __thread support is known to call malloc which makes it unsafe to use from malloc replacement |
alkondratenko@gmail.com | 7896dcb | 2013-03-11 19:16:47 +0000 | [diff] [blame] | 450 | #endif |
| 451 | ], [static __thread int p = 0])], |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 452 | [AC_DEFINE(HAVE_TLS, 1, |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 453 | Define to 1 if compiler supports __thread) |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 454 | AC_MSG_RESULT([yes])], |
| 455 | [AC_MSG_RESULT([no])]) |
| 456 | |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 457 | # glibc's __malloc_hook/etc were declared volatile starting in glibc 2.14 |
| 458 | AC_MSG_CHECKING([if __malloc_hook is declared volatile]) |
| 459 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <malloc.h> |
| 460 | void* (* volatile __malloc_hook)(size_t, const void*) = 0;],)], |
| 461 | [AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, volatile, |
| 462 | Define to 'volatile' if __malloc_hook is declared volatile) |
| 463 | AC_MSG_RESULT([yes])], |
csilvers | d2faf46 | 2011-07-27 04:18:01 +0000 | [diff] [blame] | 464 | [AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, ) |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 465 | AC_MSG_RESULT([no])]) |
| 466 | |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 467 | # Nanosleep requires extra libraries on some architectures (solaris). |
| 468 | # This sets NANOSLEEP_LIBS. nanosleep doesn't exist on mingw, which |
| 469 | # is fine for us because we don't compile libspinlock, which uses it. |
| 470 | if test "$need_nanosleep" = yes; then |
| 471 | ACX_NANOSLEEP |
| 472 | AC_SUBST(NANOSLEEP_LIBS) |
| 473 | fi |
| 474 | |
| 475 | # Solaris 10 6/06 has a bug where /usr/sfw/lib/libstdc++.la is empty. |
| 476 | # If so, we replace it with our own version. |
| 477 | LIBSTDCXX_LA_LINKER_FLAG= |
| 478 | if test -f /usr/sfw/lib/libstdc++.la && ! test -s /usr/sfw/lib/libstdc++.la |
| 479 | then |
| 480 | LIBSTDCXX_LA_LINKER_FLAG='-L$(top_srcdir)/src/solaris' |
| 481 | fi |
| 482 | AC_SUBST(LIBSTDCXX_LA_LINKER_FLAG) |
| 483 | |
csilvers | 74ad5d5 | 2007-04-16 20:49:32 +0000 | [diff] [blame] | 484 | # We also need to check if the kernel supports __thread, which requires uname() |
| 485 | AC_CHECK_DECLS(uname,,, [#include <sys/utsname.h>]) |
| 486 | |
| 487 | # In fact, a lot of the code in this directory depends on pthreads |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 488 | ACX_PTHREAD |
| 489 | |
Aliaksey Kandratsenka | 4c274b9 | 2014-01-04 18:28:36 -0800 | [diff] [blame] | 490 | AC_LANG_SAVE |
| 491 | AC_LANG_CPLUSPLUS |
| 492 | AC_MSG_CHECKING([whether pthread symbols are available in C++ without including pthread.h]) |
| 493 | acx_pthread_despite_asking_for=no |
| 494 | AC_LINK_IFELSE( |
| 495 | [AC_LANG_PROGRAM([ |
| 496 | #include <string> |
| 497 | #include <vector> |
| 498 | ],[ |
| 499 | pthread_t th; pthread_join(th, 0); |
| 500 | ])],[ |
| 501 | acx_pthread_despite_asking_for=yes |
| 502 | AC_DEFINE(HAVE_PTHREAD_DESPITE_ASKING_FOR, 1, [defined to 1 if pthread symbols are exposed even without include pthread.h]) |
| 503 | AC_DEFINE(HAVE_PTHREAD, 1, []) |
| 504 | ]) |
| 505 | AC_MSG_RESULT([$acx_pthread_despite_asking_for]) |
| 506 | AC_LANG_RESTORE |
| 507 | |
Thomas Klausner | fd3379a | 2014-02-25 21:41:07 +0100 | [diff] [blame] | 508 | AM_CONDITIONAL(HAVE_PTHREAD_DESPITE_ASKING_FOR, test x"$acx_pthread_despite_asking_for" = xyes) |
Aliaksey Kandratsenka | 4c274b9 | 2014-01-04 18:28:36 -0800 | [diff] [blame] | 509 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 510 | # Find out what namespace 'normal' STL code lives in |
| 511 | AC_CXX_STL_NAMESPACE |
| 512 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 513 | # Figure out where libc has program_invocation_name |
| 514 | AC_PROGRAM_INVOCATION_NAME |
| 515 | |
| 516 | # Make the install prefix available, to figure out where to look for pprof |
| 517 | AC_INSTALL_PREFIX |
| 518 | |
alkondratenko@gmail.com | d8e12e9 | 2013-07-20 21:35:14 +0000 | [diff] [blame] | 519 | dnl only very recent mingw has sleep and nanosleep |
| 520 | case "$host" in |
| 521 | *-mingw*) |
| 522 | AC_CHECK_DECLS([sleep], [], [], [#include <unistd.h>]) |
| 523 | AC_CHECK_DECLS([nanosleep], [], [], [#include <time.h>]) |
| 524 | ;; |
| 525 | esac |
| 526 | |
Aliaksey Kandratsenka | 125e5ed | 2014-04-12 12:38:19 -0700 | [diff] [blame] | 527 | if test "x$enable_backtrace" = xyes; then |
| 528 | AC_CHECK_DECLS([backtrace], [], [], [#include <execinfo.h>]) |
| 529 | fi |
alkondratenko@gmail.com | d8e12e9 | 2013-07-20 21:35:14 +0000 | [diff] [blame] | 530 | |
csilvers | c437e1f | 2007-07-18 18:30:50 +0000 | [diff] [blame] | 531 | # For windows, this has a non-trivial value (__declspec(export)), but any |
| 532 | # system that uses configure wants this to be the empty string. |
| 533 | AC_DEFINE(PERFTOOLS_DLL_DECL,, |
| 534 | [Always the empty-string on non-windows systems. |
| 535 | On windows, should be "__declspec(dllexport)". |
| 536 | This way, when we compile the dll, we export our functions/classes. |
| 537 | It's safe to define this here because config.h is only used |
| 538 | internally, to compile the DLL, and every DLL source file |
| 539 | #includes "config.h" before anything else.]) |
| 540 | |
csilvers | cb7393c | 2010-06-21 15:59:56 +0000 | [diff] [blame] | 541 | # In theory, config.h files shouldn't need a header guard, but we do, |
| 542 | # because we (maybe) #include windows/mingw.h from within config.h, |
| 543 | # and it #includes other .h files. These all have header guards, so |
| 544 | # the end result is if config.h is #included twice, its #undefs get |
| 545 | # evaluated twice, but all the ones in mingw.h/etc only get evaluated |
| 546 | # once, potentially causing trouble. c.f. |
csilvers | 4e9432c | 2012-02-04 00:07:36 +0000 | [diff] [blame] | 547 | # http://code.google.com/p/gperftools/issues/detail?id=246 |
csilvers | cb7393c | 2010-06-21 15:59:56 +0000 | [diff] [blame] | 548 | AH_TOP([ |
csilvers | 4e9432c | 2012-02-04 00:07:36 +0000 | [diff] [blame] | 549 | #ifndef GPERFTOOLS_CONFIG_H_ |
| 550 | #define GPERFTOOLS_CONFIG_H_ |
csilvers | cb7393c | 2010-06-21 15:59:56 +0000 | [diff] [blame] | 551 | ]) |
| 552 | |
csilvers | c2eedce | 2011-08-26 21:08:59 +0000 | [diff] [blame] | 553 | AH_VERBATIM([PTHREADS_CRASHES_IF_RUN_TOO_EARLY], |
| 554 | [/* Mark the systems where we know it's bad if pthreads runs too |
| 555 | early before main (before threads are initialized, presumably). */ |
| 556 | #ifdef __FreeBSD__ |
| 557 | #define PTHREADS_CRASHES_IF_RUN_TOO_EARLY 1 |
| 558 | #endif]) |
| 559 | |
csilvers | 11b02f7 | 2007-11-29 23:39:24 +0000 | [diff] [blame] | 560 | # MinGW uses autoconf, but also needs the windows shim routines |
| 561 | # (since it doesn't have its own support for, say, pthreads). |
| 562 | # This requires us to #include a special header file, and also to |
| 563 | # link in some windows versions of .o's instead of the unix versions. |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 564 | # |
| 565 | # Also, manually mark systems where we have to be careful how early |
| 566 | # we run pthreads. TODO(csilvers): turn this into an autoconf check. |
csilvers | 11b02f7 | 2007-11-29 23:39:24 +0000 | [diff] [blame] | 567 | AH_BOTTOM([ |
| 568 | #ifdef __MINGW32__ |
| 569 | #include "windows/mingw.h" |
| 570 | #endif |
csilvers | cb7393c | 2010-06-21 15:59:56 +0000 | [diff] [blame] | 571 | |
csilvers | 4e9432c | 2012-02-04 00:07:36 +0000 | [diff] [blame] | 572 | #endif /* #ifndef GPERFTOOLS_CONFIG_H_ */ |
csilvers | 11b02f7 | 2007-11-29 23:39:24 +0000 | [diff] [blame] | 573 | ]) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 574 | AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1) |
csilvers | 100c38c | 2011-07-16 01:07:10 +0000 | [diff] [blame] | 575 | AM_CONDITIONAL(OSX, expr $host : '.*-apple-darwin.*' >/dev/null 2>&1) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 576 | |
| 577 | # Export the --enable flags we set above. We do this at the end so |
| 578 | # other configure rules can enable or disable targets based on what |
| 579 | # they find. |
| 580 | AM_CONDITIONAL(WITH_CPU_PROFILER, test "$enable_cpu_profiler" = yes) |
| 581 | AM_CONDITIONAL(WITH_HEAP_PROFILER, test "$enable_heap_profiler" = yes) |
| 582 | AM_CONDITIONAL(WITH_HEAP_CHECKER, test "$enable_heap_checker" = yes) |
csilvers | 19dfa9e | 2009-09-11 18:42:32 +0000 | [diff] [blame] | 583 | AM_CONDITIONAL(WITH_DEBUGALLOC, test "$enable_debugalloc" = yes) |
csilvers | edd03a8 | 2009-03-11 20:50:03 +0000 | [diff] [blame] | 584 | # We make tcmalloc.so if either heap-profiler or heap-checker is asked for. |
| 585 | AM_CONDITIONAL(WITH_HEAP_PROFILER_OR_CHECKER, |
| 586 | test "$enable_heap_profiler" = yes -o \ |
| 587 | "$enable_heap_checker" = yes) |
| 588 | # If we don't use any profilers, we don't need stack traces (or pprof) |
| 589 | AM_CONDITIONAL(WITH_STACK_TRACE, test "$enable_cpu_profiler" = yes -o \ |
| 590 | "$enable_heap_profiler" = yes -o \ |
| 591 | "$enable_heap_checker" = yes) |
csilvers | 11b02f7 | 2007-11-29 23:39:24 +0000 | [diff] [blame] | 592 | |
Aliaksey Kandratsenka | 1108d83 | 2014-09-07 13:09:14 -0700 | [diff] [blame] | 593 | have_linux_sigev_thread_id=no |
| 594 | AC_MSG_CHECKING([for Linux SIGEV_THREAD_ID]) |
| 595 | AC_COMPILE_IFELSE( |
| 596 | [AC_LANG_PROGRAM([[#include <signal.h> |
| 597 | #include <time.h>]], |
| 598 | [[return SIGEV_THREAD_ID || CLOCK_THREAD_CPUTIME_ID || __linux;]])], |
| 599 | [AC_DEFINE(HAVE_LINUX_SIGEV_THREAD_ID, 1, |
| 600 | [Define if this is Linux that has SIGEV_THREAD_ID]) |
| 601 | have_linux_sigev_thread_id=yes |
| 602 | AC_MSG_RESULT([yes])], |
| 603 | [AC_MSG_RESULT([no])]) |
| 604 | |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 605 | # Write generated configuration file |
csilvers | 4e9432c | 2012-02-04 00:07:36 +0000 | [diff] [blame] | 606 | AC_CONFIG_FILES([Makefile |
| 607 | src/gperftools/tcmalloc.h src/windows/gperftools/tcmalloc.h]) |
csilvers | 51b4875 | 2007-03-22 03:00:33 +0000 | [diff] [blame] | 608 | AC_OUTPUT |
Aliaksey Kandratsenka | b5e584d | 2014-02-16 19:41:37 -0800 | [diff] [blame] | 609 | |
Aliaksey Kandratsenka | 125e5ed | 2014-04-12 12:38:19 -0700 | [diff] [blame] | 610 | 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], |
Aliaksey Kandratsenka | 9095ed0 | 2016-02-20 20:33:27 -0800 | [diff] [blame] | 611 | [AS_IF([test "x$perftools_cv_have_unwind_backtrace" = xyes], |
| 612 | [AC_MSG_WARN([No frame pointers and no libunwind. Using experimental backtrace capturing via libgcc])], |
| 613 | [AS_IF([test "x$enable_backtrace" = xyes], |
Aliaksey Kandratsenka | 7f12051 | 2016-01-31 23:17:50 -0800 | [diff] [blame] | 614 | [AC_MSG_WARN([No frame pointers and no libunwind. Using experimental backtrace()])], |
Aliaksey Kandratsenka | 9095ed0 | 2016-02-20 20:33:27 -0800 | [diff] [blame] | 615 | [AC_MSG_FAILURE([No frame pointers and no libunwind. The compilation will fail])])])]) |