configure.in 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. define(pkg_major, 1)
  2. define(pkg_minor, 0)
  3. define(pkg_extra, )
  4. define(pkg_maintainer, libunwind-devel@nongnu.org)
  5. define(mkvers, $1.$2$3)
  6. dnl Process this file with autoconf to produce a configure script.
  7. AC_INIT(libunwind, mkvers(pkg_major, pkg_minor, pkg_extra), pkg_maintainer)
  8. AC_CONFIG_SRCDIR(src/mi/backtrace.c)
  9. AC_CONFIG_AUX_DIR(config)
  10. AC_CANONICAL_SYSTEM
  11. AM_INIT_AUTOMAKE([1.6 subdir-objects])
  12. AM_MAINTAINER_MODE
  13. AM_CONFIG_HEADER(include/config.h)
  14. dnl Checks for programs.
  15. AC_PROG_CC
  16. AC_PROG_CXX
  17. AC_PROG_INSTALL
  18. AC_PROG_MAKE_SET
  19. AM_PROG_LIBTOOL
  20. AM_PROG_AS
  21. AM_PROG_CC_C_O
  22. dnl Checks for libraries.
  23. AC_CHECK_LIB(uca, __uc_get_grs)
  24. OLD_LIBS=${LIBS}
  25. AC_SEARCH_LIBS(dlopen, dl)
  26. LIBS=${OLD_LIBS}
  27. case "$ac_cv_search_dlopen" in
  28. -l*) DLLIB=$ac_cv_search_dlopen;;
  29. *) DLLIB="";;
  30. esac
  31. CHECK_ATOMIC_OPS
  32. dnl Checks for header files.
  33. AC_HEADER_STDC
  34. AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
  35. ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
  36. sys/procfs.h sys/ptrace.h byteswap.h)
  37. dnl Checks for typedefs, structures, and compiler characteristics.
  38. AC_C_CONST
  39. AC_C_INLINE
  40. AC_TYPE_SIGNAL
  41. AC_TYPE_SIZE_T
  42. AC_CHECK_SIZEOF(off_t)
  43. CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
  44. AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
  45. AC_CHECK_TYPES([sighandler_t], [], [],
  46. [$ac_includes_default
  47. #if HAVE_SIGNAL_H
  48. # include <signal.h>
  49. #endif
  50. ])
  51. AC_CHECK_TYPES([struct elf_prstatus, struct prstatus], [], [],
  52. [$ac_includes_default
  53. #if HAVE_SYS_PROCFS_H
  54. # include <sys/procfs.h>
  55. #endif
  56. ])
  57. AC_CHECK_DECLS([PTRACE_POKEUSER, PTRACE_POKEDATA,
  58. PTRACE_TRACEME, PTRACE_CONT, PTRACE_SINGLESTEP,
  59. PTRACE_SYSCALL, PT_IO, PT_GETREGS,
  60. PT_GETFPREGS, PT_CONTINUE, PT_TRACE_ME,
  61. PT_STEP, PT_SYSCALL], [], [],
  62. [$ac_includes_default
  63. #if HAVE_SYS_TYPES_H
  64. #include <sys/types.h>
  65. #endif
  66. #include <sys/ptrace.h>
  67. ])
  68. dnl Checks for library functions.
  69. AC_FUNC_MEMCMP
  70. AC_TYPE_SIGNAL
  71. AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
  72. ttrace mincore)
  73. is_gcc_m64() {
  74. if test `echo $CFLAGS | grep "\-m64" -c` -eq 1 ; then echo ppc64;
  75. else
  76. if test `echo $CC | grep "\-m64" -c` -eq 1 ; then echo ppc64; else echo ppc32; fi;
  77. fi;
  78. }
  79. is_gcc_altivec() {
  80. if test `echo $CFLAGS | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec;
  81. else
  82. if test `echo $CC | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec; else echo no_altivec; fi;
  83. fi;
  84. }
  85. AC_MSG_CHECKING([if building with AltiVec])
  86. use_altivec=`is_gcc_altivec`
  87. AM_CONDITIONAL(USE_ALTIVEC, test x$use_altivec = xhas_altivec)
  88. if test x$use_altivec = xhas_altivec; then
  89. AC_MSG_RESULT([yes])
  90. else
  91. AC_MSG_RESULT([no])
  92. fi
  93. get_arch() {
  94. case "$1" in
  95. arm*) echo arm;;
  96. i?86) echo x86;;
  97. hppa*) echo hppa;;
  98. mips*) echo mips;;
  99. powerpc*) is_gcc_m64;;
  100. amd64) echo x86_64;;
  101. *) echo $1;;
  102. esac
  103. }
  104. build_arch=`get_arch $build_cpu`
  105. host_arch=`get_arch $host_cpu`
  106. target_arch=`get_arch $target_cpu`
  107. AC_MSG_CHECKING([for build architecture])
  108. AC_MSG_RESULT([$build_arch])
  109. AC_MSG_CHECKING([for host architecture])
  110. AC_MSG_RESULT([$host_arch])
  111. AC_MSG_CHECKING([for target architecture])
  112. AC_MSG_RESULT([$target_arch])
  113. AC_MSG_CHECKING([for target operating system])
  114. AC_MSG_RESULT([$target_os])
  115. AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
  116. AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
  117. AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
  118. AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
  119. AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
  120. AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
  121. AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
  122. AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
  123. AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
  124. AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
  125. AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
  126. AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
  127. AC_MSG_CHECKING([for ELF helper width])
  128. case "${target_arch}" in
  129. (arm|hppa|ppc32|x86) use_elf32=yes; AC_MSG_RESULT([32]);;
  130. (ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
  131. (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
  132. *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
  133. esac
  134. AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
  135. AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes])
  136. AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes])
  137. AC_MSG_CHECKING([whether to include DWARF support])
  138. if test x$target_arch != xia64; then
  139. use_dwarf=yes
  140. else
  141. use_dwarf=no
  142. fi
  143. AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
  144. AC_MSG_RESULT([$use_dwarf])
  145. if test x$target_arch = xppc64; then
  146. libdir='${exec_prefix}/lib64'
  147. AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
  148. AC_SUBST([libdir])
  149. fi
  150. AC_MSG_CHECKING([whether to restrict build to remote support])
  151. if test x$target_arch != x$host_arch; then
  152. CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
  153. remote_only=yes
  154. else
  155. remote_only=no
  156. fi
  157. AC_MSG_RESULT([$remote_only])
  158. AC_MSG_CHECKING([whether to enable debug support])
  159. AC_ARG_ENABLE(debug,
  160. [ --enable-debug turn on debug support (slows down execution)],
  161. [enable_debug=$enableval], [enable_debug=no])
  162. if test x$enable_debug = xyes; then
  163. CPPFLAGS="${CPPFLAGS} -DDEBUG"
  164. else
  165. CPPFLAGS="${CPPFLAGS} -DNDEBUG"
  166. fi
  167. AC_MSG_RESULT([$enable_debug])
  168. AC_MSG_CHECKING([whether to enable C++ exception support])
  169. AC_ARG_ENABLE(cxx_exceptions,
  170. [ --enable-cxx-exceptions use libunwind to handle C++ exceptions],
  171. [enable_cxx_exceptions=$enableval],
  172. [
  173. # C++ exception handling doesn't work too well on x86
  174. case $target_arch in
  175. x86*) enable_cxx_exceptions=no;;
  176. arm*) enable_cxx_exceptions=no;;
  177. mips*) enable_cxx_exceptions=no;;
  178. *) enable_cxx_exceptions=yes;;
  179. esac
  180. ])
  181. AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
  182. AC_MSG_RESULT([$enable_cxx_exceptions])
  183. AC_MSG_CHECKING([whether to load .debug_frame sections])
  184. AC_ARG_ENABLE(debug_frame,
  185. [ --enable-debug-frame Load the ".debug_frame" section if available],
  186. [enable_debug_frame=$enableval], [
  187. case "${target_arch}" in
  188. (arm) enable_debug_frame=yes;;
  189. (*) enable_debug_frame=no;;
  190. esac])
  191. if test x$enable_debug_frame = xyes; then
  192. AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
  193. fi
  194. AC_MSG_RESULT([$enable_debug_frame])
  195. AC_MSG_CHECKING([whether to block signals during mutex ops])
  196. AC_ARG_ENABLE(block_signals,
  197. [ --enable-block-signals Block signals before performing mutex operations],
  198. [enable_block_signals=$enableval], [enable_block_signals=yes])
  199. if test x$enable_block_signals = xyes; then
  200. AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations])
  201. fi
  202. AC_MSG_RESULT([$enable_block_signals])
  203. AC_MSG_CHECKING([whether to validate memory addresses before use])
  204. AC_ARG_ENABLE(conservative_checks,
  205. [ --enable-conservative-checks Validate all memory addresses before use],
  206. [enable_conservative_checks=$enableval], [enable_conservative_checks=yes])
  207. if test x$enable_conservative_checks = xyes; then
  208. AC_DEFINE(CONSERVATIVE_CHECKS, 1,
  209. [Define to 1 if you want every memory access validated])
  210. fi
  211. AC_MSG_RESULT([$enable_conservative_checks])
  212. AC_MSG_CHECKING([whether to enable msabi support])
  213. AC_ARG_ENABLE(msabi_support,
  214. [ --enable-msabi-support Enables support for Microsoft ABI extensions ],
  215. [enable_msabi_support=$enableval], [enable_msabi_support=no])
  216. if test x$enable_msabi_support = xyes; then
  217. AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions])
  218. fi
  219. AC_MSG_RESULT([$enable_msabi_support])
  220. LIBUNWIND___THREAD
  221. AC_MSG_CHECKING([for Intel compiler])
  222. AC_TRY_COMPILE([], [#ifndef __INTEL_COMPILER
  223. #error choke me
  224. #endif], [intel_compiler=yes], [intel_compiler=no])
  225. if test x$GCC = xyes -a x$intel_compiler != xyes; then
  226. CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
  227. LIBCRTS="-lgcc"
  228. fi
  229. AC_MSG_RESULT([$intel_compiler])
  230. if test x$intel_compiler = xyes; then
  231. AC_MSG_CHECKING([if linker supports -static-libcxa])
  232. save_LDFLAGS="$LDFLAGS"
  233. LDFLAGS="$LDFLAGS -static-libcxa"
  234. AC_TRY_LINK([], [], [have_static_libcxa=yes], [have_static_libcxa=no])
  235. LDFLAGS="$save_LDFLAGS"
  236. if test "x$have_static_libcxa" = xyes; then
  237. LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
  238. fi
  239. AC_MSG_RESULT([$have_static_libcxa])
  240. fi
  241. CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
  242. arch="$target_arch"
  243. ARCH=`echo $target_arch | tr [a-z] [A-Z]`
  244. dnl create shell variables from the M4 macros:
  245. PKG_MAJOR=pkg_major
  246. PKG_MINOR=pkg_minor
  247. PKG_EXTRA=pkg_extra
  248. PKG_MAINTAINER=pkg_maintainer
  249. old_LIBS="$LIBS"
  250. LIBS=""
  251. AC_SEARCH_LIBS(backtrace, execinfo)
  252. AM_CONDITIONAL(HAVE_BACKTRACE, test "x$ac_cv_search_backtrace" != xno)
  253. BACKTRACELIB="$LIBS"
  254. LIBS="$old_LIBS"
  255. AC_SUBST(build_arch)
  256. AC_SUBST(target_os)
  257. AC_SUBST(arch)
  258. AC_SUBST(ARCH)
  259. AC_SUBST(LDFLAGS_STATIC_LIBCXA)
  260. AC_SUBST(LIBCRTS)
  261. AC_SUBST(PKG_MAJOR)
  262. AC_SUBST(PKG_MINOR)
  263. AC_SUBST(PKG_EXTRA)
  264. AC_SUBST(PKG_MAINTAINER)
  265. AC_SUBST(enable_cxx_exceptions)
  266. AC_SUBST(enable_debug_frame)
  267. AC_SUBST(DLLIB)
  268. AC_SUBST(BACKTRACELIB)
  269. AC_CONFIG_FILES(Makefile src/Makefile
  270. include/libunwind-common.h
  271. include/libunwind.h include/tdep/libunwind_i.h)
  272. AC_OUTPUT