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)
11 AM_INIT_AUTOMAKE([1.6 subdir-objects])
13 AC_CONFIG_HEADERS([include/config.h])
15 dnl Checks for programs.
20 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
25 dnl Checks for libraries.
26 AC_CHECK_LIB(uca, __uc_get_grs)
28 AC_SEARCH_LIBS(dlopen, dl)
30 case "$ac_cv_search_dlopen" in
31 -l*) DLLIB=$ac_cv_search_dlopen;;
37 dnl Checks for header files.
39 AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
40 ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
41 sys/procfs.h sys/ptrace.h byteswap.h elf.h sys/elf.h link.h sys/link.h)
43 dnl Checks for typedefs, structures, and compiler characteristics.
47 AC_CHECK_SIZEOF(off_t)
49 CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
51 AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
52 AC_CHECK_TYPES([struct elf_prstatus, struct prstatus], [], [],
55 # include <sys/procfs.h>
59 AC_CHECK_DECLS([PTRACE_POKEUSER, PTRACE_POKEDATA, PTRACE_SETREGSET,
60 PTRACE_TRACEME, PTRACE_CONT, PTRACE_SINGLESTEP,
61 PTRACE_SYSCALL, PT_IO, PT_GETREGS,
62 PT_GETFPREGS, PT_CONTINUE, PT_TRACE_ME,
63 PT_STEP, PT_SYSCALL, PTRACE_GETREGSET], [], [],
66 #include <sys/types.h>
68 #include <sys/ptrace.h>
71 dnl Checks for library functions.
72 AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
75 AC_MSG_CHECKING([if building with AltiVec])
76 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
80 ]])], [use_altivec=yes],[use_altivec=no])
81 AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes])
82 AC_MSG_RESULT([$use_altivec])
84 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
88 ]])], [ppc_bits=64], [ppc_bits=32])
92 [aarch64*],[$2=aarch64],
97 [powerpc*],[$2=ppc$ppc_bits],
104 SET_ARCH([$build_cpu],[build_arch])
105 SET_ARCH([$host_cpu],[host_arch])
106 SET_ARCH([$target_cpu],[target_arch])
109 AC_MSG_CHECKING([for Android])
121 AC_ARG_ENABLE(coredump,
122 AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
123 [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*], [enable_coredump=yes], [enable_coredump=no])]
126 AC_MSG_CHECKING([if we should build libunwind-coredump])
127 AC_MSG_RESULT([$enable_coredump])
129 AC_ARG_ENABLE(ptrace,
130 AS_HELP_STRING([--enable-ptrace],[building libunwind-ptrace library]),,
131 [AC_CHECK_HEADER([sys/ptrace.h], [enable_ptrace=yes], [enable_ptrace=no])]
134 AC_MSG_CHECKING([if we should build libunwind-ptrace])
135 AC_MSG_RESULT([$enable_ptrace])
137 AC_ARG_ENABLE(setjmp,
138 AS_HELP_STRING([--enable-setjmp],[building libunwind-setjmp library]),,
139 [AS_IF([test x$target_arch == x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])]
142 AC_ARG_ENABLE(documentation,
143 AS_HELP_STRING([--disable-documentation],[Disable generating the man pages]),,
144 [enable_documentation=yes])
147 AS_HELP_STRING([--disable-tests],[Disable tests build]),,
150 AC_MSG_CHECKING([if we should build libunwind-setjmp])
151 AC_MSG_RESULT([$enable_setjmp])
153 AC_MSG_CHECKING([for build architecture])
154 AC_MSG_RESULT([$build_arch])
155 AC_MSG_CHECKING([for host architecture])
156 AC_MSG_RESULT([$host_arch])
157 AC_MSG_CHECKING([for target architecture])
158 AC_MSG_RESULT([$target_arch])
159 AC_MSG_CHECKING([for target operating system])
160 AC_MSG_RESULT([$target_os])
162 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
163 AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes)
164 AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes)
165 AM_CONDITIONAL(NO_PTRACE_TEST, test x$build_arch != x$host_arch)
166 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
167 AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
168 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
169 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
170 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
171 AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
172 AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
173 AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
174 AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
175 AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
176 AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh)
177 AM_CONDITIONAL(ARCH_TILEGX, test x$target_arch = xtilegx)
178 AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
179 AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
180 AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
181 AM_CONDITIONAL(OS_QNX, expr x$target_os : xnto-qnx >/dev/null)
183 AC_MSG_CHECKING([for ELF helper width])
184 case "${target_arch}" in
185 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
186 (aarch64|ia64|ppc64|x86_64|tilegx) use_elf64=yes; AC_MSG_RESULT([64]);;
187 (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
188 *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
190 AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
191 AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes])
192 AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes])
194 AC_MSG_CHECKING([whether to include DWARF support])
195 if test x$target_arch != xia64; then
200 AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
201 AC_MSG_RESULT([$use_dwarf])
203 if test x$target_arch = xppc64; then
204 libdir='${exec_prefix}/lib64'
205 AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
209 AC_MSG_CHECKING([whether to restrict build to remote support])
210 if test x$target_arch != x$host_arch; then
211 CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
216 AC_MSG_RESULT([$remote_only])
218 AC_MSG_CHECKING([whether to enable debug support])
220 AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)]))
221 if test x$enable_debug = xyes; then
222 CPPFLAGS="${CPPFLAGS} -DDEBUG"
224 CPPFLAGS="${CPPFLAGS} -DNDEBUG"
226 AC_MSG_RESULT([$enable_debug])
228 AC_MSG_CHECKING([whether to enable C++ exception support])
229 AC_ARG_ENABLE(cxx_exceptions,
230 AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),,
232 # C++ exception handling doesn't work too well on x86
234 x86*) enable_cxx_exceptions=no;;
235 aarch64*) enable_cxx_exceptions=no;;
236 arm*) enable_cxx_exceptions=no;;
237 mips*) enable_cxx_exceptions=no;;
238 tile*) enable_cxx_exceptions=no;;
239 *) enable_cxx_exceptions=yes;;
243 AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
244 AC_MSG_RESULT([$enable_cxx_exceptions])
246 AC_MSG_CHECKING([whether to load .debug_frame sections])
247 AC_ARG_ENABLE(debug_frame,
248 AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [
249 case "${target_arch}" in
250 (arm) enable_debug_frame=yes;;
251 (aarch64) enable_debug_frame=yes;;
252 (*) enable_debug_frame=no;;
254 if test x$enable_debug_frame = xyes; then
255 AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
257 AC_MSG_RESULT([$enable_debug_frame])
259 AC_MSG_CHECKING([whether to block signals during mutex ops])
260 AC_ARG_ENABLE(block_signals,
261 AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),,
262 [enable_block_signals=yes])
263 if test x$enable_block_signals = xyes; then
264 AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations])
266 AC_MSG_RESULT([$enable_block_signals])
268 AC_MSG_CHECKING([whether to validate memory addresses before use])
269 AC_ARG_ENABLE(conservative_checks,
270 AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),,
271 [enable_conservative_checks=yes])
272 if test x$enable_conservative_checks = xyes; then
273 AC_DEFINE(CONSERVATIVE_CHECKS, 1,
274 [Define to 1 if you want every memory access validated])
276 AC_MSG_RESULT([$enable_conservative_checks])
278 AC_MSG_CHECKING([whether to enable msabi support])
279 AC_ARG_ENABLE(msabi_support,
280 AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions]))
281 if test x$enable_msabi_support = xyes; then
282 AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions])
284 AC_MSG_RESULT([$enable_msabi_support])
287 AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables])
288 AC_ARG_ENABLE(minidebuginfo,
289 AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto])
290 AC_MSG_RESULT([$enable_minidebuginfo])
291 if test x$enable_minidebuginfo != xno; then
292 AC_CHECK_LIB([lzma], [lzma_mf_is_supported],
294 AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma])
295 enable_minidebuginfo=yes],
296 [if test x$enable_minidebuginfo = xyes; then
297 AC_MSG_FAILURE([liblzma not found])
301 AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes)
303 AC_MSG_CHECKING([whether to support UNW_CACHE_PER_THREAD])
304 AC_ARG_ENABLE([per-thread-cache],
305 AS_HELP_STRING([--enable-per-thread-cache], [build with support for UNW_CACHE_PER_THREAD (which imposes a hight TLS memory usage) (default: disabled)]))
306 AC_MSG_RESULT([$enable_per_thread_cache])
307 AS_IF([test x$enable_per_thread_cache = xyes], [
309 AS_IF([test x$libc_cv_gcc___thread = xno], [
310 AC_MSG_FAILURE([UNW_CACHE_PER_THREAD requires __thread])
314 AC_MSG_CHECKING([for Intel compiler])
315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
317 #endif]])],[intel_compiler=yes],[intel_compiler=no])
319 if test x$GCC = xyes -a x$intel_compiler != xyes; then
320 CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
322 AC_MSG_RESULT([$intel_compiler])
324 AC_MSG_CHECKING([for QCC compiler])
325 AS_CASE([$CC], [qcc*|QCC*], [qcc_compiler=yes], [qcc_compiler=no])
326 AC_MSG_RESULT([$qcc_compiler])
328 if test x$intel_compiler = xyes; then
329 AC_MSG_CHECKING([if linker supports -static-libcxa])
330 save_LDFLAGS="$LDFLAGS"
331 LDFLAGS="$LDFLAGS -static-libcxa"
332 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no])
333 LDFLAGS="$save_LDFLAGS"
334 if test "x$have_static_libcxa" = xyes; then
335 LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
337 AC_MSG_RESULT([$have_static_libcxa])
340 if test x$qcc_compiler = xyes; then
341 LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles"
343 LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles"
346 if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes -a x$android != xyes; then
350 AC_MSG_CHECKING([for __builtin___clear_cache])
352 [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])],
353 [have__builtin___clear_cache=yes],
354 [have__builtin___clear_cache=no])
355 if test x$have__builtin___clear_cache = xyes; then
356 AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1],
357 [Defined if __builtin___clear_cache() is available])
359 AC_MSG_RESULT([$have__builtin___clear_cache])
361 AC_MSG_CHECKING([for __builtin_unreachable])
363 [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])],
364 [have__builtin_unreachable=yes],
365 [have__builtin_unreachable=no])
366 if test x$have__builtin_unreachable = xyes; then
367 AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1],
368 [Defined if __builtin_unreachable() is available])
370 AC_MSG_RESULT([$have__builtin_unreachable])
372 AC_MSG_CHECKING([for __sync atomics])
374 [AC_LANG_PROGRAM([[]], [[
375 __sync_bool_compare_and_swap((int *)0, 0, 1);
376 __sync_fetch_and_add((int *)0, 1);
378 [have_sync_atomics=yes],
379 [have_sync_atomics=no])
380 if test x$have_sync_atomics = xyes; then
381 AC_DEFINE([HAVE_SYNC_ATOMICS], [1],
382 [Defined if __sync atomics are available])
384 AC_MSG_RESULT([$have_sync_atomics])
386 CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
389 ARCH=`echo $target_arch | tr [a-z] [A-Z]`
391 dnl create shell variables from the M4 macros:
395 PKG_MAINTAINER=pkg_maintainer
399 AC_SEARCH_LIBS(backtrace, execinfo)
401 case "$ac_cv_search_backtrace" in
402 -l*) BACKTRACELIB=$ac_cv_search_backtrace;;
411 AC_SUBST(LDFLAGS_STATIC_LIBCXA)
412 AC_SUBST(LDFLAGS_NOSTARTFILES)
417 AC_SUBST(PKG_MAINTAINER)
418 AC_SUBST(enable_cxx_exceptions)
419 AC_SUBST(enable_debug_frame)
421 AC_SUBST(BACKTRACELIB)
423 AC_PATH_PROG([LATEX2MAN],[latex2man])
424 if test "x$LATEX2MAN" = "x"; then
425 AC_MSG_WARN([latex2man not found. Install latex2man. Disabling docs.])
426 enable_documentation="no";
429 AM_CONDITIONAL([CONFIG_DOCS], [test x$enable_documentation = xyes])
430 if test "x$enable_documentation" = "xyes"; then
431 AC_CONFIG_FILES(doc/Makefile doc/common.tex)
434 AM_CONDITIONAL([CONFIG_TESTS], [test x$enable_tests = xyes])
435 if test "x$enable_tests" = "xyes"; then
436 AC_CONFIG_FILES(tests/Makefile tests/check-namespace.sh)
439 AC_CONFIG_FILES(Makefile src/Makefile
440 include/libunwind-common.h
441 include/libunwind.h include/tdep/libunwind_i.h)
442 AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc
443 src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc
444 src/libunwind-generic.pc)