blob: 63267cee73c7627cb5cce12a65ee1c1616578fd3 [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
5AC_INIT([ltrace],[0.5.3],[ltrace-devel <ltrace-devel@lists.alioth.debian.org>])
6AC_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" ;;
22 powerpc|ppc64) HOST_CPU="ppc" ;;
23 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])
34
35# Checks for libraries.
36
37# libelf
Petr Machata8c4aa1f2010-11-03 12:16:44 +010038AC_CHECK_HEADERS([elf.h gelf.h],,
39 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010040)
Petr Machata8c4aa1f2010-11-03 12:16:44 +010041AC_CHECK_LIB([elf], [elf_begin],,
42 [AC_MSG_ERROR([*** libelf not found on your system])]
43)
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010044
45
46# HAVE_LIBIBERTY
47AC_CHECK_LIB([iberty], [cplus_demangle], [
48 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
49 liberty_LIBS="-liberty"], [
50 liberty_LIBS=""])
51AC_SUBST(liberty_LIBS)
52
53
54# HAVE_LIBSUPC__
55AC_CHECK_LIB([supc++], [__cxa_demangle], [
56 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
57 libsupcxx_LIBS="-lsupc++"], [
58 libsupcxx_LIBS=""])
59AC_SUBST(libsupcxx_LIBS)
60
61
Joe Damatoab3b72c2010-10-31 00:21:53 -070062# HAVE_LIBUNWIND
63AC_ARG_WITH(libunwind,
64[ --with-libunwind Use libunwind frame unwinding support],
65[case "${withval}" in
66 yes) enable_libunwind=yes ;;
67 no) enable_libunwind=no ;;
68 *) AC_MSG_ERROR(bad value ${withval} for GDB with-libunwind option) ;;
69esac],[
70 AC_CHECK_HEADERS(libunwind.h)
71 AC_CHECK_HEADERS(libunwind-ptrace.h)
72 if test x"$ac_cv_header_libunwind_h" = xyes; then
73 enable_libunwind=yes;
74 fi
75])
76
77if test x"$enable_libunwind" = xyes; then
78 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
79 AC_SUBST(libunwind_LIBS)
80 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
81 AC_SUBST(libunwind_ptrace_LIBS)
82 AC_CHECK_LIB(unwind-${HOST_CPU}, _U${HOST_CPU}_init_remote, libunwind_arch_LIBS=-lunwind-${HOST_CPU}, libunwind_arch_LIBS=)
83 AC_SUBST(libunwind_arch_LIBS)
84 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
85fi
86
87
Marc Kleine-Budde584929c2010-02-03 20:24:13 +010088# HAVE_ELF_C_READ_MMAP
89AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
90AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
91int main () {
92 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
93 return 0;
94}
95 ]])],[
96 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
97 AC_MSG_RESULT([yes])],[
98 AC_MSG_RESULT([no])])
99
100
101CPPFLAGS=" \
102 ${CPPFLAGS} \
103 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
104 -I\$(top_srcdir)/sysdeps/${HOST_OS} \
105 -I\$(top_srcdir)/sysdeps \
106 -I\$(top_srcdir) \
107"
108
109CFLAGS="${CFLAGS} -Wall"
110
111# Checks for header files.
112AC_CHECK_HEADERS([ \
113 fcntl.h \
114 limits.h \
115 stddef.h \
116 stdint.h \
117 stdlib.h \
118 string.h \
119 sys/ioctl.h \
120 sys/param.h \
121 sys/time.h \
122 unistd.h \
123])
124
125# Checks for typedefs, structures, and compiler characteristics.
126AC_TYPE_UID_T
127AC_C_INLINE
128AC_TYPE_PID_T
129AC_TYPE_SIZE_T
130AC_CHECK_SIZEOF([long])
131
132
133# Checks for library functions.
134AC_FUNC_ERROR_AT_LINE
135AC_FUNC_FORK
136AC_CHECK_FUNCS([ \
137 alarm \
138 atexit \
139 getcwd \
140 gettimeofday \
141 memset \
142 mkdir \
143 rmdir \
144 strchr \
145 strdup \
146 strerror \
147 strtol \
148 strtoul \
149])
150
151
152#
153# Debugging
154#
155AC_MSG_CHECKING([whether to enable debugging])
156AC_ARG_ENABLE(debug,
157 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
158 [case "$enableval" in
159 y | yes) CONFIG_DEBUG=yes ;;
160 *) CONFIG_DEBUG=no ;;
161 esac],
162 [CONFIG_DEBUG=no])
163AC_MSG_RESULT([${CONFIG_DEBUG}])
164if test "${CONFIG_DEBUG}" = "yes"; then
165 CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1"
166 AC_DEFINE(DEBUG, 1, [debugging])
167else
168 CFLAGS="${CFLAGS} -O2"
169fi
170
171dnl testsuite/Makefile
172dnl testsuite/ltrace.main/Makefile
173dnl testsuite/ltrace.minor/Makefile
174dnl testsuite/ltrace.torture/Makefile
175
176AC_CONFIG_FILES([
177 Makefile
178 sysdeps/Makefile
179 sysdeps/linux-gnu/Makefile
180 sysdeps/linux-gnu/alpha/Makefile
181 sysdeps/linux-gnu/arm/Makefile
182 sysdeps/linux-gnu/i386/Makefile
183 sysdeps/linux-gnu/ia64/Makefile
184 sysdeps/linux-gnu/m68k/Makefile
185 sysdeps/linux-gnu/mipsel/Makefile
186 sysdeps/linux-gnu/ppc/Makefile
187 sysdeps/linux-gnu/s390/Makefile
188 sysdeps/linux-gnu/sparc/Makefile
189 sysdeps/linux-gnu/x86_64/Makefile
190])
191AC_OUTPUT