do not run tests
[platform/upstream/ltrace.git] / configure.ac
1 # -*- Autoconf -*-
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
7 #
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.
12 #
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.
17 #
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
21 # 02110-1301 USA
22
23 # Process this file with autoconf to produce a configure script.
24 AC_PREREQ(2.65)
25
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])
31 AC_CANONICAL_BUILD
32 AC_CANONICAL_HOST
33
34 case "${host_os}" in
35     linux-gnu*) HOST_OS="linux-gnu" ;;
36     *)          AC_MSG_ERROR([unkown host-os ${host_os}]) ;;
37 esac
38 AC_SUBST(HOST_OS)
39
40 case "${host_cpu}" in
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}" ;;
50 esac
51 AC_SUBST(HOST_CPU)
52
53 # Checks for programs.
54 AC_PROG_CC
55 LT_INIT
56 # libtool-2:  LT_INIT()
57 AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
58 AM_MAINTAINER_MODE
59
60 AC_ARG_WITH([libelf],
61   AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]),
62   [case "${withval}" in
63   (no)
64     AC_MSG_ERROR([*** libelf is a required dependency])
65     ;;
66   (yes)
67     AC_MSG_ERROR([*** --with-libelf requires you to specify a path])
68     ;;
69   (*)
70     AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
71     AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
72     libelf_LD_LIBRARY_PATH="${withval}/lib"
73     ;;
74 esac],[])
75
76 # Checks for libraries.
77
78 saved_CPPFLAGS="${CPPFLAGS}"
79 saved_LDFLAGS="${LDFLAGS}"
80 CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
81 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
82 # libelf
83 AC_CHECK_HEADERS([elf.h gelf.h],,
84         [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
85 )
86 AC_CHECK_LIB([elf], [elf_begin],,
87         [AC_MSG_ERROR([*** libelf not found on your system])]
88 )
89 CPPFLAGS="${saved_CPPFLAGS}"
90 LDFLAGS="${saved_LDFLAGS}"
91
92
93 # HAVE_LIBIBERTY
94 AC_CHECK_LIB([iberty], [cplus_demangle], [
95         AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
96         liberty_LIBS="-liberty"], [
97         liberty_LIBS=""])
98 AC_SUBST(liberty_LIBS)
99
100
101 # HAVE_LIBSUPC__
102 AC_CHECK_LIB([supc++], [__cxa_demangle], [
103         AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
104         libsupcxx_LIBS="-lsupc++"], [
105         libsupcxx_LIBS=""])
106 AC_SUBST(libsupcxx_LIBS)
107
108
109 # HAVE_LIBSTDC__
110 AC_CHECK_LIB([stdc++], [__cxa_demangle], [
111         AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++])
112         libstdcxx_LIBS="-lstdc++"], [
113         libstdcxx_LIBS=""])
114 AC_SUBST(libstdcxx_LIBS)
115
116
117 dnl Check security_get_boolean_active availability.
118 AC_CHECK_HEADERS(selinux/selinux.h)
119 AC_CHECK_LIB(selinux, security_get_boolean_active)
120
121
122 # HAVE_LIBUNWIND
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"
131     ;;
132 esac],[enable_libunwind=maybe])
133
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}"
139
140 AC_MSG_CHECKING([whether to use libunwind support])
141 case "${enable_libunwind}" in
142 (yes|maybe)
143   if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
144     enable_libunwind=yes
145   elif test $enable_libunwind = maybe; then
146     enable_libunwind=no
147   else
148     AC_MSG_RESULT([$enable_libunwind])
149     AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])   
150   fi
151   ;;
152 (*) ;;
153 esac
154 AC_MSG_RESULT([$enable_libunwind])
155
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}" ;;
164   esac
165
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.])])
170
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}.])],
174                [$libunwind_LIBS])
175
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.])],
179                [$libunwind_LIBS])
180
181   AC_SUBST(libunwind_LIBS)
182   AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
183   LDFLAGS="${saved_LDFLAGS}"
184 fi
185
186
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>]], [[
194 int main () {
195         Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
196         return 0;
197 }
198         ]])],[
199         AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
200         AC_MSG_RESULT([yes])],[
201         AC_MSG_RESULT([no])])
202
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");
208         ]])],
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}"
216
217 AM_CPPFLAGS=" \
218         ${AM_CPPFLAGS} \
219         -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
220         -I\$(top_srcdir)/sysdeps/${HOST_OS} \
221         -I\$(top_srcdir)/sysdeps \
222         -I\$(top_srcdir) \
223 "
224
225 # Checks for header files.
226 AC_CHECK_HEADERS([ \
227         fcntl.h \
228         limits.h \
229         stddef.h \
230         stdint.h \
231         stdlib.h \
232         string.h \
233         sys/ioctl.h \
234         sys/param.h \
235         sys/time.h \
236         unistd.h \
237 ])
238
239 # Checks for typedefs, structures, and compiler characteristics.
240 AC_TYPE_UID_T
241 AC_C_INLINE
242 AC_TYPE_PID_T
243 AC_TYPE_SIZE_T
244 AC_CHECK_SIZEOF([long])
245
246
247 # Checks for library functions.
248 AC_FUNC_ERROR_AT_LINE
249 AC_FUNC_FORK
250 AC_CHECK_FUNCS([ \
251         alarm \
252         atexit \
253         getcwd \
254         gettimeofday \
255         memset \
256         mkdir \
257         rmdir \
258         strchr \
259         strdup \
260         strerror \
261         strtol \
262         strtoul \
263 ])
264
265
266 #
267 # Debugging
268 #
269 AC_MSG_CHECKING([whether to enable debugging])
270 AC_ARG_ENABLE(debug,
271     AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
272         [case "$enableval" in
273         y | yes) CONFIG_DEBUG=yes ;;
274         *) CONFIG_DEBUG=no ;;
275     esac],
276     [CONFIG_DEBUG=no])
277 AC_MSG_RESULT([${CONFIG_DEBUG}])
278 if test "${CONFIG_DEBUG}" = "yes"; then
279     AC_DEFINE(DEBUG, 1, [debugging])
280 fi
281
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"
289 fi
290
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])
298     fi
299 fi
300 AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
301
302 AC_SUBST(AM_CPPFLAGS)
303 AC_SUBST(AM_CFLAGS)
304 AC_SUBST(AM_LDFLAGS)
305 AC_SUBST(libelf_LD_LIBRARY_PATH)
306 AC_SUBST(libunwind_LD_LIBRARY_PATH)
307
308 AC_CONFIG_FILES([
309         Makefile
310         sysdeps/Makefile
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
322         testsuite/Makefile
323         testsuite/ltrace.main/Makefile
324         testsuite/ltrace.minor/Makefile
325         testsuite/ltrace.torture/Makefile
326 ])
327 AC_OUTPUT