summaryrefslogtreecommitdiff
path: root/configure.in
blob: 1271a560927fc433c89ea91cb967869f7fd5bce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
define(pkg_major, 0)
define(pkg_minor, 99)
define(pkg_extra, -beta)
define(pkg_maintainer, libunwind-devel@nongnu.org)
define(mkvers, $1.$2$3)
dnl Process this file with autoconf to produce a configure script.
AC_INIT(libunwind, mkvers(pkg_major, pkg_minor, pkg_extra), pkg_maintainer)
AC_CONFIG_SRCDIR(src/mi/backtrace.c)
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([1.6 subdir-objects])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(include/config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AM_PROG_LIBTOOL
AM_PROG_AS
AM_PROG_CC_C_O

dnl Checks for libraries.
AC_CHECK_LIB(uca, __uc_get_grs)
CHECK_ATOMIC_OPS

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h execinfo.h ia64intrin.h \
		 sys/uc_access.h unistd.h signal.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T

CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE"
if test x$enable_debug = xyes; then
  CPPFLAGS="${CPPFLAGS} -DDEBUG"
else
  CPPFLAGS="${CPPFLAGS} -DNDEBUG"
fi

AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include <link.h>])
AC_CHECK_TYPES([sighandler_t], [], [],
[$ac_includes_default
#if HAVE_SIGNAL_H
# include <signal.h>
#endif
])

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
		ttrace)
is_gcc_m64() {
 if test `echo $CFLAGS | grep "\-m64" -c` -eq 1 ; then echo ppc64;
 else
  if test `echo $CC | grep "\-m64" -c` -eq 1 ; then echo ppc64; else echo ppc32; fi;
 fi;
}

is_gcc_altivec() {
 if test `echo $CFLAGS | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec;
 else
  if test `echo $CC | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec; else echo no_altivec; fi;
 fi;
}

use_altivec=`is_gcc_altivec`
AM_CONDITIONAL(USE_ALTIVEC, test x$use_altivec = xhas_altivec)

get_arch() {
 case "$1" in
  arm*) echo arm;;
  i?86) echo x86;;
  hppa*) echo hppa;;
  mips*) echo mips;;
  powerpc*) is_gcc_m64;;
  *) echo $1;;
 esac
}

build_arch=`get_arch $build_cpu`
host_arch=`get_arch $host_cpu`
target_arch=`get_arch $target_cpu`

AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips)
AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86)
AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64)
AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32)
AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)

if test x$target_arch = xppc64; then
        libdir='${exec_prefix}/lib64'
        AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
        AC_SUBST([libdir])
fi

if test x$target_arch != x$host_arch; then
  CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
fi

AC_ARG_ENABLE(debug,
[  --enable-debug          turn on debug support (slows down execution)],
[enable_debug=yes], [])

AC_ARG_ENABLE(cxx_exceptions,
[  --enable-cxx-exceptions use libunwind to handle C++ exceptions],
[enable_cxx_exceptions=$enableval], 
[
# C++ exception handling doesn't work too well on x86
case $target_arch in
  x86*) enable_cxx_exceptions=no;;
  arm*) enable_cxx_exceptions=no;;
  mips*) enable_cxx_exceptions=no;;
  *) enable_cxx_exceptions=yes;;
esac
])

if test x$enable_cxx_exceptions = xyes; then
  AC_MSG_NOTICE([Enabling C++ exception support])
fi
AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes])

AC_ARG_ENABLE(debug_frame,
[  --enable-debug-frame Load the ".debug_frame" section if available],
[enable_debug_frame=$enableval], [enable_debug_frame=no])
if test x$enable_debug_frame = xyes; then
  AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
fi

LIBUNWIND___THREAD

save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -static-libcxa"
AC_TRY_LINK([], [], [have_static_libcxa=yes])
LDFLAGS="$save_LDFLAGS"
if test "x$have_static_libcxa" = xyes; then
  LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa"
fi

AC_TRY_COMPILE([], [#ifndef __INTEL_COMPILER
#error choke me
#endif], [intel_compiler=yes])

if test x$GCC = xyes -a x$intel_compiler != xyes; then
  CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
  LIBCRTS="-lgcc"
fi

CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"

arch="$target_arch"
ARCH=`echo $target_arch | tr [a-z] [A-Z]`

dnl create shell variables from the M4 macros:
PKG_MAJOR=pkg_major
PKG_MINOR=pkg_minor
PKG_EXTRA=pkg_extra
PKG_MAINTAINER=pkg_maintainer

AC_SUBST(build_arch)
AC_SUBST(target_os)
AC_SUBST(arch)
AC_SUBST(ARCH)
AC_SUBST(LDFLAGS_STATIC_LIBCXA)
AC_SUBST(LIBCRTS)
AC_SUBST(PKG_MAJOR)
AC_SUBST(PKG_MINOR)
AC_SUBST(PKG_EXTRA)
AC_SUBST(PKG_MAINTAINER)
AC_SUBST(enable_cxx_exceptions)

AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile tests/check-namespace.sh
		doc/Makefile doc/common.tex include/libunwind-common.h)
AC_OUTPUT