PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/libs/perftools/src/configure.ac

http://jslibs.googlecode.com/
m4 | 319 lines | 204 code | 34 blank | 81 comment | 0 complexity | 633fffd1d658f9d819a2e38b14e0842a MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0, GPL-3.0, GPL-2.0, AGPL-3.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, LGPL-2.0
  1. ## Process this file with autoconf to produce configure.
  2. ## In general, the safest way to proceed is to run ./autogen.sh
  3. # make sure we're interpreted by some minimal autoconf
  4. AC_PREREQ(2.57)
  5. AC_INIT(google-perftools, 1.3, opensource@google.com)
  6. # The argument here is just something that should be in the current directory
  7. # (for sanity checking)
  8. AC_CONFIG_SRCDIR(README)
  9. AC_CANONICAL_HOST
  10. AM_INIT_AUTOMAKE([dist-zip])
  11. AM_CONFIG_HEADER(src/config.h)
  12. # The user can choose not to compile in the heap-profiler, the
  13. # heap-checker, or the cpu-profiler. There's also the possibility
  14. # for a 'fully minimal' compile, which leaves out the stacktrace
  15. # code as well. By default, we include all of these that the
  16. # target system supports.
  17. default_enable_cpu_profiler=yes
  18. default_enable_heap_profiler=yes
  19. default_enable_heap_checker=yes
  20. default_enable_minimal=no
  21. need_nanosleep=yes # Used later, to decide if to run ACX_NANOSLEEP
  22. case "$host" in
  23. *-mingw*) default_enable_minimal=yes; need_nanosleep=no;;
  24. *-cygwin*) default_enable_heap_checker=no; default_enable_cpu_profiler=no;;
  25. *-freebsd*) default_enable_heap_checker=no;;
  26. *-darwin*) default_enable_heap_checker=no;;
  27. esac
  28. AC_ARG_ENABLE([cpu-profiler],
  29. [AS_HELP_STRING([--disable-cpu-profiler],
  30. [do not build the cpu profiler])],
  31. [],
  32. [enable_cpu_profiler="$default_enable_cpu_profiler"])
  33. AC_ARG_ENABLE([heap-profiler],
  34. [AS_HELP_STRING([--disable-heap-profiler],
  35. [do not build the heap profiler])],
  36. [],
  37. [enable_heap_profiler="$default_enable_heap_profiler"])
  38. AC_ARG_ENABLE([heap-checker],
  39. [AS_HELP_STRING([--disable-heap-checker],
  40. [do not build the heap checker])],
  41. [],
  42. [enable_heap_checker="$default_enable_heap_checker"])
  43. AC_ARG_ENABLE([minimal],
  44. [AS_HELP_STRING([--enable-minimal],
  45. [build only tcmalloc-minimal])],
  46. [],
  47. [enable_minimal="$default_enable_minimal"])
  48. if test "$enable_minimal" = yes; then
  49. enable_cpu_profiler=no
  50. enable_heap_profiler=no
  51. enable_heap_checker=no
  52. fi
  53. # Checks for programs.
  54. AC_PROG_CC
  55. AC_PROG_CPP
  56. AC_PROG_CXX
  57. AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
  58. AM_PROG_CC_C_O # shrug: autogen.sh suddenly needs this for some reason
  59. # We work behind libtool's back, replacing 'ar' by 'ld -r' in some
  60. # situations. The only issue is that 'ld -r' output doesn't support
  61. # ranlib. Nobody needs ranlib anymore, so it's safe to just disable it.
  62. RANLIB=":"
  63. # Check if we have an objcopy installed that supports -W
  64. AC_CHECK_TOOL([OBJCOPY], [objcopy], [])
  65. AM_CONDITIONAL(HAVE_OBJCOPY_WEAKEN, ["$OBJCOPY" -W malloc /bin/ls /dev/null])
  66. case $host_os in
  67. *mingw*)
  68. # Disabling fast install keeps libtool from creating wrapper scripts
  69. # around the executables it builds. Such scripts have caused failures on
  70. # MinGW. Using this option means an extra link step is executed during
  71. # "make install".
  72. AC_DISABLE_FAST_INSTALL
  73. ;;
  74. *)
  75. AC_ENABLE_FAST_INSTALL
  76. ;;
  77. esac
  78. AC_PROG_LIBTOOL
  79. AC_SUBST(LIBTOOL_DEPS)
  80. AM_CONDITIONAL(USE_LIBTOOL, test "x$LIBTOOL" != "x")
  81. AC_C_INLINE
  82. AX_C___ATTRIBUTE__
  83. # Check whether some low-level functions/files are available
  84. AC_HEADER_STDC
  85. # TODO(csilvers): we could remove a lot when WITH_CPU_PROFILER etc is "no".
  86. AC_CHECK_TYPES([__int64]) # defined in some windows platforms
  87. AC_CHECK_TYPES([struct mallinfo],,, [#include <malloc.h>])
  88. AC_CHECK_TYPES([Elf32_Versym],,, [#include <elf.h>]) # for vdso_support.h
  89. AC_CHECK_FUNCS(sbrk) # for tcmalloc to get memory
  90. AC_CHECK_FUNCS(geteuid) # for turning off services when run as root
  91. AC_CHECK_HEADERS(features.h) # for vdso_support.h
  92. AC_CHECK_HEADERS(malloc.h) # some systems define stuff there, others not
  93. AC_CHECK_HEADERS(glob.h) # for heap-profile-table (cleaning up profiles)
  94. AC_CHECK_HEADERS(execinfo.h) # for stacktrace? and heapchecker_unittest
  95. AC_CHECK_HEADERS(libunwind.h) # for stacktrace
  96. AC_CHECK_HEADERS(unwind.h) # for stacktrace
  97. AC_CHECK_HEADERS(sched.h) # for being nice in our spinlock code
  98. AC_CHECK_HEADERS(ucontext.h) # for profiler.cc (cpu profiler)
  99. AC_CHECK_HEADERS(conflict-signal.h) # defined on some windows platforms
  100. AC_CHECK_HEADERS(sys/prctl.h) # for thread_lister (needed by leak-checker)
  101. AC_CHECK_HEADERS(linux/ptrace.h)# also needed by leak-checker
  102. AC_CHECK_HEADERS(sys/syscall.h)
  103. AC_CHECK_HEADERS(sys/socket.h) # optional; for forking out to symbolizer
  104. AC_CHECK_HEADERS(sys/wait.h) # optional; for forking out to symbolizer
  105. AC_CHECK_HEADERS(fcntl.h) # for tcmalloc_unittest
  106. AC_CHECK_HEADERS(grp.h) # for heapchecker_unittest
  107. AC_CHECK_HEADERS(pwd.h) # for heapchecker_unittest
  108. AC_CHECK_HEADERS(sys/resource.h) # for memalign_unittest.cc
  109. # We override a lot of memory allocation routines, not all of which are
  110. # standard. For those the system doesn't declare, we'll declare ourselves.
  111. AC_CHECK_DECLS([cfree,
  112. posix_memalign,
  113. memalign,
  114. valloc,
  115. pvalloc],,,
  116. [#define _XOPEN_SOURCE 600
  117. #include <stdlib.h>
  118. #include <malloc.h>])
  119. if test "$ac_cv_type_struct_mallinfo" = yes; then
  120. AC_SUBST(ac_cv_have_struct_mallinfo, 1) # google/tcmalloc.h needs this
  121. else
  122. AC_SUBST(ac_cv_have_struct_mallinfo, 0)
  123. fi
  124. # We need to check for mmap. cygwin supports mmap, but the autoconf
  125. # test doesn't work on cygwin:
  126. # http://www.cygwin.com/ml/cygwin/2002-04/msg00412.html
  127. # This workaround comes from
  128. # http://cygwin.com/ml/cygwin/2004-11/msg00138.html
  129. case "$host" in
  130. *-*-cygwin*) ac_cv_func_mmap_fixed_mapped=yes
  131. AC_DEFINE(HAVE_MMAP, 1,
  132. [Define to 1 if you have a working `mmap' system call.])
  133. ;;
  134. *) AC_FUNC_MMAP
  135. ;;
  136. esac
  137. # If AtomicWord != Atomic32, we need to define two versions of all the
  138. # atomicops functions. If they're the same, we want to define only one.
  139. AC_MSG_CHECKING([if int32_t is the same type as intptr_t])
  140. AC_TRY_COMPILE([#include <stdint.h>],
  141. [int32_t v1 = 0; intptr_t v2 = 0; return (&v1 - &v2)],
  142. [AC_DEFINE(INT32_EQUALS_INTPTR, 1,
  143. Define to 1 if int32_t is equivalent to intptr_t)
  144. AC_MSG_RESULT([yes])],
  145. [AC_MSG_RESULT([no])])
  146. # We want to access the "PC" (Program Counter) register from a struct
  147. # ucontext. Every system has its own way of doing that. We try all the
  148. # possibilities we know about. Note REG_PC should come first (REG_RIP
  149. # is also defined on solaris, but does the wrong thing). But don't
  150. # bother if we're not doing cpu-profiling.
  151. # [*] means that we've not actually tested one of these systems
  152. if test "$enable_cpu_profiler" = yes; then
  153. AC_MSG_CHECKING([how to access the program counter from a struct ucontext])
  154. pc_fields=" uc_mcontext.gregs[[REG_PC]]" # Solaris x86 (32+64 bit)
  155. pc_fields="$pc_fields uc_mcontext.gregs[[REG_EIP]]" # Linux (i386)
  156. pc_fields="$pc_fields uc_mcontext.gregs[[REG_RIP]]" # Linux (x86_64)
  157. pc_fields="$pc_fields uc_mcontext.sc_ip" # Linux (ia64)
  158. pc_fields="$pc_fields uc_mcontext.uc_regs->gregs[[PT_NIP]]" # Linux (ppc)
  159. pc_fields="$pc_fields uc_mcontext.mc_eip" # FreeBSD (i386)
  160. pc_fields="$pc_fields uc_mcontext.mc_rip" # FreeBSD (x86_64 [*])
  161. pc_fields="$pc_fields uc_mcontext->ss.eip" # OS X (i386, <=10.4)
  162. pc_fields="$pc_fields uc_mcontext->__ss.__eip" # OS X (i386, >=10.5)
  163. pc_fields="$pc_fields uc_mcontext->ss.rip" # OS X (x86_64)
  164. pc_fields="$pc_fields uc_mcontext->__ss.__rip" # OS X (x86_64>=10.5 [*])
  165. pc_fields="$pc_fields uc_mcontext->ss.srr0" # OS X (ppc, ppc64 [*])
  166. pc_fields="$pc_fields uc_mcontext->__ss.__srr0" # OS X (ppc>=10.5 [*])
  167. pc_field_found=false
  168. for pc_field in $pc_fields; do
  169. if ! $pc_field_found; then
  170. AC_TRY_COMPILE([#define _GNU_SOURCE 1
  171. #include <ucontext.h>],
  172. [ucontext_t u; return u.$pc_field == 0;],
  173. AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
  174. How to access the PC from a struct ucontext)
  175. AC_MSG_RESULT([$pc_field])
  176. pc_field_found=true)
  177. fi
  178. done
  179. if ! $pc_field_found; then
  180. AC_MSG_WARN(Could not find the PC. Will not try to compile libprofiler...)
  181. enable_cpu_profiler=no
  182. fi
  183. fi
  184. # We want to link in libunwind if it exists
  185. AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind, UNWIND_LIBS=)
  186. AC_SUBST(UNWIND_LIBS)
  187. # On x86_64, instead of libunwind, we can choose to compile with frame-pointers
  188. # (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
  189. AC_ARG_ENABLE(frame_pointers,
  190. AS_HELP_STRING([--enable-frame-pointers],
  191. [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),
  192. , enable_frame_pointers=no)
  193. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
  194. [is_x86_64=yes], [is_x86_64=no])
  195. AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
  196. AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
  197. # Defines PRIuS
  198. AC_COMPILER_CHARACTERISTICS
  199. # Also make sure we get standard PRI... definitions, even with glibc.
  200. # We have to use AH_VERBATIM because we need the #ifdef guard (gcc buglet)
  201. AH_VERBATIM([__STDC_FORMAT_MACROS],
  202. [/* C99 says: define this to get the PRI... macros from stdint.h */
  203. #ifndef __STDC_FORMAT_MACROS
  204. # define __STDC_FORMAT_MACROS 1
  205. #endif])
  206. # Check if __builtin_stack_pointer() is available (for elfcore.h)
  207. AC_MSG_CHECKING([for __builtin_stack_pointer()])
  208. AC_LINK_IFELSE([AC_LANG_PROGRAM(, [void *sp = __builtin_stack_pointer()])],
  209. [AC_DEFINE(HAVE_BUILTIN_STACK_POINTER, 1,
  210. Define to 1 if compiler supports __builtin_stack_pointer)
  211. AC_MSG_RESULT([yes])],
  212. [AC_MSG_RESULT([no])])
  213. # If we support __thread, that can speed up tcmalloc a bit.
  214. # Note, however, that our code tickles a bug in gcc < 4.1.2
  215. # involving TLS and -fPIC (which our libraries will use) on x86:
  216. # http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
  217. AC_MSG_CHECKING([for __thread])
  218. AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2))
  219. #error gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
  220. #endif], [static __thread int p = 0])],
  221. [AC_DEFINE(HAVE_TLS, 1,
  222. Define to 1 if compiler supports __thread)
  223. AC_MSG_RESULT([yes])],
  224. [AC_MSG_RESULT([no])])
  225. # Nanosleep requires extra libraries on some architectures (solaris).
  226. # This sets NANOSLEEP_LIBS. nanosleep doesn't exist on mingw, which
  227. # is fine for us because we don't compile libspinlock, which uses it.
  228. if test "$need_nanosleep" = yes; then
  229. ACX_NANOSLEEP
  230. AC_SUBST(NANOSLEEP_LIBS)
  231. fi
  232. # Solaris 10 6/06 has a bug where /usr/sfw/lib/libstdc++.la is empty.
  233. # If so, we replace it with our own version.
  234. LIBSTDCXX_LA_LINKER_FLAG=
  235. if test -f /usr/sfw/lib/libstdc++.la && ! test -s /usr/sfw/lib/libstdc++.la
  236. then
  237. LIBSTDCXX_LA_LINKER_FLAG='-L$(top_srcdir)/src/solaris'
  238. fi
  239. AC_SUBST(LIBSTDCXX_LA_LINKER_FLAG)
  240. # We also need to check if the kernel supports __thread, which requires uname()
  241. AC_CHECK_DECLS(uname,,, [#include <sys/utsname.h>])
  242. # In fact, a lot of the code in this directory depends on pthreads
  243. ACX_PTHREAD
  244. # Find out what namespace 'normal' STL code lives in
  245. AC_CXX_STL_NAMESPACE
  246. # Figure out where libc has program_invocation_name
  247. AC_PROGRAM_INVOCATION_NAME
  248. # Make the install prefix available, to figure out where to look for pprof
  249. AC_INSTALL_PREFIX
  250. # For windows, this has a non-trivial value (__declspec(export)), but any
  251. # system that uses configure wants this to be the empty string.
  252. AC_DEFINE(PERFTOOLS_DLL_DECL,,
  253. [Always the empty-string on non-windows systems.
  254. On windows, should be "__declspec(dllexport)".
  255. This way, when we compile the dll, we export our functions/classes.
  256. It's safe to define this here because config.h is only used
  257. internally, to compile the DLL, and every DLL source file
  258. #includes "config.h" before anything else.])
  259. # MinGW uses autoconf, but also needs the windows shim routines
  260. # (since it doesn't have its own support for, say, pthreads).
  261. # This requires us to #include a special header file, and also to
  262. # link in some windows versions of .o's instead of the unix versions.
  263. AH_BOTTOM([
  264. #ifdef __MINGW32__
  265. #include "windows/mingw.h"
  266. #endif
  267. ])
  268. AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
  269. # Export the --enable flags we set above. We do this at the end so
  270. # other configure rules can enable or disable targets based on what
  271. # they find.
  272. AM_CONDITIONAL(WITH_CPU_PROFILER, test "$enable_cpu_profiler" = yes)
  273. AM_CONDITIONAL(WITH_HEAP_PROFILER, test "$enable_heap_profiler" = yes)
  274. AM_CONDITIONAL(WITH_HEAP_CHECKER, test "$enable_heap_checker" = yes)
  275. # We make tcmalloc.so if either heap-profiler or heap-checker is asked for.
  276. AM_CONDITIONAL(WITH_HEAP_PROFILER_OR_CHECKER,
  277. test "$enable_heap_profiler" = yes -o \
  278. "$enable_heap_checker" = yes)
  279. # If we don't use any profilers, we don't need stack traces (or pprof)
  280. AM_CONDITIONAL(WITH_STACK_TRACE, test "$enable_cpu_profiler" = yes -o \
  281. "$enable_heap_profiler" = yes -o \
  282. "$enable_heap_checker" = yes)
  283. # Write generated configuration file
  284. AC_CONFIG_FILES([Makefile src/google/tcmalloc.h])
  285. AC_OUTPUT