blob: 4782b8ca0bc10530cb4e84f579d36cea28a2017c [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
2AC_INIT(vg_clientmalloc.c)
3AM_CONFIG_HEADER(config.h)
sewardj9f4808b2002-06-03 01:30:32 +00004AM_INIT_AUTOMAKE(valgrind, 20020602)
sewardjde4a1d02002-03-22 01:27:54 +00005
gobryb0ed4672002-03-27 20:58:58 +00006AM_MAINTAINER_MODE
7
sewardjde4a1d02002-03-22 01:27:54 +00008# Checks for programs.
gobrye721a522002-03-22 13:38:30 +00009CFLAGS=""
10
sewardjde4a1d02002-03-22 01:27:54 +000011AC_PROG_LN_S
12AC_PROG_CC
13AC_PROG_CPP
14AC_PROG_RANLIB
15
gobrye721a522002-03-22 13:38:30 +000016# Check for the compiler support
17if test "${GCC}" != "yes" ; then
18 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
19fi
20
daywalker48ccca52002-04-15 00:31:58 +000021# some older automake's don't have it so try something on our own
22ifdef([AM_PROG_AS],[AM_PROG_AS],
23[
gobry1be19852002-03-26 20:44:55 +000024AS="${CC}"
25AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000026
gobry1be19852002-03-26 20:44:55 +000027ASFLAGS=""
28AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000029])
gobry3b777892002-04-04 09:18:39 +000030
31# This variable will collect the individual suppression files
32# depending on the results of autoconf
33
34DEFAULT_SUPP=""
35
36
gobrye721a522002-03-22 13:38:30 +000037# We don't want gcc 2.7
38AC_MSG_CHECKING([for a supported version of gcc])
39
daywalker870ac4c2002-05-21 00:09:48 +000040gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000041
42case "${gcc_version}" in
43 gcc-2.7.*)
44 AC_MSG_RESULT([no (${gcc_version})])
45 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
46 ;;
47
48 *)
49 AC_MSG_RESULT([ok (${gcc_version})])
50 ;;
51esac
52
53# does this compiler support -mpreferred-stack-boundary=2 ?
54AC_MSG_CHECKING([for extra compiler options])
55
56CFLAGS="-mpreferred-stack-boundary=2"
57
58AC_TRY_COMPILE(, [
59
60int main () { return 0 ; }
61
62],
63[
64PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
65AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
66], [
67PREFERRED_STACK_BOUNDARY=""
68AC_MSG_RESULT([none])
69])
70
71AC_SUBST(PREFERRED_STACK_BOUNDARY)
72
sewardjde4a1d02002-03-22 01:27:54 +000073# Checks for the platform
74AC_CANONICAL_HOST
75
76AC_MSG_CHECKING([for a supported CPU])
77
gobrye721a522002-03-22 13:38:30 +000078case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000079 i?86)
80 AC_MSG_RESULT([ok (${host_cpu})])
81 ;;
82
83 *)
84 AC_MSG_RESULT([no (${host_cpu})])
85 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
86 ;;
87esac
88
89AC_MSG_CHECKING([for a supported OS])
90
gobrye721a522002-03-22 13:38:30 +000091case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000092 *linux*)
93 AC_MSG_RESULT([ok (${host_os})])
94 ;;
95
96 *)
97 AC_MSG_RESULT([no (${host_os})])
98 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
99 ;;
100esac
101
102
103# Ok, this is linux. Check the kernel version
104AC_MSG_CHECKING([for the kernel version])
105
106kernel=`uname -r`
107
gobrye721a522002-03-22 13:38:30 +0000108case "${kernel}" in
sewardjde4a1d02002-03-22 01:27:54 +0000109 2.4.*)
110 AC_MSG_RESULT([2.4 family (${kernel})])
111 AC_DEFINE(KERNEL_2_4)
sewardjde4a1d02002-03-22 01:27:54 +0000112 ;;
113
114 2.2.*)
115 AC_MSG_RESULT([2.2 family (${kernel})])
116 AC_DEFINE(KERNEL_2_2)
sewardjde4a1d02002-03-22 01:27:54 +0000117 ;;
118
119 *)
120 AC_MSG_RESULT([unsupported (${kernel})])
121 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
122 ;;
123esac
124
125AC_SUBST(DEFAULT_SUPP)
126
127
128# Ok, this is linux. Check the kernel version
129AC_MSG_CHECKING([the glibc version])
130
131glibc=""
132
133AC_EGREP_CPP([GLIBC_21], [
134#include <features.h>
135#ifdef __GNU_LIBRARY__
136 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
137 GLIBC_21
138 #endif
139#endif
140],
141glibc="2.1")
142
143AC_EGREP_CPP([GLIBC_22], [
144#include <features.h>
145#ifdef __GNU_LIBRARY__
146 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
147 GLIBC_22
148 #endif
149#endif
150],
151glibc="2.2")
152
gobrye721a522002-03-22 13:38:30 +0000153case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000154 2.1)
155 AC_MSG_RESULT(2.1 family)
156 AC_DEFINE(GLIBC_2_1)
gobry3b777892002-04-04 09:18:39 +0000157 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000158 ;;
159
160 2.2)
161 AC_MSG_RESULT(2.2 family)
162 AC_DEFINE(GLIBC_2_2)
gobry3b777892002-04-04 09:18:39 +0000163 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000164 ;;
165
166 *)
167 AC_MSG_RESULT(unsupported version)
168 AC_MSG_ERROR([Valgrind requires the glibc version 2.1 or 2.2])
169 ;;
170esac
171
sewardj3e909ce2002-06-03 13:27:15 +0000172# APIs introduced in recent glibc versions
173
174AC_MSG_CHECKING([whether sched_param has a sched_priority member])
175AC_CACHE_VAL(vg_have_sched_priority,
176[
177AC_TRY_COMPILE([#include <pthread.h>],[
178struct sched_param p; p.sched_priority=1;],
179vg_have_sched_priority=yes,
180vg_have_sched_priority=no)
181])
182AC_MSG_RESULT($vg_have_sched_priority)
183if test "$vg_have_sched_priority" = yes; then
184AC_DEFINE(HAVE_SCHED_PRIORITY)
185fi
186
187AC_MSG_CHECKING([whether nfds_t is defined])
188AC_CACHE_VAL(vg_have_nfds_t,
189[
190AC_TRY_COMPILE([#include <sys/poll.h>],[
191nfds_t i=0;],
192vg_have_nfds_t=yes,
193vg_have_nfds_t=no)
194])
195AC_MSG_RESULT($vg_have_nfds_t)
196if test "$vg_have_nfds_t" = yes; then
197AC_DEFINE(HAVE_NFDS_T)
198fi
199
sewardjde4a1d02002-03-22 01:27:54 +0000200# try to detect the XFree version
201
gobrye721a522002-03-22 13:38:30 +0000202AC_PATH_X
203
204if test "${no_x}" != 'yes' ; then
205
206 AC_MSG_CHECKING([XFree version])
207
208 cat<<EOF > conftest.c
209#include <X11/Xlib.h>
210
211int main (int argc, char * argv [])
212{
213 Display * display = XOpenDisplay (NULL);
214
215 if (display) {
216 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
217 }
218
219 return 0;
220}
221EOF
222
223 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
224
225 if test "$?" != 0 ; then
226 AC_MSG_RESULT([cannot compile test program])
227 else
228 xfree=`./conftest`
229
230 case "${xfree}" in
231 *XFree86*)
232 ;;
233
234 *) AC_MSG_RESULT([not a XFree86 server])
235 ;;
236 esac
237
238 case "${xfree}" in
239
240 *version=4*)
241 AC_MSG_RESULT([XFree 4.x family])
242 AC_DEFINE(XFREE_4)
gobry3b777892002-04-04 09:18:39 +0000243 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000244 ;;
245
246 *version=3*)
247 AC_MSG_RESULT([XFree 3.x family])
248 AC_DEFINE(XFREE_3)
sewardj19e6a4d2002-05-22 11:58:25 +0000249 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000250 ;;
251
252 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
253 ;;
254 esac
255 fi
256
257 rm -f conftest conftest.c
258fi
259
sewardjde4a1d02002-03-22 01:27:54 +0000260# Checks for header files.
261AC_HEADER_STDC
262AC_CHECK_HEADERS([fcntl.h malloc.h stdlib.h string.h sys/socket.h sys/statfs.h sys/time.h termios.h unistd.h utime.h])
263
264# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000265AC_TYPE_UID_T
266AC_TYPE_OFF_T
267AC_TYPE_SIZE_T
268AC_HEADER_TIME
269
270# Checks for library functions.
271AC_FUNC_MEMCMP
272AC_FUNC_MMAP
273AC_TYPE_SIGNAL
274
275AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
276
gobrye721a522002-03-22 13:38:30 +0000277AC_OUTPUT(
sewardjaa6fecc2002-04-29 17:27:07 +0000278 vg_annotate
279 vg_cachegen
gobrye721a522002-03-22 13:38:30 +0000280 valgrind
281 valgrind.spec
sewardj83adf412002-05-01 01:25:45 +0000282 cachegrind
sewardjde4a1d02002-03-22 01:27:54 +0000283 Makefile
284 docs/Makefile
285 tests/Makefile
286 demangle/Makefile)
gobry3b777892002-04-04 09:18:39 +0000287
288cat<<EOF
289
290Using the following suppressions by default:
291
292 ${DEFAULT_SUPP}
293EOF
294
295cat<<EOF > default.supp
296# This is a generated file, composed of the following suppression rules:
297#
298# ${DEFAULT_SUPP}
299#
300
301EOF
302
303for file in ${DEFAULT_SUPP} ; do
304 cat ${srcdir}/$file >> default.supp
305done