add changes
[platform/upstream/libunwind.git] / configure.ac
1 define(pkg_major, 1)
2 define(pkg_minor, 2)
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 elf.h sys/elf.h link.h sys/link.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         [aarch64*],[$2=aarch64],
92         [arm*],[$2=arm],
93         [i?86],[$2=x86],
94         [hppa*],[$2=hppa],
95         [mips*],[$2=mips],
96         [powerpc*],[$2=ppc$ppc_bits],
97         [sh*],[$2=sh],
98         [amd64],[$2=x86_64],
99         [tile*],[$2=tilegx],
100         [$2=$1])
101 ]) dnl SET_ARCH
102
103 SET_ARCH([$build_cpu],[build_arch])
104 SET_ARCH([$host_cpu],[host_arch])
105 SET_ARCH([$target_cpu],[target_arch])
106
107 AC_ARG_ENABLE(coredump,
108         AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
109         [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*], [enable_coredump=yes], [enable_coredump=no])]
110 )
111
112 AC_MSG_CHECKING([if we should build libunwind-coredump])
113 AC_MSG_RESULT([$enable_coredump])
114
115 AC_ARG_ENABLE(ptrace,
116         AS_HELP_STRING([--enable-ptrace],[building libunwind-ptrace library]),,
117         [AC_CHECK_HEADER([sys/ptrace.h], [enable_ptrace=yes], [enable_ptrace=no])]
118 )
119
120 AC_MSG_CHECKING([if we should build libunwind-ptrace])
121 AC_MSG_RESULT([$enable_ptrace])
122
123 AC_ARG_ENABLE(setjmp,
124         AS_HELP_STRING([--enable-setjmp],[building libunwind-setjmp library]),,
125         [AS_IF([test x$target_arch == x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])]
126 )
127
128 AC_ARG_ENABLE(documentation,
129         AS_HELP_STRING([--disable-documentation],[Disable generating the man pages]),,
130         [enable_documentation=yes])
131
132 AC_MSG_CHECKING([if we should build libunwind-setjmp])
133 AC_MSG_RESULT([$enable_setjmp])
134
135 AC_MSG_CHECKING([for build architecture])
136 AC_MSG_RESULT([$build_arch])
137 AC_MSG_CHECKING([for host architecture])
138 AC_MSG_RESULT([$host_arch])
139 AC_MSG_CHECKING([for target architecture])
140 AC_MSG_RESULT([$target_arch])
141 AC_MSG_CHECKING([for target operating system])
142 AC_MSG_RESULT([$target_os])
143
144 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
145 AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes)
146 AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes)
147 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
148 AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
149 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
150 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
151 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
152 AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
153 AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
154 AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
155 AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
156 AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
157 AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh)
158 AM_CONDITIONAL(ARCH_TILEGX, test x$target_arch = xtilegx)
159 AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
160 AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
161 AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
162 AM_CONDITIONAL(OS_QNX, expr x$target_os : xnto-qnx >/dev/null)
163
164 AC_MSG_CHECKING([for ELF helper width])
165 case "${target_arch}" in
166 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
167 (aarch64|ia64|ppc64|x86_64|tilegx)  use_elf64=yes; AC_MSG_RESULT([64]);;
168 (mips)                 use_elfxx=yes; AC_MSG_RESULT([xx]);;
169 *)                     AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
170 esac
171 AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
172 AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes])
173 AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes])
174
175 AC_MSG_CHECKING([whether to include DWARF support])
176 if test x$target_arch != xia64; then
177   use_dwarf=yes
178 else
179   use_dwarf=no
180 fi
181 AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
182 AC_MSG_RESULT([$use_dwarf])
183
184 if test x$target_arch = xppc64; then
185         libdir='${exec_prefix}/lib64'
186         AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
187         AC_SUBST([libdir])
188 fi
189
190 AC_MSG_CHECKING([whether to restrict build to remote support])
191 if test x$target_arch != x$host_arch; then
192   CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
193   remote_only=yes
194 else
195   remote_only=no
196 fi
197 AC_MSG_RESULT([$remote_only])
198
199 AC_MSG_CHECKING([whether to enable debug support])
200 AC_ARG_ENABLE(debug,
201 AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)]))
202 if test x$enable_debug = xyes; then
203   CPPFLAGS="${CPPFLAGS} -DDEBUG"
204 else
205   CPPFLAGS="${CPPFLAGS} -DNDEBUG"
206 fi
207 AC_MSG_RESULT([$enable_debug])
208
209 AC_MSG_CHECKING([whether to enable C++ exception support])
210 AC_ARG_ENABLE(cxx_exceptions,
211 AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),,
212 [
213 # C++ exception handling doesn't work too well on x86
214 case $target_arch in
215   x86*) enable_cxx_exceptions=no;;
216   aarch64*) enable_cxx_exceptions=no;;
217   arm*) enable_cxx_exceptions=no;;
218   mips*) enable_cxx_exceptions=no;;
219   tile*) enable_cxx_exceptions=no;;
220   *) enable_cxx_exceptions=yes;;
221 esac
222 ])
223
224 AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])
225 AC_MSG_RESULT([$enable_cxx_exceptions])
226
227 AC_MSG_CHECKING([whether to load .debug_frame sections])
228 AC_ARG_ENABLE(debug_frame,
229 AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [
230 case "${target_arch}" in
231   (arm) enable_debug_frame=yes;;
232   (*)   enable_debug_frame=no;;
233 esac])
234 if test x$enable_debug_frame = xyes; then
235   AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
236 fi
237 AC_MSG_RESULT([$enable_debug_frame])
238
239 AC_MSG_CHECKING([whether to block signals during mutex ops])
240 AC_ARG_ENABLE(block_signals,
241 AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),,
242 [enable_block_signals=yes])
243 if test x$enable_block_signals = xyes; then
244   AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations])
245 fi
246 AC_MSG_RESULT([$enable_block_signals])
247
248 AC_MSG_CHECKING([whether to validate memory addresses before use])
249 AC_ARG_ENABLE(conservative_checks,
250 AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),,
251 [enable_conservative_checks=yes])
252 if test x$enable_conservative_checks = xyes; then
253   AC_DEFINE(CONSERVATIVE_CHECKS, 1,
254         [Define to 1 if you want every memory access validated])
255 fi
256 AC_MSG_RESULT([$enable_conservative_checks])
257
258 AC_MSG_CHECKING([whether to enable msabi support])
259 AC_ARG_ENABLE(msabi_support,
260 AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions]))
261 if test x$enable_msabi_support = xyes; then
262   AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions])
263 fi
264 AC_MSG_RESULT([$enable_msabi_support])
265
266 LIBLZMA=
267 AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables])
268 AC_ARG_ENABLE(minidebuginfo,
269 AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto])
270 AC_MSG_RESULT([$enable_minidebuginfo])
271 if test x$enable_minidebuginfo != xno; then
272    AC_CHECK_LIB([lzma], [lzma_mf_is_supported],
273    [LIBLZMA=-llzma
274     AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma])
275     enable_minidebuginfo=yes],
276    [if test x$enable_minidebuginfo = xyes; then
277       AC_MSG_FAILURE([liblzma not found])
278     fi])
279 fi
280 AC_SUBST([LIBLZMA])
281 AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes)
282
283 LIBUNWIND___THREAD
284
285 AC_MSG_CHECKING([for Intel compiler])
286 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
287 #error choke me
288 #endif]])],[intel_compiler=yes],[intel_compiler=no])
289
290 if test x$GCC = xyes -a x$intel_compiler != xyes; then
291   CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
292 fi
293 AC_MSG_RESULT([$intel_compiler])
294
295 AC_MSG_CHECKING([for QCC compiler])
296 AS_CASE([$CC], [qcc*|QCC*], [qcc_compiler=yes], [qcc_compiler=no])
297 AC_MSG_RESULT([$qcc_compiler])
298
299 if test x$intel_compiler = xyes; then
300   AC_MSG_CHECKING([if linker supports -static-libcxa])
301   save_LDFLAGS="$LDFLAGS"
302   LDFLAGS="$LDFLAGS -static-libcxa"
303   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no])
304   LDFLAGS="$save_LDFLAGS"
305   if test "x$have_static_libcxa" = xyes; then
306     LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
307   fi
308   AC_MSG_RESULT([$have_static_libcxa])
309 fi
310
311 if test x$qcc_compiler = xyes; then
312     LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles"
313 else
314     LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles"
315 fi
316
317 if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes; then
318   LIBCRTS="-lgcc_s"
319 fi
320
321 AC_MSG_CHECKING([for __builtin___clear_cache])
322 AC_LINK_IFELSE(
323   [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])],
324   [have__builtin___clear_cache=yes],
325   [have__builtin___clear_cache=no])
326 if test x$have__builtin___clear_cache = xyes; then
327   AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1],
328             [Defined if __builtin___clear_cache() is available])
329 fi
330 AC_MSG_RESULT([$have__builtin___clear_cache])
331
332 AC_MSG_CHECKING([for __builtin_unreachable])
333 AC_LINK_IFELSE(
334   [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])],
335   [have__builtin_unreachable=yes],
336   [have__builtin_unreachable=no])
337 if test x$have__builtin_unreachable = xyes; then
338   AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1],
339             [Defined if __builtin_unreachable() is available])
340 fi
341 AC_MSG_RESULT([$have__builtin_unreachable])
342
343 AC_MSG_CHECKING([for __sync atomics])
344 AC_LINK_IFELSE(
345   [AC_LANG_PROGRAM([[]], [[
346     __sync_bool_compare_and_swap((int *)0, 0, 1);
347     __sync_fetch_and_add((int *)0, 1);
348     ]])],
349   [have_sync_atomics=yes],
350   [have_sync_atomics=no])
351 if test x$have_sync_atomics = xyes; then
352   AC_DEFINE([HAVE_SYNC_ATOMICS], [1],
353             [Defined if __sync atomics are available])
354 fi
355 AC_MSG_RESULT([$have_sync_atomics])
356
357 CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
358
359 arch="$target_arch"
360 ARCH=`echo $target_arch | tr [a-z] [A-Z]`
361
362 dnl create shell variables from the M4 macros:
363 PKG_MAJOR=pkg_major
364 PKG_MINOR=pkg_minor
365 PKG_EXTRA=pkg_extra
366 PKG_MAINTAINER=pkg_maintainer
367
368 old_LIBS="$LIBS"
369 LIBS=""
370 AC_SEARCH_LIBS(backtrace, execinfo)
371 LIBS="$old_LIBS"
372
373 AC_SUBST(build_arch)
374 AC_SUBST(target_os)
375 AC_SUBST(arch)
376 AC_SUBST(ARCH)
377 AC_SUBST(LDFLAGS_STATIC_LIBCXA)
378 AC_SUBST(LDFLAGS_NOSTARTFILES)
379 AC_SUBST(LIBCRTS)
380 AC_SUBST(PKG_MAJOR)
381 AC_SUBST(PKG_MINOR)
382 AC_SUBST(PKG_EXTRA)
383 AC_SUBST(PKG_MAINTAINER)
384 AC_SUBST(enable_cxx_exceptions)
385 AC_SUBST(enable_debug_frame)
386 AC_SUBST(DLLIB)
387
388 AC_PATH_PROG([LATEX2MAN],[latex2man])
389 if test "x$LATEX2MAN" = "x"; then
390   AC_MSG_WARN([latex2man not found. Install latex2man. Disabling docs.])
391   enable_documentation="no";
392 fi
393
394 AM_CONDITIONAL([CONFIG_DOCS], [test x$enable_documentation = xyes])
395 if test "x$enable_documentation" = "xyes"; then
396   AC_CONFIG_FILES(doc/Makefile doc/common.tex)
397 fi
398
399 AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile tests/check-namespace.sh
400                 include/libunwind-common.h
401                 include/libunwind.h include/tdep/libunwind_i.h)
402 AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc
403                 src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc
404                 src/libunwind-generic.pc)
405 AC_OUTPUT