blob: 30f5efc040fc83968866a64c067335b0ca153833 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
njn25ab726032002-09-23 16:24:41 +00002AC_INIT(coregrind/vg_clientmalloc.c) # give me a source file, any source file...
sewardjde4a1d02002-03-22 01:27:54 +00003AM_CONFIG_HEADER(config.h)
sewardjfa4b9b72002-11-13 21:35:53 +00004AM_INIT_AUTOMAKE(valgrind, 1.9.1)
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
njn25e49d8e72002-09-23 09:36:25 +000014AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000015AC_PROG_RANLIB
16
gobrye721a522002-03-22 13:38:30 +000017# Check for the compiler support
18if test "${GCC}" != "yes" ; then
19 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
20fi
21
daywalker48ccca52002-04-15 00:31:58 +000022# some older automake's don't have it so try something on our own
23ifdef([AM_PROG_AS],[AM_PROG_AS],
24[
gobry1be19852002-03-26 20:44:55 +000025AS="${CC}"
26AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000027
gobry1be19852002-03-26 20:44:55 +000028ASFLAGS=""
29AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000030])
gobry3b777892002-04-04 09:18:39 +000031
32# This variable will collect the individual suppression files
33# depending on the results of autoconf
34
35DEFAULT_SUPP=""
36
37
gobrye721a522002-03-22 13:38:30 +000038# We don't want gcc 2.7
39AC_MSG_CHECKING([for a supported version of gcc])
40
daywalker870ac4c2002-05-21 00:09:48 +000041gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000042
43case "${gcc_version}" in
44 gcc-2.7.*)
45 AC_MSG_RESULT([no (${gcc_version})])
46 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
47 ;;
48
49 *)
50 AC_MSG_RESULT([ok (${gcc_version})])
51 ;;
52esac
53
gobrye721a522002-03-22 13:38:30 +000054
sewardjde4a1d02002-03-22 01:27:54 +000055# Checks for the platform
56AC_CANONICAL_HOST
57
58AC_MSG_CHECKING([for a supported CPU])
59
gobrye721a522002-03-22 13:38:30 +000060case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000061 i?86)
62 AC_MSG_RESULT([ok (${host_cpu})])
63 ;;
64
65 *)
66 AC_MSG_RESULT([no (${host_cpu})])
67 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
68 ;;
69esac
70
71AC_MSG_CHECKING([for a supported OS])
72
gobrye721a522002-03-22 13:38:30 +000073case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000074 *linux*)
75 AC_MSG_RESULT([ok (${host_os})])
76 ;;
77
78 *)
79 AC_MSG_RESULT([no (${host_os})])
80 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
81 ;;
82esac
83
84
85# Ok, this is linux. Check the kernel version
86AC_MSG_CHECKING([for the kernel version])
87
88kernel=`uname -r`
89
gobrye721a522002-03-22 13:38:30 +000090case "${kernel}" in
sewardj2c216242002-12-14 23:49:42 +000091 2.5.*)
92 AC_MSG_RESULT([2.5 family (${kernel})])
93 AC_DEFINE([KERNEL_2_5], 1, [Define to 1 if you're using Linux 2.5.x])
94 ;;
95
sewardjde4a1d02002-03-22 01:27:54 +000096 2.4.*)
97 AC_MSG_RESULT([2.4 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +000098 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
sewardjde4a1d02002-03-22 01:27:54 +000099 ;;
100
101 2.2.*)
102 AC_MSG_RESULT([2.2 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000103 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
sewardjde4a1d02002-03-22 01:27:54 +0000104 ;;
105
106 *)
107 AC_MSG_RESULT([unsupported (${kernel})])
108 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
109 ;;
110esac
111
112AC_SUBST(DEFAULT_SUPP)
113
114
115# Ok, this is linux. Check the kernel version
116AC_MSG_CHECKING([the glibc version])
117
118glibc=""
119
120AC_EGREP_CPP([GLIBC_21], [
121#include <features.h>
122#ifdef __GNU_LIBRARY__
123 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
124 GLIBC_21
125 #endif
126#endif
127],
128glibc="2.1")
129
130AC_EGREP_CPP([GLIBC_22], [
131#include <features.h>
132#ifdef __GNU_LIBRARY__
133 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
134 GLIBC_22
135 #endif
136#endif
137],
138glibc="2.2")
139
sewardj08c7f012002-10-07 23:56:55 +0000140AC_EGREP_CPP([GLIBC_23], [
141#include <features.h>
142#ifdef __GNU_LIBRARY__
143 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
144 GLIBC_23
145 #endif
146#endif
147],
148glibc="2.3")
149
gobrye721a522002-03-22 13:38:30 +0000150case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000151 2.1)
152 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000153 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000154 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000155 ;;
156
157 2.2)
158 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000159 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000160 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000161 ;;
162
sewardj08c7f012002-10-07 23:56:55 +0000163 2.3)
164 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000165 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj08c7f012002-10-07 23:56:55 +0000166 ## Use the same suppression for as for 2.2.
167 ## This is a horrible hack that should be gotten
168 ## rid of. JRS, 20021007.
169 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
170 ;;
171
sewardjde4a1d02002-03-22 01:27:54 +0000172 *)
173 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000174 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000175 ;;
176esac
177
sewardj3e909ce2002-06-03 13:27:15 +0000178# APIs introduced in recent glibc versions
179
180AC_MSG_CHECKING([whether sched_param has a sched_priority member])
181AC_CACHE_VAL(vg_have_sched_priority,
182[
183AC_TRY_COMPILE([#include <pthread.h>],[
184struct sched_param p; p.sched_priority=1;],
185vg_have_sched_priority=yes,
186vg_have_sched_priority=no)
187])
188AC_MSG_RESULT($vg_have_sched_priority)
189if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000190AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000191fi
192
193AC_MSG_CHECKING([whether nfds_t is defined])
194AC_CACHE_VAL(vg_have_nfds_t,
195[
196AC_TRY_COMPILE([#include <sys/poll.h>],[
197nfds_t i=0;],
198vg_have_nfds_t=yes,
199vg_have_nfds_t=no)
200])
201AC_MSG_RESULT($vg_have_nfds_t)
202if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000203AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000204fi
205
sewardjde4a1d02002-03-22 01:27:54 +0000206# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000207# JRS 2002-06-17: this is completely bogus because it
208# detects the server version, whereas we need to know the
209# client library version. So what follows is hacked to
210# use all the X supp files regardless of what is detected.
211# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000212
gobrye721a522002-03-22 13:38:30 +0000213AC_PATH_X
214
215if test "${no_x}" != 'yes' ; then
216
217 AC_MSG_CHECKING([XFree version])
218
219 cat<<EOF > conftest.c
220#include <X11/Xlib.h>
221
222int main (int argc, char * argv [])
223{
224 Display * display = XOpenDisplay (NULL);
225
226 if (display) {
227 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
228 }
229
230 return 0;
231}
232EOF
233
234 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
235
236 if test "$?" != 0 ; then
237 AC_MSG_RESULT([cannot compile test program])
238 else
239 xfree=`./conftest`
240
241 case "${xfree}" in
242 *XFree86*)
243 ;;
244
245 *) AC_MSG_RESULT([not a XFree86 server])
246 ;;
247 esac
248
249 case "${xfree}" in
250
251 *version=4*)
252 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000253 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000254 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000255 # haaaaaaack!
256 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000257 ;;
258
259 *version=3*)
260 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000261 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000262 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000263 # haaaaaaack!
264 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000265 ;;
266
267 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000268 # haaaaaaack!
269 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
270 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000271 ;;
272 esac
273 fi
274
275 rm -f conftest conftest.c
276fi
277
sewardj5b754b42002-06-03 22:53:35 +0000278# does this compiler support -mpreferred-stack-boundary=2 ?
279AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
280
281CFLAGS="-mpreferred-stack-boundary=2"
282
283AC_TRY_COMPILE(, [
284
285int main () { return 0 ; }
286
287],
288[
289PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
290AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
291], [
292PREFERRED_STACK_BOUNDARY=""
293AC_MSG_RESULT([no])
294])
295
296AC_SUBST(PREFERRED_STACK_BOUNDARY)
297
298
299
sewardjde4a1d02002-03-22 01:27:54 +0000300# Checks for header files.
301AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000302AC_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 +0000303
304# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000305AC_TYPE_UID_T
306AC_TYPE_OFF_T
307AC_TYPE_SIZE_T
308AC_HEADER_TIME
309
310# Checks for library functions.
311AC_FUNC_MEMCMP
312AC_FUNC_MMAP
313AC_TYPE_SIGNAL
314
315AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
316
gobrye721a522002-03-22 13:38:30 +0000317AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000318 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000319 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000320 docs/Makefile
321 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000322 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000323 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000324 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000325 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000326 coregrind/Makefile
327 coregrind/demangle/Makefile
328 coregrind/docs/Makefile
329 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000330 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000331 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000332 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000333 memcheck/Makefile
334 memcheck/tests/Makefile
335 memcheck/docs/Makefile
336 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000337 cachegrind/tests/Makefile
338 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000339 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000340 corecheck/Makefile
341 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000342 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000343 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000344 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000345 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000346 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000347 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000348 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000349 none/Makefile
350 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000351 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000352)
gobry3b777892002-04-04 09:18:39 +0000353
354cat<<EOF
355
356Using the following suppressions by default:
357
358 ${DEFAULT_SUPP}
359EOF
360
361cat<<EOF > default.supp
362# This is a generated file, composed of the following suppression rules:
363#
364# ${DEFAULT_SUPP}
365#
366
367EOF
368
369for file in ${DEFAULT_SUPP} ; do
370 cat ${srcdir}/$file >> default.supp
371done