blob: 091b4cebd7be86ed94cbe3161300abede1fcce3f [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)
sewardjaa4c2df2002-06-06 09:02:48 +00004AM_INIT_AUTOMAKE(valgrind, 20020606)
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
182
gobrye721a522002-03-22 13:38:30 +0000183AC_PATH_X
184
185if test "${no_x}" != 'yes' ; then
186
187 AC_MSG_CHECKING([XFree version])
188
189 cat<<EOF > conftest.c
190#include <X11/Xlib.h>
191
192int main (int argc, char * argv [])
193{
194 Display * display = XOpenDisplay (NULL);
195
196 if (display) {
197 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
198 }
199
200 return 0;
201}
202EOF
203
204 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
205
206 if test "$?" != 0 ; then
207 AC_MSG_RESULT([cannot compile test program])
208 else
209 xfree=`./conftest`
210
211 case "${xfree}" in
212 *XFree86*)
213 ;;
214
215 *) AC_MSG_RESULT([not a XFree86 server])
216 ;;
217 esac
218
219 case "${xfree}" in
220
221 *version=4*)
222 AC_MSG_RESULT([XFree 4.x family])
223 AC_DEFINE(XFREE_4)
gobry3b777892002-04-04 09:18:39 +0000224 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000225 ;;
226
227 *version=3*)
228 AC_MSG_RESULT([XFree 3.x family])
229 AC_DEFINE(XFREE_3)
sewardj19e6a4d2002-05-22 11:58:25 +0000230 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000231 ;;
232
233 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
234 ;;
235 esac
236 fi
237
238 rm -f conftest conftest.c
239fi
240
sewardj5b754b42002-06-03 22:53:35 +0000241# does this compiler support -mpreferred-stack-boundary=2 ?
242AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
243
244CFLAGS="-mpreferred-stack-boundary=2"
245
246AC_TRY_COMPILE(, [
247
248int main () { return 0 ; }
249
250],
251[
252PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
253AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
254], [
255PREFERRED_STACK_BOUNDARY=""
256AC_MSG_RESULT([no])
257])
258
259AC_SUBST(PREFERRED_STACK_BOUNDARY)
260
261
262
sewardjde4a1d02002-03-22 01:27:54 +0000263# Checks for header files.
264AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000265AC_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 +0000266
267# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000268AC_TYPE_UID_T
269AC_TYPE_OFF_T
270AC_TYPE_SIZE_T
271AC_HEADER_TIME
272
273# Checks for library functions.
274AC_FUNC_MEMCMP
275AC_FUNC_MMAP
276AC_TYPE_SIGNAL
277
278AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
279
gobrye721a522002-03-22 13:38:30 +0000280AC_OUTPUT(
sewardjaa6fecc2002-04-29 17:27:07 +0000281 vg_annotate
gobrye721a522002-03-22 13:38:30 +0000282 valgrind
283 valgrind.spec
sewardj83adf412002-05-01 01:25:45 +0000284 cachegrind
sewardjde4a1d02002-03-22 01:27:54 +0000285 Makefile
286 docs/Makefile
287 tests/Makefile
288 demangle/Makefile)
gobry3b777892002-04-04 09:18:39 +0000289
290cat<<EOF
291
292Using the following suppressions by default:
293
294 ${DEFAULT_SUPP}
295EOF
296
297cat<<EOF > default.supp
298# This is a generated file, composed of the following suppression rules:
299#
300# ${DEFAULT_SUPP}
301#
302
303EOF
304
305for file in ${DEFAULT_SUPP} ; do
306 cat ${srcdir}/$file >> default.supp
307done