blob: 2db8a72413ee3251669193de982f394cf042ca8c [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)
sewardj9b9e10a2002-06-14 10:40:16 +00004AM_INIT_AUTOMAKE(valgrind, 1.0pre1)
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
gobrye721a522002-03-22 13:38:30 +000053
sewardjde4a1d02002-03-22 01:27:54 +000054# Checks for the platform
55AC_CANONICAL_HOST
56
57AC_MSG_CHECKING([for a supported CPU])
58
gobrye721a522002-03-22 13:38:30 +000059case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000060 i?86)
61 AC_MSG_RESULT([ok (${host_cpu})])
62 ;;
63
64 *)
65 AC_MSG_RESULT([no (${host_cpu})])
66 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
67 ;;
68esac
69
70AC_MSG_CHECKING([for a supported OS])
71
gobrye721a522002-03-22 13:38:30 +000072case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000073 *linux*)
74 AC_MSG_RESULT([ok (${host_os})])
75 ;;
76
77 *)
78 AC_MSG_RESULT([no (${host_os})])
79 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
80 ;;
81esac
82
83
84# Ok, this is linux. Check the kernel version
85AC_MSG_CHECKING([for the kernel version])
86
87kernel=`uname -r`
88
gobrye721a522002-03-22 13:38:30 +000089case "${kernel}" in
sewardjde4a1d02002-03-22 01:27:54 +000090 2.4.*)
91 AC_MSG_RESULT([2.4 family (${kernel})])
92 AC_DEFINE(KERNEL_2_4)
sewardjde4a1d02002-03-22 01:27:54 +000093 ;;
94
95 2.2.*)
96 AC_MSG_RESULT([2.2 family (${kernel})])
97 AC_DEFINE(KERNEL_2_2)
sewardjde4a1d02002-03-22 01:27:54 +000098 ;;
99
100 *)
101 AC_MSG_RESULT([unsupported (${kernel})])
102 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
103 ;;
104esac
105
106AC_SUBST(DEFAULT_SUPP)
107
108
109# Ok, this is linux. Check the kernel version
110AC_MSG_CHECKING([the glibc version])
111
112glibc=""
113
114AC_EGREP_CPP([GLIBC_21], [
115#include <features.h>
116#ifdef __GNU_LIBRARY__
117 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
118 GLIBC_21
119 #endif
120#endif
121],
122glibc="2.1")
123
124AC_EGREP_CPP([GLIBC_22], [
125#include <features.h>
126#ifdef __GNU_LIBRARY__
127 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
128 GLIBC_22
129 #endif
130#endif
131],
132glibc="2.2")
133
gobrye721a522002-03-22 13:38:30 +0000134case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000135 2.1)
136 AC_MSG_RESULT(2.1 family)
137 AC_DEFINE(GLIBC_2_1)
gobry3b777892002-04-04 09:18:39 +0000138 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000139 ;;
140
141 2.2)
142 AC_MSG_RESULT(2.2 family)
143 AC_DEFINE(GLIBC_2_2)
gobry3b777892002-04-04 09:18:39 +0000144 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000145 ;;
146
147 *)
148 AC_MSG_RESULT(unsupported version)
149 AC_MSG_ERROR([Valgrind requires the glibc version 2.1 or 2.2])
150 ;;
151esac
152
sewardj3e909ce2002-06-03 13:27:15 +0000153# APIs introduced in recent glibc versions
154
155AC_MSG_CHECKING([whether sched_param has a sched_priority member])
156AC_CACHE_VAL(vg_have_sched_priority,
157[
158AC_TRY_COMPILE([#include <pthread.h>],[
159struct sched_param p; p.sched_priority=1;],
160vg_have_sched_priority=yes,
161vg_have_sched_priority=no)
162])
163AC_MSG_RESULT($vg_have_sched_priority)
164if test "$vg_have_sched_priority" = yes; then
165AC_DEFINE(HAVE_SCHED_PRIORITY)
166fi
167
168AC_MSG_CHECKING([whether nfds_t is defined])
169AC_CACHE_VAL(vg_have_nfds_t,
170[
171AC_TRY_COMPILE([#include <sys/poll.h>],[
172nfds_t i=0;],
173vg_have_nfds_t=yes,
174vg_have_nfds_t=no)
175])
176AC_MSG_RESULT($vg_have_nfds_t)
177if test "$vg_have_nfds_t" = yes; then
178AC_DEFINE(HAVE_NFDS_T)
179fi
180
sewardjde4a1d02002-03-22 01:27:54 +0000181# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000182# JRS 2002-06-17: this is completely bogus because it
183# detects the server version, whereas we need to know the
184# client library version. So what follows is hacked to
185# use all the X supp files regardless of what is detected.
186# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000187
gobrye721a522002-03-22 13:38:30 +0000188AC_PATH_X
189
190if test "${no_x}" != 'yes' ; then
191
192 AC_MSG_CHECKING([XFree version])
193
194 cat<<EOF > conftest.c
195#include <X11/Xlib.h>
196
197int main (int argc, char * argv [])
198{
199 Display * display = XOpenDisplay (NULL);
200
201 if (display) {
202 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
203 }
204
205 return 0;
206}
207EOF
208
209 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
210
211 if test "$?" != 0 ; then
212 AC_MSG_RESULT([cannot compile test program])
213 else
214 xfree=`./conftest`
215
216 case "${xfree}" in
217 *XFree86*)
218 ;;
219
220 *) AC_MSG_RESULT([not a XFree86 server])
221 ;;
222 esac
223
224 case "${xfree}" in
225
226 *version=4*)
227 AC_MSG_RESULT([XFree 4.x family])
228 AC_DEFINE(XFREE_4)
gobry3b777892002-04-04 09:18:39 +0000229 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000230 # haaaaaaack!
231 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000232 ;;
233
234 *version=3*)
235 AC_MSG_RESULT([XFree 3.x family])
236 AC_DEFINE(XFREE_3)
sewardj19e6a4d2002-05-22 11:58:25 +0000237 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000238 # haaaaaaack!
239 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000240 ;;
241
242 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000243 # haaaaaaack!
244 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
245 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000246 ;;
247 esac
248 fi
249
250 rm -f conftest conftest.c
251fi
252
sewardj5b754b42002-06-03 22:53:35 +0000253# does this compiler support -mpreferred-stack-boundary=2 ?
254AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
255
256CFLAGS="-mpreferred-stack-boundary=2"
257
258AC_TRY_COMPILE(, [
259
260int main () { return 0 ; }
261
262],
263[
264PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
265AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
266], [
267PREFERRED_STACK_BOUNDARY=""
268AC_MSG_RESULT([no])
269])
270
271AC_SUBST(PREFERRED_STACK_BOUNDARY)
272
273
274
sewardjde4a1d02002-03-22 01:27:54 +0000275# Checks for header files.
276AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000277AC_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])
sewardjde4a1d02002-03-22 01:27:54 +0000278
279# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000280AC_TYPE_UID_T
281AC_TYPE_OFF_T
282AC_TYPE_SIZE_T
283AC_HEADER_TIME
284
285# Checks for library functions.
286AC_FUNC_MEMCMP
287AC_FUNC_MMAP
288AC_TYPE_SIGNAL
289
290AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
291
gobrye721a522002-03-22 13:38:30 +0000292AC_OUTPUT(
sewardjaa6fecc2002-04-29 17:27:07 +0000293 vg_annotate
gobrye721a522002-03-22 13:38:30 +0000294 valgrind
295 valgrind.spec
sewardj83adf412002-05-01 01:25:45 +0000296 cachegrind
sewardjde4a1d02002-03-22 01:27:54 +0000297 Makefile
298 docs/Makefile
299 tests/Makefile
300 demangle/Makefile)
gobry3b777892002-04-04 09:18:39 +0000301
302cat<<EOF
303
304Using the following suppressions by default:
305
306 ${DEFAULT_SUPP}
307EOF
308
309cat<<EOF > default.supp
310# This is a generated file, composed of the following suppression rules:
311#
312# ${DEFAULT_SUPP}
313#
314
315EOF
316
317for file in ${DEFAULT_SUPP} ; do
318 cat ${srcdir}/$file >> default.supp
319done