disable UNW_ARM_METHOD_FRAME routine
[external/libunwind.git] / configure.ac
1 define(pkg_major, 1)
2 define(pkg_minor, 1)
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_TARGET
11 AM_INIT_AUTOMAKE([1.6 subdir-objects])
12 AM_MAINTAINER_MODE
13 AC_CONFIG_HEADERS([include/config.h])
14
15 dnl Checks for programs.
16 AC_PROG_CC
17 AC_PROG_CXX
18 AC_PROG_INSTALL
19 AC_PROG_MAKE_SET
20 LT_INIT
21 AM_PROG_AS
22 AM_PROG_CC_C_O
23
24 dnl Checks for libraries.
25 AC_CHECK_LIB(uca, __uc_get_grs)
26 OLD_LIBS=${LIBS}
27 AC_SEARCH_LIBS(dlopen, dl)
28 LIBS=${OLD_LIBS}
29 case "$ac_cv_search_dlopen" in
30   -l*) DLLIB=$ac_cv_search_dlopen;;
31   *) DLLIB="";;
32 esac
33
34 CHECK_ATOMIC_OPS
35
36 dnl Checks for header files.
37 AC_HEADER_STDC
38 AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
39                 ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
40                 sys/procfs.h sys/ptrace.h byteswap.h)
41
42 dnl Checks for typedefs, structures, and compiler characteristics.
43 AC_C_CONST
44 AC_C_INLINE
45 AC_TYPE_SIZE_T
46 AC_CHECK_SIZEOF(off_t)
47
48 CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
49
50 AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
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
58 AC_CHECK_DECLS([PTRACE_POKEUSER, PTRACE_POKEDATA,
59 PTRACE_TRACEME, PTRACE_CONT, PTRACE_SINGLESTEP,
60 PTRACE_SYSCALL, PT_IO, PT_GETREGS,
61 PT_GETFPREGS, PT_CONTINUE, PT_TRACE_ME,
62 PT_STEP, PT_SYSCALL], [], [],
63 [$ac_includes_default
64 #if HAVE_SYS_TYPES_H
65 #include <sys/types.h>
66 #endif
67 #include <sys/ptrace.h>
68 ])
69
70 dnl Checks for library functions.
71 AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
72                 ttrace mincore)
73
74 AC_MSG_CHECKING([if building with AltiVec])
75 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
76 #ifndef __ALTIVEC__
77 # error choke
78 #endif
79 ]])], [use_altivec=yes],[use_altivec=no])
80 AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes])
81 AC_MSG_RESULT([$use_altivec])
82
83 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
84 #ifndef __powerpc64__
85 # error choke
86 #endif
87 ]])], [ppc_bits=64], [ppc_bits=32])
88
89 AC_DEFUN([SET_ARCH],[
90     AS_CASE([$1],
91         [arm*],[$2=arm],
92         [i?86],[$2=x86],
93         [hppa*],[$2=hppa],
94         [mips*],[$2=mips],
95         [powerpc*],[$2=ppc$ppc_bits],
96         [sh*],[$2=sh],
97         [amd64],[$2=x86_64],
98         [$2=$1])
99 ]) dnl SET_ARCH
100
101 SET_ARCH([$build_cpu],[build_arch])
102 SET_ARCH([$host_cpu],[host_arch])
103 SET_ARCH([$target_cpu],[target_arch])
104
105 AC_ARG_ENABLE(coredump,
106         AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
107         [AS_CASE([$host_arch], [arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
108 )
109
110 AC_MSG_CHECKING([if we should build libunwind-coredump])
111 AC_MSG_RESULT([$enable_coredump])
112
113 AC_MSG_CHECKING([for build architecture])
114 AC_MSG_RESULT([$build_arch])
115 AC_MSG_CHECKING([for host architecture])
116 AC_MSG_RESULT([$host_arch])
117 AC_MSG_CHECKING([for target architecture])
118 AC_MSG_RESULT([$target_arch])
119 AC_MSG_CHECKING([for target operating system])
120 AC_MSG_RESULT([$target_os])
121
122 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
123 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
124 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
125 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
126 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
127 AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
128 AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
129 AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
130 AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
131 AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
132 AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh)
133 AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
134 AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
135 AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
136
137 AC_MSG_CHECKING([for ELF helper width])
138 case "${target_arch}" in
139 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
140 (ia64|ppc64|x86_64)    use_elf64=yes; AC_MSG_RESULT([64]);;
141 (mips)                 use_elfxx=yes; AC_MSG_RESULT([xx]);;
142 *)                     AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
143 esac
144 AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
145 AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes])
146 AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes])
147
148 AC_MSG_CHECKING([whether to include DWARF support])
149 if test x$target_arch != xia64; then
150   use_dwarf=yes
151 else
152   use_dwarf=no
153 fi
154 AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
155 AC_MSG_RESULT([$use_dwarf])
156
157 if test x$target_arch = xppc64; then
158         libdir='${exec_prefix}/lib64'
159         AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
160         AC_SUBST([libdir])
161 fi
162
163 AC_MSG_CHECKING([whether to restrict build to remote support])
164 if test x$target_arch != x$host_arch; then
165   CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
166   remote_only=yes
167 else
168   remote_only=no
169 fi
170 AC_MSG_RESULT([$remote_only])
171
172 AC_MSG_CHECKING([whether to enable debug support])
173 AC_ARG_ENABLE(debug,
174 AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)]))
175 if test x$enable_debug = xyes; then
176   CPPFLAGS="${CPPFLAGS} -DDEBUG"
177 else
178   CPPFLAGS="${CPPFLAGS} -DNDEBUG"
179 fi
180 AC_MSG_RESULT([$enable_debug])
181
182 AC_MSG_CHECKING([whether to enable C++ exception support])
183 AC_ARG_ENABLE(cxx_exceptions,
184 AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),,
185 [
186 # C++ exception handling doesn't work too well on x86
187 case $target_arch in
188   x86*) enable_cxx_exceptions=no;;
189   arm*) enable_cxx_exceptions=no;;
190   mips*) enable_cxx_exceptions=no;;
191   *) enable_cxx_exceptions=yes;;
192 esac
193 ])
194
195 AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
196 AC_MSG_RESULT([$enable_cxx_exceptions])
197
198 AC_MSG_CHECKING([whether to load .debug_frame sections])
199 AC_ARG_ENABLE(debug_frame,
200 AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [
201 case "${target_arch}" in
202   (arm) enable_debug_frame=yes;;
203   (*)   enable_debug_frame=no;;
204 esac])
205 if test x$enable_debug_frame = xyes; then
206   AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
207 fi
208 AC_MSG_RESULT([$enable_debug_frame])
209
210 AC_MSG_CHECKING([whether to block signals during mutex ops])
211 AC_ARG_ENABLE(block_signals,
212 AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),,
213 [enable_block_signals=yes])
214 if test x$enable_block_signals = xyes; then
215   AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations])
216 fi
217 AC_MSG_RESULT([$enable_block_signals])
218
219 AC_MSG_CHECKING([whether to validate memory addresses before use])
220 AC_ARG_ENABLE(conservative_checks,
221 AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),,
222 [enable_conservative_checks=yes])
223 if test x$enable_conservative_checks = xyes; then
224   AC_DEFINE(CONSERVATIVE_CHECKS, 1,
225         [Define to 1 if you want every memory access validated])
226 fi
227 AC_MSG_RESULT([$enable_conservative_checks])
228
229 AC_MSG_CHECKING([whether to enable msabi support])
230 AC_ARG_ENABLE(msabi_support,
231 AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions]))
232 if test x$enable_msabi_support = xyes; then
233   AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions])
234 fi
235 AC_MSG_RESULT([$enable_msabi_support])
236
237 AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables])
238 AC_ARG_ENABLE(minidebuginfo,
239 AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto])
240 AC_MSG_RESULT([$enable_minidebuginfo])
241 if test x$enable_minidebuginfo != xno; then
242    AC_CHECK_LIB([lzma], [lzma_mf_is_supported],
243    [AC_SUBST([LIBLZMA], [-lzma])
244     AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma])
245     enable_minidebuginfo=yes],
246    [if test x$enable_minidebuginfo = xyes; then
247       AC_MSG_FAILURE([liblzma not found])
248     fi])
249 fi
250 AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes)
251
252 LIBUNWIND___THREAD
253
254 AC_MSG_CHECKING([for Intel compiler])
255 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
256 #error choke me
257 #endif]])],[intel_compiler=yes],[intel_compiler=no])
258
259 if test x$GCC = xyes -a x$intel_compiler != xyes; then
260   CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
261   LIBCRTS="-lgcc"
262 fi
263 AC_MSG_RESULT([$intel_compiler])
264
265 if test x$intel_compiler = xyes; then
266   AC_MSG_CHECKING([if linker supports -static-libcxa])
267   save_LDFLAGS="$LDFLAGS"
268   LDFLAGS="$LDFLAGS -static-libcxa"
269   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no])
270   LDFLAGS="$save_LDFLAGS"
271   if test "x$have_static_libcxa" = xyes; then
272     LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
273   fi
274   AC_MSG_RESULT([$have_static_libcxa])
275 fi
276
277 AC_MSG_CHECKING([for __builtin___clear_cache])
278 AC_LINK_IFELSE(
279   [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])],
280   [have__builtin___clear_cache=yes],
281   [have__builtin___clear_cache=no])
282 if test x$have__builtin___clear_cache = xyes; then
283   AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1],
284             [Defined if __builtin___clear_cache() is available])
285 fi
286 AC_MSG_RESULT([$have__builtin___clear_cache])
287
288 AC_MSG_CHECKING([for __sync atomics])
289 AC_LINK_IFELSE(
290   [AC_LANG_PROGRAM([[]], [[
291     __sync_bool_compare_and_swap((int *)0, 0, 1);
292     __sync_fetch_and_add((int *)0, 1);
293     ]])],
294   [have_sync_atomics=yes],
295   [have_sync_atomics=no])
296 if test x$have_sync_atomics = xyes; then
297   AC_DEFINE([HAVE_SYNC_ATOMICS], [1],
298             [Defined if __sync atomics are available])
299 fi
300 AC_MSG_RESULT([$have_sync_atomics])
301
302 CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
303
304 arch="$target_arch"
305 ARCH=`echo $target_arch | tr [a-z] [A-Z]`
306
307 dnl create shell variables from the M4 macros:
308 PKG_MAJOR=pkg_major
309 PKG_MINOR=pkg_minor
310 PKG_EXTRA=pkg_extra
311 PKG_MAINTAINER=pkg_maintainer
312
313 old_LIBS="$LIBS"
314 LIBS=""
315 AC_SEARCH_LIBS(backtrace, execinfo)
316 LIBS="$old_LIBS"
317
318 AC_SUBST(build_arch)
319 AC_SUBST(target_os)
320 AC_SUBST(arch)
321 AC_SUBST(ARCH)
322 AC_SUBST(LDFLAGS_STATIC_LIBCXA)
323 AC_SUBST(LIBCRTS)
324 AC_SUBST(PKG_MAJOR)
325 AC_SUBST(PKG_MINOR)
326 AC_SUBST(PKG_EXTRA)
327 AC_SUBST(PKG_MAINTAINER)
328 AC_SUBST(enable_cxx_exceptions)
329 AC_SUBST(enable_debug_frame)
330 AC_SUBST(DLLIB)
331
332 AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile tests/check-namespace.sh
333                 doc/Makefile doc/common.tex include/libunwind-common.h
334                 include/libunwind.h include/tdep/libunwind_i.h)
335 AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc
336                 src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc
337                 src/libunwind-generic.pc)
338 AC_OUTPUT