blob: 942fcbd17551854a1a7933367c9a647df8f2d60f [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
Zachary T Welchd0fafff2010-12-08 18:55:13 -080069 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
70 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070071 ;;
72esac],[enable_libunwind=maybe])
73
Zachary T Welchd0fafff2010-12-08 18:55:13 -080074saved_CPPFLAGS="${CPPFLAGS}"
75CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070076AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
77AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
Zachary T Welchd0fafff2010-12-08 18:55:13 -080078CPPFLAGS="${saved_CPPFLAGS}"
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070079
80AC_MSG_CHECKING([whether to use libunwind support])
81case "${enable_libunwind}" in
82(yes|maybe)
83 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
84 enable_libunwind=yes
85 elif test $enable_libunwind = maybe; then
86 enable_libunwind=no
87 else
88 AC_MSG_RESULT([$enable_libunwind])
89 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])
Joe Damatoab3b72c2010-10-31 00:21:53 -070090 fi
Zachary T Welchbc7a4a92010-11-05 15:03:04 -070091 ;;
92(*) ;;
93esac
94AC_MSG_RESULT([$enable_libunwind])
Joe Damatoab3b72c2010-10-31 00:21:53 -070095
96if test x"$enable_libunwind" = xyes; then
Zachary T Welchd0fafff2010-12-08 18:55:13 -080097 saved_LDFLAGS="${LDFLAGS}"
98 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
Joe Damatoab3b72c2010-10-31 00:21:53 -070099 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
100 AC_SUBST(libunwind_LIBS)
101 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
102 AC_SUBST(libunwind_ptrace_LIBS)
Joe Damatoafb44342010-11-07 15:33:36 -0800103
104 case "${host_cpu}" in
105 arm*|sa110) UNWIND_ARCH="arm" ;;
106 i?86) UNWIND_ARCH="x86" ;;
107 powerpc) UNWIND_ARCH="ppc32" ;;
108 ppc64) UNWIND_ARCH="ppc64" ;;
109 mips*) UNWIND_ARCH="mips" ;;
110 *) UNWIND_ARCH="${host_cpu}" ;;
111 esac
112
113 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 -0700114 AC_SUBST(libunwind_arch_LIBS)
115 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
Zachary T Welchd0fafff2010-12-08 18:55:13 -0800116 LDFLAGS="${saved_LDFLAGS}"
Joe Damatoab3b72c2010-10-31 00:21:53 -0700117fi
118
119
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100120# HAVE_ELF_C_READ_MMAP
121AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
122AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
123int main () {
124 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
125 return 0;
126}
127 ]])],[
128 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
129 AC_MSG_RESULT([yes])],[
130 AC_MSG_RESULT([no])])
131
Zachary T Welch0a43b322010-12-08 18:55:10 -0800132saved_CFLAGS="${CFLAGS}"
133CFLAGS="${CFLAGS} -Wall -Werror"
134AC_MSG_CHECKING([whether elf_hash takes a signed char string])
135AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[
136 (void) elf_hash("name");
137 ]])],
138 [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1],
139 [elf_hash() takes signed char])
140 AC_MSG_RESULT([yes])],
141 [AC_MSG_RESULT([no])])
142CFLAGS="${saved_CFLAGS}"
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100143
Zachary T Welchd0fafff2010-12-08 18:55:13 -0800144AM_CPPFLAGS=" \
145 ${AM_CPPFLAGS} \
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100146 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
147 -I\$(top_srcdir)/sysdeps/${HOST_OS} \
148 -I\$(top_srcdir)/sysdeps \
149 -I\$(top_srcdir) \
150"
151
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100152# Checks for header files.
153AC_CHECK_HEADERS([ \
154 fcntl.h \
155 limits.h \
156 stddef.h \
157 stdint.h \
158 stdlib.h \
159 string.h \
160 sys/ioctl.h \
161 sys/param.h \
162 sys/time.h \
163 unistd.h \
164])
165
166# Checks for typedefs, structures, and compiler characteristics.
167AC_TYPE_UID_T
168AC_C_INLINE
169AC_TYPE_PID_T
170AC_TYPE_SIZE_T
171AC_CHECK_SIZEOF([long])
172
173
174# Checks for library functions.
175AC_FUNC_ERROR_AT_LINE
176AC_FUNC_FORK
177AC_CHECK_FUNCS([ \
178 alarm \
179 atexit \
180 getcwd \
181 gettimeofday \
182 memset \
183 mkdir \
184 rmdir \
185 strchr \
186 strdup \
187 strerror \
188 strtol \
189 strtoul \
190])
191
192
193#
194# Debugging
195#
196AC_MSG_CHECKING([whether to enable debugging])
197AC_ARG_ENABLE(debug,
198 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
199 [case "$enableval" in
200 y | yes) CONFIG_DEBUG=yes ;;
201 *) CONFIG_DEBUG=no ;;
202 esac],
203 [CONFIG_DEBUG=no])
204AC_MSG_RESULT([${CONFIG_DEBUG}])
205if test "${CONFIG_DEBUG}" = "yes"; then
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100206 AC_DEFINE(DEBUG, 1, [debugging])
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100207fi
208
Zachary T Welchfe6c8052010-12-08 18:55:11 -0800209# Ignore the compiler's warnings at your own risk.
210AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security"
211AC_ARG_ENABLE([werror],
212 AS_HELP_STRING([--disable-werror], [disable use of -Werror]),
213 [enable_werror=$enableval], [enable_werror=yes])
214if test x$enable_werror = xyes; then
215 AM_CFLAGS="${AM_CFLAGS} -Werror"
216fi
217
Zachary T Welchd0fafff2010-12-08 18:55:13 -0800218AC_SUBST(AM_CPPFLAGS)
Zachary T Welchfe6c8052010-12-08 18:55:11 -0800219AC_SUBST(AM_CFLAGS)
Zachary T Welchd0fafff2010-12-08 18:55:13 -0800220AC_SUBST(AM_LDFLAGS)
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100221
222AC_CONFIG_FILES([
223 Makefile
224 sysdeps/Makefile
225 sysdeps/linux-gnu/Makefile
226 sysdeps/linux-gnu/alpha/Makefile
227 sysdeps/linux-gnu/arm/Makefile
228 sysdeps/linux-gnu/i386/Makefile
229 sysdeps/linux-gnu/ia64/Makefile
230 sysdeps/linux-gnu/m68k/Makefile
231 sysdeps/linux-gnu/mipsel/Makefile
232 sysdeps/linux-gnu/ppc/Makefile
233 sysdeps/linux-gnu/s390/Makefile
234 sysdeps/linux-gnu/sparc/Makefile
235 sysdeps/linux-gnu/x86_64/Makefile
Zachary T Welch3a9d1e72010-11-05 15:03:00 -0700236 testsuite/Makefile
237 testsuite/ltrace.main/Makefile
238 testsuite/ltrace.minor/Makefile
239 testsuite/ltrace.torture/Makefile
Marc Kleine-Budde584929c2010-02-03 20:24:13 +0100240])
241AC_OUTPUT