2 # This file is part of ltrace.
3 # Copyright (C) 2010,2012 Petr Machata, Red Hat Inc.
4 # Copyright (C) 2010,2011 Joe Damato
5 # Copyright (C) 2010 Marc Kleine-Budde
6 # Copyright (C) 2010 Zachary T Welch
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 # Process this file with autoconf to produce a configure script.
26 AC_INIT([ltrace],[0.7.2],[ltrace-devel@lists.alioth.debian.org])
27 AC_CONFIG_HEADERS([config.h])
28 AC_CONFIG_SRCDIR(libltrace.c)
29 AC_CONFIG_MACRO_DIR([config/m4])
30 AC_CONFIG_AUX_DIR([config/autoconf])
35 linux-gnu*) HOST_OS="linux-gnu" ;;
36 *) AC_MSG_ERROR([unkown host-os ${host_os}]) ;;
41 arm*|sa110) HOST_CPU="arm" ;;
42 cris*) HOST_CPU="cris" ;;
43 mips*el) HOST_CPU="mipsel" ;;
44 mips*) HOST_CPU="mips" ;;
45 powerpc|powerpc64) HOST_CPU="ppc" ;;
46 sun4u|sparc64) HOST_CPU="sparc" ;;
47 s390x) HOST_CPU="s390" ;;
48 i?86|x86_64) HOST_CPU="x86" ;;
49 *) HOST_CPU="${host_cpu}" ;;
53 # Checks for programs.
56 # libtool-2: LT_INIT()
57 AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
61 AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]),
64 AC_MSG_ERROR([*** libelf is a required dependency])
67 AC_MSG_ERROR([*** --with-libelf requires you to specify a path])
70 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
71 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
72 libelf_LD_LIBRARY_PATH="${withval}/lib"
76 # Checks for libraries.
78 saved_CPPFLAGS="${CPPFLAGS}"
79 saved_LDFLAGS="${LDFLAGS}"
80 CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
81 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
83 AC_CHECK_HEADERS([elf.h gelf.h],,
84 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
86 AC_CHECK_LIB([elf], [elf_begin],,
87 [AC_MSG_ERROR([*** libelf not found on your system])]
89 CPPFLAGS="${saved_CPPFLAGS}"
90 LDFLAGS="${saved_LDFLAGS}"
94 AC_CHECK_LIB([iberty], [cplus_demangle], [
95 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
96 liberty_LIBS="-liberty"], [
98 AC_SUBST(liberty_LIBS)
102 AC_CHECK_LIB([supc++], [__cxa_demangle], [
103 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
104 libsupcxx_LIBS="-lsupc++"], [
106 AC_SUBST(libsupcxx_LIBS)
110 AC_CHECK_LIB([stdc++], [__cxa_demangle], [
111 AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++])
112 libstdcxx_LIBS="-lstdc++"], [
114 AC_SUBST(libstdcxx_LIBS)
117 dnl Check security_get_boolean_active availability.
118 AC_CHECK_HEADERS(selinux/selinux.h)
119 AC_CHECK_LIB(selinux, security_get_boolean_active)
123 AC_ARG_WITH(libunwind,
124 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]),
125 [case "${withval}" in
126 (yes|no) enable_libunwind=$withval;;
127 (*) enable_libunwind=yes
128 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
129 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
130 libunwind_LD_LIBRARY_PATH="${withval}/lib"
132 esac],[enable_libunwind=maybe])
134 saved_CPPFLAGS="${CPPFLAGS}"
135 CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
136 AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
137 AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
138 CPPFLAGS="${saved_CPPFLAGS}"
140 AC_MSG_CHECKING([whether to use libunwind support])
141 case "${enable_libunwind}" in
143 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
145 elif test $enable_libunwind = maybe; then
148 AC_MSG_RESULT([$enable_libunwind])
149 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])
154 AC_MSG_RESULT([$enable_libunwind])
156 if test x"$enable_libunwind" = xyes; then
157 case "${host_cpu}" in
158 arm*|sa110) UNWIND_ARCH="arm" ;;
159 i?86) UNWIND_ARCH="x86" ;;
160 powerpc) UNWIND_ARCH="ppc32" ;;
161 powerpc64) UNWIND_ARCH="ppc64" ;;
162 mips*) UNWIND_ARCH="mips" ;;
163 *) UNWIND_ARCH="${host_cpu}" ;;
166 saved_LDFLAGS="${LDFLAGS}"
167 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
168 AC_CHECK_LIB([unwind], [backtrace], [libunwind_LIBS=-lunwind],
169 [AC_MSG_ERROR([Couldn't find or use libunwind.])])
171 AC_CHECK_LIB([unwind-${UNWIND_ARCH}], [_U${UNWIND_ARCH}_init_remote],
172 [libunwind_LIBS="-lunwind-${UNWIND_ARCH} $libunwind_LIBS"],
173 [AC_MSG_ERROR([Couldn't find or use libunwind-${UNWIND_ARCH}.])],
176 AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
177 [libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"],
178 [AC_MSG_ERROR([Couldn't find or use libunwind-ptrace.])],
181 AC_SUBST(libunwind_LIBS)
182 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
183 LDFLAGS="${saved_LDFLAGS}"
187 saved_CPPFLAGS="${CPPFLAGS}"
188 saved_LDFLAGS="${LDFLAGS}"
189 CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
190 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
191 # HAVE_ELF_C_READ_MMAP
192 AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
195 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
199 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
200 AC_MSG_RESULT([yes])],[
201 AC_MSG_RESULT([no])])
203 saved_CFLAGS="${CFLAGS}"
204 CFLAGS="${CFLAGS} -Wall -Werror"
205 AC_MSG_CHECKING([whether elf_hash takes a char* argument])
206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[
207 (void) elf_hash("name");
209 [AC_DEFINE([ELF_HASH_TAKES_CHARP], [1],
210 [elf_hash() takes char* (as opposed to unsigned char *)])
211 AC_MSG_RESULT([yes])],
212 [AC_MSG_RESULT([no])])
213 CFLAGS="${saved_CFLAGS}"
214 CPPFLAGS="${saved_CPPFLAGS}"
215 LDFLAGS="${saved_LDFLAGS}"
219 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
220 -I\$(top_srcdir)/sysdeps/${HOST_OS} \
221 -I\$(top_srcdir)/sysdeps \
225 # Checks for header files.
239 # Checks for typedefs, structures, and compiler characteristics.
244 AC_CHECK_SIZEOF([long])
247 # Checks for library functions.
248 AC_FUNC_ERROR_AT_LINE
269 AC_MSG_CHECKING([whether to enable debugging])
271 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
272 [case "$enableval" in
273 y | yes) CONFIG_DEBUG=yes ;;
274 *) CONFIG_DEBUG=no ;;
277 AC_MSG_RESULT([${CONFIG_DEBUG}])
278 if test "${CONFIG_DEBUG}" = "yes"; then
279 AC_DEFINE(DEBUG, 1, [debugging])
282 # Ignore the compiler's warnings at your own risk.
283 AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security"
284 AC_ARG_ENABLE([werror],
285 AS_HELP_STRING([--disable-werror], [disable use of -Werror]),
286 [enable_werror=$enableval], [enable_werror=yes])
287 if test x$enable_werror = xyes; then
288 AM_CFLAGS="${AM_CFLAGS} -Werror"
291 AC_ARG_ENABLE([valgrind],
292 AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]),
293 [use_valgrind=$enableval], [use_valgrind=no])
294 if test x$use_valgrind = xyes; then
295 AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
296 if test x$HAVE_VALGRIND = xno; then
297 AC_MSG_ERROR([valgrind not found])
300 AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
302 AC_SUBST(AM_CPPFLAGS)
305 AC_SUBST(libelf_LD_LIBRARY_PATH)
306 AC_SUBST(libunwind_LD_LIBRARY_PATH)
311 sysdeps/linux-gnu/Makefile
312 sysdeps/linux-gnu/alpha/Makefile
313 sysdeps/linux-gnu/arm/Makefile
314 sysdeps/linux-gnu/cris/Makefile
315 sysdeps/linux-gnu/ia64/Makefile
316 sysdeps/linux-gnu/m68k/Makefile
317 sysdeps/linux-gnu/mipsel/Makefile
318 sysdeps/linux-gnu/ppc/Makefile
319 sysdeps/linux-gnu/s390/Makefile
320 sysdeps/linux-gnu/sparc/Makefile
321 sysdeps/linux-gnu/x86/Makefile
323 testsuite/ltrace.main/Makefile
324 testsuite/ltrace.minor/Makefile
325 testsuite/ltrace.torture/Makefile