configure.ac revision 266e1f5b1af3b095c9eab10f9862892fbd5f4ddf
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.65)
4
5AC_INIT([ltrace],[0.7.0-git],[ltrace-devel@lists.alioth.debian.org])
6AC_CONFIG_HEADERS([config.h])
7AC_CONFIG_SRCDIR(libltrace.c)
8AC_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_os}]) ;;
16esac
17AC_SUBST(HOST_OS)
18
19case "${host_cpu}" in
20    arm*|sa110)		HOST_CPU="arm" ;;
21    cris*)		HOST_CPU="cris" ;;
22    mips*el)		HOST_CPU="mipsel" ;;
23    mips*)		HOST_CPU="mips" ;;
24    powerpc|powerpc64)	HOST_CPU="ppc" ;;
25    sun4u|sparc64)	HOST_CPU="sparc" ;;
26    s390x)		HOST_CPU="s390" ;;
27    i?86|x86_64)	HOST_CPU="x86" ;;
28    *)			HOST_CPU="${host_cpu}" ;;
29esac
30AC_SUBST(HOST_CPU)
31
32# Checks for programs.
33AC_PROG_CC
34LT_INIT
35# libtool-2:  LT_INIT()
36AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
37AM_MAINTAINER_MODE
38
39AC_ARG_WITH([libelf],
40  AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]),
41  [case "${withval}" in
42  (no)
43    AC_MSG_ERROR([*** libelf is a required dependency])
44    ;;
45  (yes)
46    AC_MSG_ERROR([*** --with-libelf requires you to specify a path])
47    ;;
48  (*)
49    AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
50    AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
51    libelf_LD_LIBRARY_PATH="${withval}/lib"
52    ;;
53esac],[])
54
55# Checks for libraries.
56
57saved_CPPFLAGS="${CPPFLAGS}"
58saved_LDFLAGS="${LDFLAGS}"
59CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
60LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
61# libelf
62AC_CHECK_HEADERS([elf.h gelf.h],,
63	[AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
64)
65AC_CHECK_LIB([elf], [elf_begin],,
66	[AC_MSG_ERROR([*** libelf not found on your system])]
67)
68CPPFLAGS="${saved_CPPFLAGS}"
69LDFLAGS="${saved_LDFLAGS}"
70
71
72# HAVE_LIBIBERTY
73AC_CHECK_LIB([iberty], [cplus_demangle], [
74	AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
75	liberty_LIBS="-liberty"], [
76	liberty_LIBS=""])
77AC_SUBST(liberty_LIBS)
78
79
80# HAVE_LIBSUPC__
81AC_CHECK_LIB([supc++], [__cxa_demangle], [
82	AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
83	libsupcxx_LIBS="-lsupc++"], [
84	libsupcxx_LIBS=""])
85AC_SUBST(libsupcxx_LIBS)
86
87
88# HAVE_LIBSTDC__
89AC_CHECK_LIB([stdc++], [__cxa_demangle], [
90	AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++])
91	libstdcxx_LIBS="-lstdc++"], [
92	libstdcxx_LIBS=""])
93AC_SUBST(libstdcxx_LIBS)
94
95
96dnl Check security_get_boolean_active availability.
97AC_CHECK_HEADERS(selinux/selinux.h)
98AC_CHECK_LIB(selinux, security_get_boolean_active)
99
100
101# HAVE_LIBUNWIND
102AC_ARG_WITH(libunwind,
103  AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]),
104  [case "${withval}" in
105  (yes|no) enable_libunwind=$withval;;
106  (*) enable_libunwind=yes
107    AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
108    AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
109    libunwind_LD_LIBRARY_PATH="${withval}/lib"
110    ;;
111esac],[enable_libunwind=maybe])
112
113saved_CPPFLAGS="${CPPFLAGS}"
114CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
115AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
116AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
117CPPFLAGS="${saved_CPPFLAGS}"
118
119AC_MSG_CHECKING([whether to use libunwind support])
120case "${enable_libunwind}" in
121(yes|maybe)
122  if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
123    enable_libunwind=yes
124  elif test $enable_libunwind = maybe; then
125    enable_libunwind=no
126  else
127    AC_MSG_RESULT([$enable_libunwind])
128    AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])	
129  fi
130  ;;
131(*) ;;
132esac
133AC_MSG_RESULT([$enable_libunwind])
134
135if test x"$enable_libunwind" = xyes; then
136  saved_LDFLAGS="${LDFLAGS}"
137  LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
138  AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
139  AC_SUBST(libunwind_LIBS)
140  AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
141  AC_SUBST(libunwind_ptrace_LIBS)
142
143  case "${host_cpu}" in
144      arm*|sa110)         UNWIND_ARCH="arm" ;;
145      i?86)               UNWIND_ARCH="x86" ;;
146      powerpc)            UNWIND_ARCH="ppc32" ;;
147      ppc64)              UNWIND_ARCH="ppc64" ;;
148      mips*)              UNWIND_ARCH="mips" ;;
149      *)                  UNWIND_ARCH="${host_cpu}" ;;
150  esac
151
152  AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=)
153  AC_SUBST(libunwind_arch_LIBS)
154  AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
155  LDFLAGS="${saved_LDFLAGS}"
156fi
157
158
159saved_CPPFLAGS="${CPPFLAGS}"
160saved_LDFLAGS="${LDFLAGS}"
161CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
162LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
163# HAVE_ELF_C_READ_MMAP
164AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
165AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
166int main () {
167	Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
168	return 0;
169}
170	]])],[
171	AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
172	AC_MSG_RESULT([yes])],[
173	AC_MSG_RESULT([no])])
174
175saved_CFLAGS="${CFLAGS}"
176CFLAGS="${CFLAGS} -Wall -Werror"
177AC_MSG_CHECKING([whether elf_hash takes a char* argument])
178AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[
179	(void) elf_hash("name");
180	]])],
181	[AC_DEFINE([ELF_HASH_TAKES_CHARP], [1],
182		[elf_hash() takes char* (as opposed to unsigned char *)])
183	 AC_MSG_RESULT([yes])],
184	[AC_MSG_RESULT([no])])
185CFLAGS="${saved_CFLAGS}"
186CPPFLAGS="${saved_CPPFLAGS}"
187LDFLAGS="${saved_LDFLAGS}"
188
189AM_CPPFLAGS=" \
190	${AM_CPPFLAGS} \
191	-I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
192	-I\$(top_srcdir)/sysdeps/${HOST_OS} \
193	-I\$(top_srcdir)/sysdeps \
194	-I\$(top_srcdir) \
195"
196
197# Checks for header files.
198AC_CHECK_HEADERS([ \
199	fcntl.h \
200	limits.h \
201	stddef.h \
202	stdint.h \
203	stdlib.h \
204	string.h \
205	sys/ioctl.h \
206	sys/param.h \
207	sys/time.h \
208	unistd.h \
209])
210
211# Checks for typedefs, structures, and compiler characteristics.
212AC_TYPE_UID_T
213AC_C_INLINE
214AC_TYPE_PID_T
215AC_TYPE_SIZE_T
216AC_CHECK_SIZEOF([long])
217
218
219# Checks for library functions.
220AC_FUNC_ERROR_AT_LINE
221AC_FUNC_FORK
222AC_CHECK_FUNCS([ \
223	alarm \
224	atexit \
225	getcwd \
226	gettimeofday \
227	memset \
228	mkdir \
229	rmdir \
230	strchr \
231	strdup \
232	strerror \
233	strtol \
234	strtoul \
235])
236
237
238#
239# Debugging
240#
241AC_MSG_CHECKING([whether to enable debugging])
242AC_ARG_ENABLE(debug,
243    AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
244	[case "$enableval" in
245	y | yes) CONFIG_DEBUG=yes ;;
246        *) CONFIG_DEBUG=no ;;
247    esac],
248    [CONFIG_DEBUG=no])
249AC_MSG_RESULT([${CONFIG_DEBUG}])
250if test "${CONFIG_DEBUG}" = "yes"; then
251    AC_DEFINE(DEBUG, 1, [debugging])
252fi
253
254# Ignore the compiler's warnings at your own risk.
255AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security"
256AC_ARG_ENABLE([werror],
257    AS_HELP_STRING([--disable-werror], [disable use of -Werror]),
258    [enable_werror=$enableval], [enable_werror=yes])
259if test x$enable_werror = xyes; then
260    AM_CFLAGS="${AM_CFLAGS} -Werror"
261fi
262
263AC_SUBST(AM_CPPFLAGS)
264AC_SUBST(AM_CFLAGS)
265AC_SUBST(AM_LDFLAGS)
266AC_SUBST(libelf_LD_LIBRARY_PATH)
267AC_SUBST(libunwind_LD_LIBRARY_PATH)
268
269AC_CONFIG_FILES([
270	Makefile
271	sysdeps/Makefile
272	sysdeps/linux-gnu/Makefile
273	sysdeps/linux-gnu/alpha/Makefile
274	sysdeps/linux-gnu/arm/Makefile
275	sysdeps/linux-gnu/cris/Makefile
276	sysdeps/linux-gnu/ia64/Makefile
277	sysdeps/linux-gnu/m68k/Makefile
278	sysdeps/linux-gnu/mipsel/Makefile
279	sysdeps/linux-gnu/ppc/Makefile
280	sysdeps/linux-gnu/s390/Makefile
281	sysdeps/linux-gnu/sparc/Makefile
282	sysdeps/linux-gnu/x86/Makefile
283	testsuite/Makefile
284	testsuite/ltrace.main/Makefile
285	testsuite/ltrace.minor/Makefile
286	testsuite/ltrace.torture/Makefile
287])
288AC_OUTPUT
289