Merge branch 'upstream' into tizen
[platform/upstream/libunwind.git] / configure.ac
1 define(pkg_major, 1)
2 define(pkg_minor, 3)
3 define(pkg_extra, 1)
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 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
21 LT_INIT
22 AM_PROG_AS
23 AM_PROG_CC_C_O
24
25 dnl Checks for libraries.
26 AC_CHECK_LIB(uca, __uc_get_grs)
27 OLD_LIBS=${LIBS}
28 AC_SEARCH_LIBS(dlopen, dl)
29 LIBS=${OLD_LIBS}
30 case "$ac_cv_search_dlopen" in
31   -l*) DLLIB=$ac_cv_search_dlopen;;
32   *) DLLIB="";;
33 esac
34
35 CHECK_ATOMIC_OPS
36
37 dnl Checks for header files.
38 AC_HEADER_STDC
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)
42
43 dnl Checks for typedefs, structures, and compiler characteristics.
44 AC_C_CONST
45 AC_C_INLINE
46 AC_TYPE_SIZE_T
47 AC_CHECK_SIZEOF(off_t)
48
49 CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
50
51 AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
52 AC_CHECK_TYPES([struct elf_prstatus, struct prstatus], [], [],
53 [$ac_includes_default
54 #if HAVE_SYS_PROCFS_H
55 # include <sys/procfs.h>
56 #endif
57 ])
58
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], [], [],
64 [$ac_includes_default
65 #if HAVE_SYS_TYPES_H
66 #include <sys/types.h>
67 #endif
68 #include <sys/ptrace.h>
69 ])
70
71 dnl Checks for library functions.
72 AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
73                 ttrace mincore)
74
75 AC_MSG_CHECKING([if building with AltiVec])
76 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
77 #ifndef __ALTIVEC__
78 # error choke
79 #endif
80 ]])], [use_altivec=yes],[use_altivec=no])
81 AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes])
82 AC_MSG_RESULT([$use_altivec])
83
84 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
85 #ifndef __powerpc64__
86 # error choke
87 #endif
88 ]])], [ppc_bits=64], [ppc_bits=32])
89
90 AC_DEFUN([SET_ARCH],[
91     AS_CASE([$1],
92         [aarch64*],[$2=aarch64],
93         [arm*],[$2=arm],
94         [i?86],[$2=x86],
95         [hppa*],[$2=hppa],
96         [mips*],[$2=mips],
97         [powerpc*],[$2=ppc$ppc_bits],
98         [sh*],[$2=sh],
99         [amd64],[$2=x86_64],
100         [tile*],[$2=tilegx],
101         [$2=$1])
102 ]) dnl SET_ARCH
103
104 SET_ARCH([$build_cpu],[build_arch])
105 SET_ARCH([$host_cpu],[host_arch])
106 SET_ARCH([$target_cpu],[target_arch])
107
108 # Check for Android
109 AC_MSG_CHECKING([for Android])
110 android="no"
111 case "$host_os" in
112   *android*)
113     android="yes"
114     AC_MSG_RESULT([yes])
115     ;;
116   *)
117     AC_MSG_RESULT([no])
118     ;;
119 esac
120
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])]
124 )
125
126 AC_MSG_CHECKING([if we should build libunwind-coredump])
127 AC_MSG_RESULT([$enable_coredump])
128
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])]
132 )
133
134 AC_MSG_CHECKING([if we should build libunwind-ptrace])
135 AC_MSG_RESULT([$enable_ptrace])
136
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])]
140 )
141
142 AC_ARG_ENABLE(documentation,
143         AS_HELP_STRING([--disable-documentation],[Disable generating the man pages]),,
144         [enable_documentation=yes])
145
146 AC_ARG_ENABLE(tests,
147  AS_HELP_STRING([--disable-tests],[Disable tests build]),,
148  [enable_tests=yes])
149
150 AC_MSG_CHECKING([if we should build libunwind-setjmp])
151 AC_MSG_RESULT([$enable_setjmp])
152
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])
161
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)
182
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}])
189 esac
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])
193
194 AC_MSG_CHECKING([whether to include DWARF support])
195 if test x$target_arch != xia64; then
196   use_dwarf=yes
197 else
198   use_dwarf=no
199 fi
200 AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
201 AC_MSG_RESULT([$use_dwarf])
202
203 if test x$target_arch = xppc64; then
204         libdir='${exec_prefix}/lib64'
205         AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
206         AC_SUBST([libdir])
207 fi
208
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"
212   remote_only=yes
213 else
214   remote_only=no
215 fi
216 AC_MSG_RESULT([$remote_only])
217
218 AC_MSG_CHECKING([whether to enable debug support])
219 AC_ARG_ENABLE(debug,
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"
223 else
224   CPPFLAGS="${CPPFLAGS} -DNDEBUG"
225 fi
226 AC_MSG_RESULT([$enable_debug])
227
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]),,
231 [
232 # C++ exception handling doesn't work too well on x86
233 case $target_arch in
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;;
240 esac
241 ])
242
243 AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
244 AC_MSG_RESULT([$enable_cxx_exceptions])
245
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;;
253 esac])
254 if test x$enable_debug_frame = xyes; then
255   AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
256 fi
257 AC_MSG_RESULT([$enable_debug_frame])
258
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])
265 fi
266 AC_MSG_RESULT([$enable_block_signals])
267
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])
275 fi
276 AC_MSG_RESULT([$enable_conservative_checks])
277
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])
283 fi
284 AC_MSG_RESULT([$enable_msabi_support])
285
286 LIBLZMA=
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],
293    [LIBLZMA=-llzma
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])
298     fi])
299 fi
300 AC_SUBST([LIBLZMA])
301 AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes)
302
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], [
308   LIBUNWIND___THREAD
309   AS_IF([test x$libc_cv_gcc___thread = xno], [
310     AC_MSG_FAILURE([UNW_CACHE_PER_THREAD requires __thread])
311   ])
312 ])
313
314 AC_MSG_CHECKING([for Intel compiler])
315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
316 #error choke me
317 #endif]])],[intel_compiler=yes],[intel_compiler=no])
318
319 if test x$GCC = xyes -a x$intel_compiler != xyes; then
320   CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
321 fi
322 AC_MSG_RESULT([$intel_compiler])
323
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])
327
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"
336   fi
337   AC_MSG_RESULT([$have_static_libcxa])
338 fi
339
340 if test x$qcc_compiler = xyes; then
341     LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles"
342 else
343     LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles"
344 fi
345
346 if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes -a x$android != xyes; then
347   LIBCRTS="-lgcc_s"
348 fi
349
350 AC_MSG_CHECKING([for __builtin___clear_cache])
351 AC_LINK_IFELSE(
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])
358 fi
359 AC_MSG_RESULT([$have__builtin___clear_cache])
360
361 AC_MSG_CHECKING([for __builtin_unreachable])
362 AC_LINK_IFELSE(
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])
369 fi
370 AC_MSG_RESULT([$have__builtin_unreachable])
371
372 AC_MSG_CHECKING([for __sync atomics])
373 AC_LINK_IFELSE(
374   [AC_LANG_PROGRAM([[]], [[
375     __sync_bool_compare_and_swap((int *)0, 0, 1);
376     __sync_fetch_and_add((int *)0, 1);
377     ]])],
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])
383 fi
384 AC_MSG_RESULT([$have_sync_atomics])
385
386 CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
387
388 arch="$target_arch"
389 ARCH=`echo $target_arch | tr [a-z] [A-Z]`
390
391 dnl create shell variables from the M4 macros:
392 PKG_MAJOR=pkg_major
393 PKG_MINOR=pkg_minor
394 PKG_EXTRA=pkg_extra
395 PKG_MAINTAINER=pkg_maintainer
396
397 old_LIBS="$LIBS"
398 LIBS=""
399 AC_SEARCH_LIBS(backtrace, execinfo)
400 LIBS="$old_LIBS"
401 case "$ac_cv_search_backtrace" in
402   -l*) BACKTRACELIB=$ac_cv_search_backtrace;;
403   *) BACKTRACELIB="";;
404 esac
405
406
407 AC_SUBST(build_arch)
408 AC_SUBST(target_os)
409 AC_SUBST(arch)
410 AC_SUBST(ARCH)
411 AC_SUBST(LDFLAGS_STATIC_LIBCXA)
412 AC_SUBST(LDFLAGS_NOSTARTFILES)
413 AC_SUBST(LIBCRTS)
414 AC_SUBST(PKG_MAJOR)
415 AC_SUBST(PKG_MINOR)
416 AC_SUBST(PKG_EXTRA)
417 AC_SUBST(PKG_MAINTAINER)
418 AC_SUBST(enable_cxx_exceptions)
419 AC_SUBST(enable_debug_frame)
420 AC_SUBST(DLLIB)
421 AC_SUBST(BACKTRACELIB)
422
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";
427 fi
428
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)
432 fi
433
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)
437 fi
438
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)
445 AC_OUTPUT