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.
24 dnl Checks for libraries.
25 AC_CHECK_LIB(uca, __uc_get_grs)
27 AC_SEARCH_LIBS(dlopen, dl)
29 case "$ac_cv_search_dlopen" in
30 -l*) DLLIB=$ac_cv_search_dlopen;;
36 dnl Checks for header files.
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 elf.h sys/elf.h link.h sys/link.h)
42 dnl Checks for typedefs, structures, and compiler characteristics.
46 AC_CHECK_SIZEOF(off_t)
48 CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
50 AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
51 AC_CHECK_TYPES([struct elf_prstatus, struct prstatus], [], [],
54 # include <sys/procfs.h>
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], [], [],
65 #include <sys/types.h>
67 #include <sys/ptrace.h>
70 dnl Checks for library functions.
71 AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
74 AC_MSG_CHECKING([if building with AltiVec])
75 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
79 ]])], [use_altivec=yes],[use_altivec=no])
80 AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes])
81 AC_MSG_RESULT([$use_altivec])
83 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
87 ]])], [ppc_bits=64], [ppc_bits=32])
95 [powerpc*],[$2=ppc$ppc_bits],
101 SET_ARCH([$build_cpu],[build_arch])
102 SET_ARCH([$host_cpu],[host_arch])
103 SET_ARCH([$target_cpu],[target_arch])
105 AC_ARG_ENABLE(coredump,
106 AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
107 [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
110 AC_MSG_CHECKING([if we should build libunwind-coredump])
111 AC_MSG_RESULT([$enable_coredump])
113 AC_ARG_ENABLE(ptrace,
114 AS_HELP_STRING([--enable-ptrace],[building libunwind-ptrace library]),,
115 [AC_CHECK_HEADER([sys/ptrace.h], [enable_ptrace=yes], [enable_ptrace=no])]
118 AC_MSG_CHECKING([if we should build libunwind-ptrace])
119 AC_MSG_RESULT([$enable_ptrace])
121 AC_ARG_ENABLE(setjmp,
122 AS_HELP_STRING([--enable-setjmp],[building libunwind-setjmp library]),,
123 [AS_IF([test x$target_arch == x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])]
126 AC_MSG_CHECKING([if we should build libunwind-setjmp])
127 AC_MSG_RESULT([$enable_setjmp])
129 AC_MSG_CHECKING([for build architecture])
130 AC_MSG_RESULT([$build_arch])
131 AC_MSG_CHECKING([for host architecture])
132 AC_MSG_RESULT([$host_arch])
133 AC_MSG_CHECKING([for target architecture])
134 AC_MSG_RESULT([$target_arch])
135 AC_MSG_CHECKING([for target operating system])
136 AC_MSG_RESULT([$target_os])
138 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
139 AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes)
140 AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes)
141 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
142 AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
143 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
144 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
145 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
146 AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
147 AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
148 AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
149 AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
150 AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
151 AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh)
152 AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
153 AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
154 AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
155 AM_CONDITIONAL(OS_QNX, expr x$target_os : xnto-qnx >/dev/null)
157 AC_MSG_CHECKING([for ELF helper width])
158 case "${target_arch}" in
159 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
160 (aarch64|ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
161 (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
162 *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
164 AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
165 AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes])
166 AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes])
168 AC_MSG_CHECKING([whether to include DWARF support])
169 if test x$target_arch != xia64; then
174 AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
175 AC_MSG_RESULT([$use_dwarf])
177 if test x$target_arch = xppc64; then
178 libdir='${exec_prefix}/lib64'
179 AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
183 AC_MSG_CHECKING([whether to restrict build to remote support])
184 if test x$target_arch != x$host_arch; then
185 CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
190 AC_MSG_RESULT([$remote_only])
192 AC_MSG_CHECKING([whether to enable debug support])
194 AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)]))
195 if test x$enable_debug = xyes; then
196 CPPFLAGS="${CPPFLAGS} -DDEBUG"
198 CPPFLAGS="${CPPFLAGS} -DNDEBUG"
200 AC_MSG_RESULT([$enable_debug])
202 AC_MSG_CHECKING([whether to enable C++ exception support])
203 AC_ARG_ENABLE(cxx_exceptions,
204 AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),,
206 # C++ exception handling doesn't work too well on x86
208 x86*) enable_cxx_exceptions=no;;
209 aarch64*) enable_cxx_exceptions=no;;
210 arm*) enable_cxx_exceptions=no;;
211 mips*) enable_cxx_exceptions=no;;
212 *) enable_cxx_exceptions=yes;;
216 AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
217 AC_MSG_RESULT([$enable_cxx_exceptions])
219 AC_MSG_CHECKING([whether to load .debug_frame sections])
220 AC_ARG_ENABLE(debug_frame,
221 AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [
222 case "${target_arch}" in
223 (arm) enable_debug_frame=yes;;
224 (*) enable_debug_frame=no;;
226 if test x$enable_debug_frame = xyes; then
227 AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
229 AC_MSG_RESULT([$enable_debug_frame])
231 AC_MSG_CHECKING([whether to block signals during mutex ops])
232 AC_ARG_ENABLE(block_signals,
233 AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),,
234 [enable_block_signals=yes])
235 if test x$enable_block_signals = xyes; then
236 AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations])
238 AC_MSG_RESULT([$enable_block_signals])
240 AC_MSG_CHECKING([whether to validate memory addresses before use])
241 AC_ARG_ENABLE(conservative_checks,
242 AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),,
243 [enable_conservative_checks=yes])
244 if test x$enable_conservative_checks = xyes; then
245 AC_DEFINE(CONSERVATIVE_CHECKS, 1,
246 [Define to 1 if you want every memory access validated])
248 AC_MSG_RESULT([$enable_conservative_checks])
250 AC_MSG_CHECKING([whether to enable msabi support])
251 AC_ARG_ENABLE(msabi_support,
252 AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions]))
253 if test x$enable_msabi_support = xyes; then
254 AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions])
256 AC_MSG_RESULT([$enable_msabi_support])
259 AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables])
260 AC_ARG_ENABLE(minidebuginfo,
261 AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto])
262 AC_MSG_RESULT([$enable_minidebuginfo])
263 if test x$enable_minidebuginfo != xno; then
264 AC_CHECK_LIB([lzma], [lzma_mf_is_supported],
266 AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma])
267 enable_minidebuginfo=yes],
268 [if test x$enable_minidebuginfo = xyes; then
269 AC_MSG_FAILURE([liblzma not found])
273 AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes)
277 AC_MSG_CHECKING([for Intel compiler])
278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
280 #endif]])],[intel_compiler=yes],[intel_compiler=no])
282 if test x$GCC = xyes -a x$intel_compiler != xyes; then
283 CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
285 AC_MSG_RESULT([$intel_compiler])
287 AC_MSG_CHECKING([for QCC compiler])
288 AS_CASE([$CC], [qcc*|QCC*], [qcc_compiler=yes], [qcc_compiler=no])
289 AC_MSG_RESULT([$qcc_compiler])
291 if test x$intel_compiler = xyes; then
292 AC_MSG_CHECKING([if linker supports -static-libcxa])
293 save_LDFLAGS="$LDFLAGS"
294 LDFLAGS="$LDFLAGS -static-libcxa"
295 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no])
296 LDFLAGS="$save_LDFLAGS"
297 if test "x$have_static_libcxa" = xyes; then
298 LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
300 AC_MSG_RESULT([$have_static_libcxa])
303 if test x$qcc_compiler = xyes; then
304 LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles"
306 LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles"
309 if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes; then
313 AC_MSG_CHECKING([for __builtin___clear_cache])
315 [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])],
316 [have__builtin___clear_cache=yes],
317 [have__builtin___clear_cache=no])
318 if test x$have__builtin___clear_cache = xyes; then
319 AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1],
320 [Defined if __builtin___clear_cache() is available])
322 AC_MSG_RESULT([$have__builtin___clear_cache])
324 AC_MSG_CHECKING([for __builtin_unreachable])
326 [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])],
327 [have__builtin_unreachable=yes],
328 [have__builtin_unreachable=no])
329 if test x$have__builtin_unreachable = xyes; then
330 AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1],
331 [Defined if __builtin_unreachable() is available])
333 AC_MSG_RESULT([$have__builtin_unreachable])
335 AC_MSG_CHECKING([for __sync atomics])
337 [AC_LANG_PROGRAM([[]], [[
338 __sync_bool_compare_and_swap((int *)0, 0, 1);
339 __sync_fetch_and_add((int *)0, 1);
341 [have_sync_atomics=yes],
342 [have_sync_atomics=no])
343 if test x$have_sync_atomics = xyes; then
344 AC_DEFINE([HAVE_SYNC_ATOMICS], [1],
345 [Defined if __sync atomics are available])
347 AC_MSG_RESULT([$have_sync_atomics])
349 CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
352 ARCH=`echo $target_arch | tr [a-z] [A-Z]`
354 dnl create shell variables from the M4 macros:
358 PKG_MAINTAINER=pkg_maintainer
362 AC_SEARCH_LIBS(backtrace, execinfo)
369 AC_SUBST(LDFLAGS_STATIC_LIBCXA)
370 AC_SUBST(LDFLAGS_NOSTARTFILES)
375 AC_SUBST(PKG_MAINTAINER)
376 AC_SUBST(enable_cxx_exceptions)
377 AC_SUBST(enable_debug_frame)
380 AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile tests/check-namespace.sh
381 doc/Makefile doc/common.tex include/libunwind-common.h
382 include/libunwind.h include/tdep/libunwind_i.h)
383 AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc
384 src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc
385 src/libunwind-generic.pc)