configure.ac revision ded5ea818c11020add67308cb67c67c33eb52175
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.59)
4
5AC_INIT([ltrace],[0.5.3],[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|powerpc64)	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
31AC_PROG_LIBTOOL
32# libtool-2:  LT_INIT()
33AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
34AM_MAINTAINER_MODE
35
36# Checks for libraries.
37
38# libelf
39AC_CHECK_HEADERS([elf.h gelf.h],,
40	[AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
41)
42AC_CHECK_LIB([elf], [elf_begin],,
43	[AC_MSG_ERROR([*** libelf not found on your system])]
44)
45
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
63# HAVE_LIBUNWIND
64AC_ARG_WITH(libunwind,
65  AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]),
66  [case "${withval}" in
67  (yes|no) enable_libunwind=$withval;;
68  (*) enable_libunwind=yes
69    CPPFLAGS="${CPPFLAGS} -I${withval}/include"
70    LDFLAGS="${LDFLAGS} -L${withval}/lib"
71    ;;
72esac],[enable_libunwind=maybe])
73
74AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
75AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
76
77AC_MSG_CHECKING([whether to use libunwind support])
78case "${enable_libunwind}" in
79(yes|maybe)
80  if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
81    enable_libunwind=yes
82  elif test $enable_libunwind = maybe; then
83    enable_libunwind=no
84  else
85    AC_MSG_RESULT([$enable_libunwind])
86    AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])	
87  fi
88  ;;
89(*) ;;
90esac
91AC_MSG_RESULT([$enable_libunwind])
92
93if test x"$enable_libunwind" = xyes; then
94  AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
95  AC_SUBST(libunwind_LIBS)
96  AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
97  AC_SUBST(libunwind_ptrace_LIBS)
98
99  case "${host_cpu}" in
100      arm*|sa110)         UNWIND_ARCH="arm" ;;
101      i?86)               UNWIND_ARCH="x86" ;;
102      powerpc)            UNWIND_ARCH="ppc32" ;;
103      ppc64)              UNWIND_ARCH="ppc64" ;;
104      mips*)              UNWIND_ARCH="mips" ;;
105      *)                  UNWIND_ARCH="${host_cpu}" ;;
106  esac
107
108  AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=)
109  AC_SUBST(libunwind_arch_LIBS)
110  AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
111fi
112
113
114# HAVE_ELF_C_READ_MMAP
115AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
116AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
117int main () {
118	Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
119	return 0;
120}
121	]])],[
122	AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
123	AC_MSG_RESULT([yes])],[
124	AC_MSG_RESULT([no])])
125
126
127CPPFLAGS=" \
128	${CPPFLAGS} \
129	-I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
130	-I\$(top_srcdir)/sysdeps/${HOST_OS} \
131	-I\$(top_srcdir)/sysdeps \
132	-I\$(top_srcdir) \
133"
134
135CFLAGS="${CFLAGS} -Wall"
136
137# Checks for header files.
138AC_CHECK_HEADERS([ \
139	fcntl.h \
140	limits.h \
141	stddef.h \
142	stdint.h \
143	stdlib.h \
144	string.h \
145	sys/ioctl.h \
146	sys/param.h \
147	sys/time.h \
148	unistd.h \
149])
150
151# Checks for typedefs, structures, and compiler characteristics.
152AC_TYPE_UID_T
153AC_C_INLINE
154AC_TYPE_PID_T
155AC_TYPE_SIZE_T
156AC_CHECK_SIZEOF([long])
157
158
159# Checks for library functions.
160AC_FUNC_ERROR_AT_LINE
161AC_FUNC_FORK
162AC_CHECK_FUNCS([ \
163	alarm \
164	atexit \
165	getcwd \
166	gettimeofday \
167	memset \
168	mkdir \
169	rmdir \
170	strchr \
171	strdup \
172	strerror \
173	strtol \
174	strtoul \
175])
176
177
178#
179# Debugging
180#
181AC_MSG_CHECKING([whether to enable debugging])
182AC_ARG_ENABLE(debug,
183    AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
184	[case "$enableval" in
185	y | yes) CONFIG_DEBUG=yes ;;
186        *) CONFIG_DEBUG=no ;;
187    esac],
188    [CONFIG_DEBUG=no])
189AC_MSG_RESULT([${CONFIG_DEBUG}])
190if test "${CONFIG_DEBUG}" = "yes"; then
191    CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1"
192    AC_DEFINE(DEBUG, 1, [debugging])
193else
194    CFLAGS="${CFLAGS} -O2"
195fi
196
197dnl 	testsuite/Makefile
198dnl 	testsuite/ltrace.main/Makefile
199dnl 	testsuite/ltrace.minor/Makefile
200dnl 	testsuite/ltrace.torture/Makefile
201
202AC_CONFIG_FILES([
203	Makefile
204	sysdeps/Makefile
205	sysdeps/linux-gnu/Makefile
206	sysdeps/linux-gnu/alpha/Makefile
207	sysdeps/linux-gnu/arm/Makefile
208	sysdeps/linux-gnu/i386/Makefile
209	sysdeps/linux-gnu/ia64/Makefile
210	sysdeps/linux-gnu/m68k/Makefile
211	sysdeps/linux-gnu/mipsel/Makefile
212	sysdeps/linux-gnu/ppc/Makefile
213	sysdeps/linux-gnu/s390/Makefile
214	sysdeps/linux-gnu/sparc/Makefile
215	sysdeps/linux-gnu/x86_64/Makefile
216	testsuite/Makefile
217	testsuite/ltrace.main/Makefile
218	testsuite/ltrace.minor/Makefile
219	testsuite/ltrace.torture/Makefile
220])
221AC_OUTPUT
222