1define(pkg_major, 1) 2define(pkg_minor, 6) 3define(pkg_extra, 2) 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 20m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 21LT_INIT 22AM_PROG_AS 23AM_PROG_CC_C_O 24 25dnl Checks for libraries. 26AC_CHECK_LIB(uca, __uc_get_grs) 27OLD_LIBS=${LIBS} 28AC_SEARCH_LIBS(dlopen, dl) 29LIBS=${OLD_LIBS} 30case "$ac_cv_search_dlopen" in 31 -l*) DLLIB=$ac_cv_search_dlopen;; 32 *) DLLIB="";; 33esac 34 35dnl Checks for header files. 36AC_HEADER_STDC 37AC_CHECK_HEADERS(asm/ptrace_offsets.h asm/ptrace.h endian.h sys/endian.h sys/param.h \ 38 execinfo.h ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \ 39 sys/procfs.h sys/ptrace.h sys/syscall.h byteswap.h elf.h sys/elf.h \ 40 link.h sys/link.h) 41 42dnl Checks for typedefs, structures, and compiler characteristics. 43AC_C_CONST 44AC_C_INLINE 45AC_TYPE_SIZE_T 46AC_CHECK_SIZEOF(off_t) 47 48CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE" 49 50AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>]) 51AC_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 58AC_CHECK_DECLS([PTRACE_POKEUSER, PTRACE_POKEDATA, PTRACE_SETREGSET, 59PTRACE_TRACEME, PTRACE_CONT, PTRACE_SINGLESTEP, 60PTRACE_SYSCALL, PT_IO, PT_GETREGS, 61PT_GETFPREGS, PT_CONTINUE, PT_TRACE_ME, 62PT_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 70dnl Checks for library functions. 71AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \ 72 ttrace mincore pipe2) 73 74AC_MSG_CHECKING([if building with AltiVec]) 75AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 76#ifndef __ALTIVEC__ 77# error choke 78#endif 79]])], [use_altivec=yes],[use_altivec=no]) 80AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes]) 81AC_MSG_RESULT([$use_altivec]) 82 83AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 84#ifndef __powerpc64__ 85# error choke 86#endif 87]])], [ppc_bits=64], [ppc_bits=32]) 88 89AC_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 [riscv*],[$2=riscv], 101 [$2=$1]) 102]) dnl SET_ARCH 103 104SET_ARCH([$build_cpu],[build_arch]) 105SET_ARCH([$host_cpu],[host_arch]) 106SET_ARCH([$target_cpu],[target_arch]) 107 108# Check for Android 109AC_MSG_CHECKING([for Android]) 110android="no" 111case "$host_os" in 112 *android*) 113 android="yes" 114 AC_MSG_RESULT([yes]) 115 ;; 116 *) 117 AC_MSG_RESULT([no]) 118 ;; 119esac 120 121AC_ARG_ENABLE(coredump, 122 AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),, 123 [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*|riscv*], [enable_coredump=yes], [enable_coredump=no])] 124) 125 126AC_MSG_CHECKING([if we should build libunwind-coredump]) 127AC_MSG_RESULT([$enable_coredump]) 128 129AC_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 134AC_MSG_CHECKING([if we should build libunwind-ptrace]) 135AC_MSG_RESULT([$enable_ptrace]) 136 137AC_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 142AC_ARG_ENABLE(documentation, 143 AS_HELP_STRING([--disable-documentation],[Disable generating the man pages]),, 144 [enable_documentation=yes]) 145 146AC_ARG_ENABLE(tests, 147 AS_HELP_STRING([--disable-tests],[Disable tests build]),, 148 [enable_tests=yes]) 149 150AC_ARG_ENABLE(weak-backtrace, 151 AS_HELP_STRING([--disable-weak-backtrace],[Do not provide the weak 'backtrace' symbol.]),, 152 [enable_weak_backtrace=yes]) 153 154AC_ARG_ENABLE(unwind-header, 155 AS_HELP_STRING([--disable-unwind-header],[Do not export the 'unwind.h' header]),, 156 [enable_unwind_header=yes]) 157 158AC_MSG_CHECKING([if we should export unwind.h]) 159AC_MSG_RESULT([$enable_unwind_header]) 160 161AC_MSG_CHECKING([if we should build libunwind-setjmp]) 162AC_MSG_RESULT([$enable_setjmp]) 163 164AC_MSG_CHECKING([for build architecture]) 165AC_MSG_RESULT([$build_arch]) 166AC_MSG_CHECKING([for host architecture]) 167AC_MSG_RESULT([$host_arch]) 168AC_MSG_CHECKING([for target architecture]) 169AC_MSG_RESULT([$target_arch]) 170AC_MSG_CHECKING([for target operating system]) 171AC_MSG_RESULT([$target_os]) 172 173AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes) 174AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes) 175AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes) 176AM_CONDITIONAL(BUILD_UNWIND_HEADER, test "x$enable_unwind_header" = xyes) 177AM_CONDITIONAL(NO_PTRACE_TEST, test x$build_arch != x$host_arch) 178AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch) 179AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64) 180AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm) 181AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64) 182AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa) 183AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips) 184AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86) 185AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64) 186AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32) 187AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64) 188AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh) 189AM_CONDITIONAL(ARCH_TILEGX, test x$target_arch = xtilegx) 190AM_CONDITIONAL(ARCH_S390X, test x$target_arch = xs390x) 191AM_CONDITIONAL(ARCH_RISCV, test x$target_arch = xriscv) 192AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null) 193AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null) 194AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null) 195AM_CONDITIONAL(OS_QNX, expr x$target_os : xnto-qnx >/dev/null) 196AM_CONDITIONAL(OS_SOLARIS, expr x$target_os : xsolaris >/dev/null) 197 198AC_MSG_CHECKING([for ELF helper width]) 199case "${target_arch}" in 200(arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);; 201(aarch64|ia64|ppc64|x86_64|s390x|tilegx) use_elf64=yes; AC_MSG_RESULT([64]);; 202(mips|riscv) use_elfxx=yes; AC_MSG_RESULT([xx]);; 203*) AC_MSG_ERROR([Unknown ELF target: ${target_arch}]) 204esac 205AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes]) 206AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes]) 207AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes]) 208 209AC_MSG_CHECKING([whether to include DWARF support]) 210if test x$target_arch != xia64; then 211 use_dwarf=yes 212else 213 use_dwarf=no 214fi 215AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes]) 216AC_MSG_RESULT([$use_dwarf]) 217 218AC_MSG_CHECKING([whether to restrict build to remote support]) 219if test x$target_arch != x$host_arch; then 220 CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY" 221 remote_only=yes 222else 223 remote_only=no 224fi 225AC_MSG_RESULT([$remote_only]) 226 227AC_MSG_CHECKING([whether to enable debug support]) 228AC_ARG_ENABLE(debug, 229AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)])) 230if test x$enable_debug = xyes; then 231 CPPFLAGS="${CPPFLAGS} -DDEBUG" 232else 233 CPPFLAGS="${CPPFLAGS} -DNDEBUG" 234fi 235AC_MSG_RESULT([$enable_debug]) 236 237AC_MSG_CHECKING([whether to enable C++ exception support]) 238AC_ARG_ENABLE(cxx_exceptions, 239AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),, 240[ 241# C++ exception handling doesn't work too well on x86 242case $target_arch in 243 x86*) enable_cxx_exceptions=no;; 244 aarch64*) enable_cxx_exceptions=no;; 245 arm*) enable_cxx_exceptions=no;; 246 mips*) enable_cxx_exceptions=no;; 247 tile*) enable_cxx_exceptions=no;; 248 s390x*) enable_cxx_exceptions=no;; 249 *) enable_cxx_exceptions=yes;; 250esac 251]) 252 253AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes]) 254AC_MSG_RESULT([$enable_cxx_exceptions]) 255 256AC_MSG_CHECKING([whether to load .debug_frame sections]) 257AC_ARG_ENABLE(debug_frame, 258AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [ 259case "${target_arch}" in 260 (arm) enable_debug_frame=yes;; 261 (aarch64) enable_debug_frame=yes;; 262 (*) enable_debug_frame=no;; 263esac]) 264if test x$remote_only = xyes; then 265 enable_debug_frame=no 266fi 267if test x$enable_debug_frame = xyes; then 268 AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame]) 269fi 270AC_MSG_RESULT([$enable_debug_frame]) 271 272AC_MSG_CHECKING([whether to block signals during mutex ops]) 273AC_ARG_ENABLE(block_signals, 274AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),, 275[enable_block_signals=yes]) 276if test x$enable_block_signals = xyes; then 277 AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations]) 278fi 279AC_MSG_RESULT([$enable_block_signals]) 280 281AC_MSG_CHECKING([whether to validate memory addresses before use]) 282AC_ARG_ENABLE(conservative_checks, 283AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),, 284[enable_conservative_checks=yes]) 285if test x$enable_conservative_checks = xyes; then 286 AC_DEFINE(CONSERVATIVE_CHECKS, 1, 287 [Define to 1 if you want every memory access validated]) 288fi 289AC_MSG_RESULT([$enable_conservative_checks]) 290 291AC_MSG_CHECKING([whether to enable msabi support]) 292AC_ARG_ENABLE(msabi_support, 293AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions])) 294if test x$enable_msabi_support = xyes; then 295 AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions]) 296fi 297AC_MSG_RESULT([$enable_msabi_support]) 298 299LIBLZMA= 300AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables]) 301AC_ARG_ENABLE(minidebuginfo, 302AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto]) 303AC_MSG_RESULT([$enable_minidebuginfo]) 304if test x$enable_minidebuginfo != xno; then 305 AC_CHECK_LIB([lzma], [lzma_mf_is_supported], 306 [LIBLZMA=-llzma 307 AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma]) 308 enable_minidebuginfo=yes], 309 [if test x$enable_minidebuginfo = xyes; then 310 AC_MSG_FAILURE([liblzma not found]) 311 fi]) 312fi 313AC_SUBST([LIBLZMA]) 314AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes) 315 316LIBZ= 317AC_MSG_CHECKING([whether to support ZLIB-compressed symbol tables]) 318AC_ARG_ENABLE(zlibdebuginfo, 319AS_HELP_STRING([--enable-zlibdebuginfo], [Enables support for ZLIB-compressed symbol tables]),, [enable_zlibdebuginfo=auto]) 320AC_MSG_RESULT([$enable_zlibdebuginfo]) 321if test x$enable_zlibdebuginfo != xno; then 322 AC_CHECK_LIB([z], [uncompress], 323 [LIBZ=-lz 324 AC_DEFINE([HAVE_ZLIB], [1], [Define if you have libz]) 325 enable_zlibdebuginfo=yes], 326 [if test x$enable_zlibdebuginfo = xyes; then 327 AC_MSG_FAILURE([libz not found]) 328 fi]) 329fi 330AC_SUBST([LIBZ]) 331AM_CONDITIONAL(HAVE_ZLIB, test x$enable_zlibdebuginfo = xyes) 332 333AC_MSG_CHECKING([whether to support UNW_CACHE_PER_THREAD]) 334AC_ARG_ENABLE([per-thread-cache], 335AS_HELP_STRING([--enable-per-thread-cache], [build with support for UNW_CACHE_PER_THREAD (which imposes a hight TLS memory usage) (default: disabled)])) 336AC_MSG_RESULT([$enable_per_thread_cache]) 337AS_IF([test x$enable_per_thread_cache = xyes], [ 338 AC_DEFINE(HAVE___CACHE_PER_THREAD, 1, 339 [Define to 1 if --enable-per-thread-cache]) 340]) 341 342AC_MSG_CHECKING([for Intel compiler]) 343AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER 344#error choke me 345#endif]])],[intel_compiler=yes],[intel_compiler=no]) 346 347if test x$GCC = xyes -a x$intel_compiler != xyes; then 348 CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare" 349fi 350AC_MSG_RESULT([$intel_compiler]) 351 352AC_MSG_CHECKING([if building on Solaris then define __EXTENSIONS__ macro]) 353if $OS_SOLARIS; then 354 CFLAGS="${CFLAGS} -D__EXTENSIONS__" 355 AC_MSG_RESULT([yes]) 356else 357 AC_MSG_RESULT([no]) 358fi 359 360AC_MSG_CHECKING([for QCC compiler]) 361AS_CASE([$CC], [qcc*|QCC*], [qcc_compiler=yes], [qcc_compiler=no]) 362AC_MSG_RESULT([$qcc_compiler]) 363 364if test x$intel_compiler = xyes; then 365 AC_MSG_CHECKING([if linker supports -static-libcxa]) 366 save_LDFLAGS="$LDFLAGS" 367 LDFLAGS="$LDFLAGS -static-libcxa" 368 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no]) 369 LDFLAGS="$save_LDFLAGS" 370 if test "x$have_static_libcxa" = xyes; then 371 LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa" 372 fi 373 AC_MSG_RESULT([$have_static_libcxa]) 374fi 375 376if test x$qcc_compiler = xyes; then 377 LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles" 378else 379 LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles" 380fi 381 382if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes -a x$android != xyes; then 383 LIBCRTS="-lgcc_s" 384fi 385 386AC_MSG_CHECKING([for __builtin___clear_cache]) 387AC_LINK_IFELSE( 388 [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])], 389 [have__builtin___clear_cache=yes], 390 [have__builtin___clear_cache=no]) 391if test x$have__builtin___clear_cache = xyes; then 392 AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1], 393 [Defined if __builtin___clear_cache() is available]) 394fi 395AC_MSG_RESULT([$have__builtin___clear_cache]) 396 397AC_MSG_CHECKING([for __builtin_unreachable]) 398AC_LINK_IFELSE( 399 [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])], 400 [have__builtin_unreachable=yes], 401 [have__builtin_unreachable=no]) 402if test x$have__builtin_unreachable = xyes; then 403 AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1], 404 [Defined if __builtin_unreachable() is available]) 405fi 406AC_MSG_RESULT([$have__builtin_unreachable]) 407 408CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}" 409 410arch="$target_arch" 411ARCH=`echo $target_arch | tr [a-z] [A-Z]` 412 413dnl create shell variables from the M4 macros: 414PKG_MAJOR=pkg_major 415PKG_MINOR=pkg_minor 416PKG_EXTRA=pkg_extra 417PKG_MAINTAINER=pkg_maintainer 418 419old_LIBS="$LIBS" 420LIBS="" 421AC_SEARCH_LIBS(backtrace, execinfo) 422LIBS="$old_LIBS" 423case "$ac_cv_search_backtrace" in 424 -l*) BACKTRACELIB=$ac_cv_search_backtrace;; 425 *) BACKTRACELIB="";; 426esac 427 428 429AC_SUBST(build_arch) 430AC_SUBST(target_os) 431AC_SUBST(arch) 432AC_SUBST(ARCH) 433AC_SUBST(LDFLAGS_STATIC_LIBCXA) 434AC_SUBST(LDFLAGS_NOSTARTFILES) 435AC_SUBST(LIBCRTS) 436AC_SUBST(PKG_MAJOR) 437AC_SUBST(PKG_MINOR) 438AC_SUBST(PKG_EXTRA) 439AC_SUBST(PKG_MAINTAINER) 440AC_SUBST(enable_cxx_exceptions) 441AC_SUBST(enable_debug_frame) 442AC_SUBST(DLLIB) 443AC_SUBST(BACKTRACELIB) 444 445AC_PATH_PROG([LATEX2MAN],[latex2man]) 446if test "x$LATEX2MAN" = "x"; then 447 AC_MSG_WARN([latex2man not found. Install latex2man. Disabling docs.]) 448 enable_documentation="no"; 449fi 450 451AM_CONDITIONAL([CONFIG_DOCS], [test x$enable_documentation = xyes]) 452if test "x$enable_documentation" = "xyes"; then 453 AC_CONFIG_FILES(doc/Makefile doc/common.tex) 454fi 455 456AM_CONDITIONAL([CONFIG_TESTS], [test x$enable_tests = xyes]) 457if test "x$enable_tests" = "xyes"; then 458 AC_CONFIG_FILES(tests/Makefile tests/check-namespace.sh) 459fi 460 461AM_CONDITIONAL([CONFIG_WEAK_BACKTRACE], [test "x$enable_weak_backtrace" = xyes]) 462AM_COND_IF([CONFIG_WEAK_BACKTRACE], [ 463 AC_DEFINE([CONFIG_WEAK_BACKTRACE], [1], [Define if the weak 'backtrace' symbol is provided.]) 464]) 465 466AC_CONFIG_FILES(Makefile src/Makefile 467 include/libunwind-common.h 468 include/libunwind.h include/tdep/libunwind_i.h) 469AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc 470 src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc 471 src/libunwind-generic.pc) 472AC_OUTPUT 473