blob: 9375f45f78345b8440c9881bb366bac4caa5e912 [file] [log] [blame]
Marc Kleine-Budde584929c2010-02-03 20:24:13 +01001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
Marc Kleine-Budde3a7d76d2010-02-04 18:54:58 +01003AC_PREREQ(2.59)
Marc Kleine-Budde584929c2010-02-03 20:24:13 +01004
Zachary T Welchded5ea82010-12-06 23:20:58 -08005AC_INIT([ltrace],[0.5.3],[ltrace-devel@lists.alioth.debian.org])
Marc Kleine-Budde584929c2010-02-03 20:24:13 +01006AC_CONFIG_HEADERS([config.h])
7AC_CONFIG_SRCDIR(libltrace.c)
8#AC_CONFIG_MACRO_DIR([config/m4])
9AC_CONFIG_AUX_DIR([config/autoconf])
10AC_CANONICAL_BUILD
11AC_CANONICAL_HOST
12
13case "${host_os}" in
14 linux-gnu*) HOST_OS="linux-gnu" ;;
15 *) AC_MSG_ERROR([unkown host-os ${host_osx}]) ;;
16esac
17AC_SUBST(HOST_OS)
18
19case "${host_cpu}" in
20 arm*|sa110) HOST_CPU="arm" ;;
21 i?86) HOST_CPU="i386" ;;
Petr Machata19062482010-11-01 16:06:12 +010022 powerpc|powerpc64) HOST_CPU="ppc" ;;
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010023 sun4u|sparc64) HOST_CPU="sparc" ;;
24 s390x) HOST_CPU="s390" ;;
25 *) HOST_CPU="${host_cpu}" ;;
26esac
27AC_SUBST(HOST_CPU)
28
29# Checks for programs.
30AC_PROG_CC
Marc Kleine-Budde7cae4e02010-02-04 18:55:22 +010031AC_PROG_LIBTOOL
32# libtool-2: LT_INIT()
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010033AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
Zachary T Welchd9152892010-11-05 15:02:57 -070034AM_MAINTAINER_MODE
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010035
36# Checks for libraries.
37
38# libelf
Petr Machata8c4aa1f2010-11-03 12:16:44 +010039AC_CHECK_HEADERS([elf.h gelf.h],,
40 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010041)
Petr Machata8c4aa1f2010-11-03 12:16:44 +010042AC_CHECK_LIB([elf], [elf_begin],,
43 [AC_MSG_ERROR([*** libelf not found on your system])]
44)
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010045
46
47# HAVE_LIBIBERTY
48AC_CHECK_LIB([iberty], [cplus_demangle], [
49 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
50 liberty_LIBS="-liberty"], [
51 liberty_LIBS=""])
52AC_SUBST(liberty_LIBS)
53
54
55# HAVE_LIBSUPC__
56AC_CHECK_LIB([supc++], [__cxa_demangle], [
57 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
58 libsupcxx_LIBS="-lsupc++"], [
59 libsupcxx_LIBS=""])
60AC_SUBST(libsupcxx_LIBS)
61
62
Joe Damatoab3b72c2010-10-31 00:21:53 -070063# HAVE_LIBUNWIND
64AC_ARG_WITH(libunwind,
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070065 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]),
66 [case "${withval}" in
67 (yes|no) enable_libunwind=$withval;;
68 (*) enable_libunwind=yes
69 CPPFLAGS="${CPPFLAGS} -I${withval}/include"
70 LDFLAGS="${LDFLAGS} -L${withval}/lib"
71 ;;
72esac],[enable_libunwind=maybe])
73
74AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
75AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
76
77AC_MSG_CHECKING([whether to use libunwind support])
78case "${enable_libunwind}" in
79(yes|maybe)
80 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
81 enable_libunwind=yes
82 elif test $enable_libunwind = maybe; then
83 enable_libunwind=no
84 else
85 AC_MSG_RESULT([$enable_libunwind])
86 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])
Joe Damatoab3b72c2010-10-31 00:21:53 -070087 fi
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070088 ;;
89(*) ;;
90esac
91AC_MSG_RESULT([$enable_libunwind])
Joe Damatoab3b72c2010-10-31 00:21:53 -070092
93if test x"$enable_libunwind" = xyes; then
94 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
95 AC_SUBST(libunwind_LIBS)
96 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
97 AC_SUBST(libunwind_ptrace_LIBS)
Joe Damatoafb44342010-11-07 15:33:36 -080098
99 case "${host_cpu}" in
100 arm*|sa110) UNWIND_ARCH="arm" ;;
101 i?86) UNWIND_ARCH="x86" ;;
102 powerpc) UNWIND_ARCH="ppc32" ;;
103 ppc64) UNWIND_ARCH="ppc64" ;;
104 mips*) UNWIND_ARCH="mips" ;;
105 *) UNWIND_ARCH="${host_cpu}" ;;
106 esac
107
108 AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=)
Joe Damatoab3b72c2010-10-31 00:21:53 -0700109 AC_SUBST(libunwind_arch_LIBS)
110 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
111fi
112
113
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100114# HAVE_ELF_C_READ_MMAP
115AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
116AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
117int main () {
118 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
119 return 0;
120}
121 ]])],[
122 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
123 AC_MSG_RESULT([yes])],[
124 AC_MSG_RESULT([no])])
125
Zachary T Welch0a43b322010-12-08 18:55:10 -0800126saved_CFLAGS="${CFLAGS}"
127CFLAGS="${CFLAGS} -Wall -Werror"
128AC_MSG_CHECKING([whether elf_hash takes a signed char string])
129AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[
130 (void) elf_hash("name");
131 ]])],
132 [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1],
133 [elf_hash() takes signed char])
134 AC_MSG_RESULT([yes])],
135 [AC_MSG_RESULT([no])])
136CFLAGS="${saved_CFLAGS}"
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100137
138CPPFLAGS=" \
139 ${CPPFLAGS} \
140 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
141 -I\$(top_srcdir)/sysdeps/${HOST_OS} \
142 -I\$(top_srcdir)/sysdeps \
143 -I\$(top_srcdir) \
144"
145
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100146# Checks for header files.
147AC_CHECK_HEADERS([ \
148 fcntl.h \
149 limits.h \
150 stddef.h \
151 stdint.h \
152 stdlib.h \
153 string.h \
154 sys/ioctl.h \
155 sys/param.h \
156 sys/time.h \
157 unistd.h \
158])
159
160# Checks for typedefs, structures, and compiler characteristics.
161AC_TYPE_UID_T
162AC_C_INLINE
163AC_TYPE_PID_T
164AC_TYPE_SIZE_T
165AC_CHECK_SIZEOF([long])
166
167
168# Checks for library functions.
169AC_FUNC_ERROR_AT_LINE
170AC_FUNC_FORK
171AC_CHECK_FUNCS([ \
172 alarm \
173 atexit \
174 getcwd \
175 gettimeofday \
176 memset \
177 mkdir \
178 rmdir \
179 strchr \
180 strdup \
181 strerror \
182 strtol \
183 strtoul \
184])
185
186
187#
188# Debugging
189#
190AC_MSG_CHECKING([whether to enable debugging])
191AC_ARG_ENABLE(debug,
192 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
193 [case "$enableval" in
194 y | yes) CONFIG_DEBUG=yes ;;
195 *) CONFIG_DEBUG=no ;;
196 esac],
197 [CONFIG_DEBUG=no])
198AC_MSG_RESULT([${CONFIG_DEBUG}])
199if test "${CONFIG_DEBUG}" = "yes"; then
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100200 AC_DEFINE(DEBUG, 1, [debugging])
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100201fi
202
Zachary T Welchfe6c8052010-12-08 18:55:11 -0800203# Ignore the compiler's warnings at your own risk.
204AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security"
205AC_ARG_ENABLE([werror],
206 AS_HELP_STRING([--disable-werror], [disable use of -Werror]),
207 [enable_werror=$enableval], [enable_werror=yes])
208if test x$enable_werror = xyes; then
209 AM_CFLAGS="${AM_CFLAGS} -Werror"
210fi
211
212AC_SUBST(AM_CFLAGS)
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100213
214AC_CONFIG_FILES([
215 Makefile
216 sysdeps/Makefile
217 sysdeps/linux-gnu/Makefile
218 sysdeps/linux-gnu/alpha/Makefile
219 sysdeps/linux-gnu/arm/Makefile
220 sysdeps/linux-gnu/i386/Makefile
221 sysdeps/linux-gnu/ia64/Makefile
222 sysdeps/linux-gnu/m68k/Makefile
223 sysdeps/linux-gnu/mipsel/Makefile
224 sysdeps/linux-gnu/ppc/Makefile
225 sysdeps/linux-gnu/s390/Makefile
226 sysdeps/linux-gnu/sparc/Makefile
227 sysdeps/linux-gnu/x86_64/Makefile
Zachary T Welch3a9d1e72010-11-05 15:03:00 -0700228 testsuite/Makefile
229 testsuite/ltrace.main/Makefile
230 testsuite/ltrace.minor/Makefile
231 testsuite/ltrace.torture/Makefile
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100232])
233AC_OUTPUT