configure.ac revision d91528913adb057d0681a98a959836f93ab564fe
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 <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
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)  enable_libunwind=yes ;;
68  no)   enable_libunwind=no ;;
69  *)    AC_MSG_ERROR(bad value ${withval} for GDB with-libunwind option) ;;
70esac],[
71  AC_CHECK_HEADERS(libunwind.h)
72  AC_CHECK_HEADERS(libunwind-ptrace.h)
73  if test x"$ac_cv_header_libunwind_h" = xyes; then
74    enable_libunwind=yes;
75  fi
76])
77
78if test x"$enable_libunwind" = xyes; then
79  AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
80  AC_SUBST(libunwind_LIBS)
81  AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
82  AC_SUBST(libunwind_ptrace_LIBS)
83  AC_CHECK_LIB(unwind-${HOST_CPU}, _U${HOST_CPU}_init_remote, libunwind_arch_LIBS=-lunwind-${HOST_CPU}, libunwind_arch_LIBS=)
84  AC_SUBST(libunwind_arch_LIBS)
85  AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
86fi
87
88
89# HAVE_ELF_C_READ_MMAP
90AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
91AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
92int main () {
93	Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
94	return 0;
95}
96	]])],[
97	AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
98	AC_MSG_RESULT([yes])],[
99	AC_MSG_RESULT([no])])
100
101
102CPPFLAGS=" \
103	${CPPFLAGS} \
104	-I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
105	-I\$(top_srcdir)/sysdeps/${HOST_OS} \
106	-I\$(top_srcdir)/sysdeps \
107	-I\$(top_srcdir) \
108"
109
110CFLAGS="${CFLAGS} -Wall"
111
112# Checks for header files.
113AC_CHECK_HEADERS([ \
114	fcntl.h \
115	limits.h \
116	stddef.h \
117	stdint.h \
118	stdlib.h \
119	string.h \
120	sys/ioctl.h \
121	sys/param.h \
122	sys/time.h \
123	unistd.h \
124])
125
126# Checks for typedefs, structures, and compiler characteristics.
127AC_TYPE_UID_T
128AC_C_INLINE
129AC_TYPE_PID_T
130AC_TYPE_SIZE_T
131AC_CHECK_SIZEOF([long])
132
133
134# Checks for library functions.
135AC_FUNC_ERROR_AT_LINE
136AC_FUNC_FORK
137AC_CHECK_FUNCS([ \
138	alarm \
139	atexit \
140	getcwd \
141	gettimeofday \
142	memset \
143	mkdir \
144	rmdir \
145	strchr \
146	strdup \
147	strerror \
148	strtol \
149	strtoul \
150])
151
152
153#
154# Debugging
155#
156AC_MSG_CHECKING([whether to enable debugging])
157AC_ARG_ENABLE(debug,
158    AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
159	[case "$enableval" in
160	y | yes) CONFIG_DEBUG=yes ;;
161        *) CONFIG_DEBUG=no ;;
162    esac],
163    [CONFIG_DEBUG=no])
164AC_MSG_RESULT([${CONFIG_DEBUG}])
165if test "${CONFIG_DEBUG}" = "yes"; then
166    CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1"
167    AC_DEFINE(DEBUG, 1, [debugging])
168else
169    CFLAGS="${CFLAGS} -O2"
170fi
171
172dnl 	testsuite/Makefile
173dnl 	testsuite/ltrace.main/Makefile
174dnl 	testsuite/ltrace.minor/Makefile
175dnl 	testsuite/ltrace.torture/Makefile
176
177AC_CONFIG_FILES([
178	Makefile
179	sysdeps/Makefile
180	sysdeps/linux-gnu/Makefile
181	sysdeps/linux-gnu/alpha/Makefile
182	sysdeps/linux-gnu/arm/Makefile
183	sysdeps/linux-gnu/i386/Makefile
184	sysdeps/linux-gnu/ia64/Makefile
185	sysdeps/linux-gnu/m68k/Makefile
186	sysdeps/linux-gnu/mipsel/Makefile
187	sysdeps/linux-gnu/ppc/Makefile
188	sysdeps/linux-gnu/s390/Makefile
189	sysdeps/linux-gnu/sparc/Makefile
190	sysdeps/linux-gnu/x86_64/Makefile
191])
192AC_OUTPUT
193