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