blob: 9712b738264db945447eba3ddbd0fbe4ca78e1d3 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
njn3e884182003-04-15 13:03:23 +00002AC_INIT(coregrind/vg_main.c) # give me a source file, any source file...
sewardjde4a1d02002-03-22 01:27:54 +00003AM_CONFIG_HEADER(config.h)
sewardjcc731c02003-02-24 21:59:31 +00004AM_INIT_AUTOMAKE(valgrind, 1.9.4)
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
sewardj2f685952002-12-22 19:32:23 +000022# figure out where perl lives
23AC_PATH_PROG(PERL, perl)
24
njn9315df32003-04-16 20:50:50 +000025# figure out where gdb lives
26AC_PATH_PROG(GDB, gdb)
27
daywalker48ccca52002-04-15 00:31:58 +000028# some older automake's don't have it so try something on our own
29ifdef([AM_PROG_AS],[AM_PROG_AS],
30[
gobry1be19852002-03-26 20:44:55 +000031AS="${CC}"
32AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000033
gobry1be19852002-03-26 20:44:55 +000034ASFLAGS=""
35AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000036])
gobry3b777892002-04-04 09:18:39 +000037
38# This variable will collect the individual suppression files
39# depending on the results of autoconf
40
41DEFAULT_SUPP=""
42
43
gobrye721a522002-03-22 13:38:30 +000044# We don't want gcc 2.7
45AC_MSG_CHECKING([for a supported version of gcc])
46
daywalker870ac4c2002-05-21 00:09:48 +000047gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000048
49case "${gcc_version}" in
50 gcc-2.7.*)
51 AC_MSG_RESULT([no (${gcc_version})])
52 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
53 ;;
54
55 *)
56 AC_MSG_RESULT([ok (${gcc_version})])
57 ;;
58esac
59
gobrye721a522002-03-22 13:38:30 +000060
sewardjde4a1d02002-03-22 01:27:54 +000061# Checks for the platform
62AC_CANONICAL_HOST
63
64AC_MSG_CHECKING([for a supported CPU])
65
gobrye721a522002-03-22 13:38:30 +000066case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000067 i?86)
68 AC_MSG_RESULT([ok (${host_cpu})])
69 ;;
70
71 *)
72 AC_MSG_RESULT([no (${host_cpu})])
73 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
74 ;;
75esac
76
77AC_MSG_CHECKING([for a supported OS])
78
gobrye721a522002-03-22 13:38:30 +000079case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000080 *linux*)
81 AC_MSG_RESULT([ok (${host_os})])
82 ;;
83
84 *)
85 AC_MSG_RESULT([no (${host_os})])
86 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
87 ;;
88esac
89
90
91# Ok, this is linux. Check the kernel version
92AC_MSG_CHECKING([for the kernel version])
93
94kernel=`uname -r`
95
gobrye721a522002-03-22 13:38:30 +000096case "${kernel}" in
sewardj2c216242002-12-14 23:49:42 +000097 2.5.*)
98 AC_MSG_RESULT([2.5 family (${kernel})])
99 AC_DEFINE([KERNEL_2_5], 1, [Define to 1 if you're using Linux 2.5.x])
100 ;;
101
sewardjde4a1d02002-03-22 01:27:54 +0000102 2.4.*)
103 AC_MSG_RESULT([2.4 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000104 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
sewardjde4a1d02002-03-22 01:27:54 +0000105 ;;
106
107 2.2.*)
108 AC_MSG_RESULT([2.2 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000109 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
sewardjde4a1d02002-03-22 01:27:54 +0000110 ;;
111
112 *)
113 AC_MSG_RESULT([unsupported (${kernel})])
114 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
115 ;;
116esac
117
118AC_SUBST(DEFAULT_SUPP)
119
120
121# Ok, this is linux. Check the kernel version
122AC_MSG_CHECKING([the glibc version])
123
124glibc=""
125
126AC_EGREP_CPP([GLIBC_21], [
127#include <features.h>
128#ifdef __GNU_LIBRARY__
129 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
130 GLIBC_21
131 #endif
132#endif
133],
134glibc="2.1")
135
136AC_EGREP_CPP([GLIBC_22], [
137#include <features.h>
138#ifdef __GNU_LIBRARY__
139 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
140 GLIBC_22
141 #endif
142#endif
143],
144glibc="2.2")
145
sewardj08c7f012002-10-07 23:56:55 +0000146AC_EGREP_CPP([GLIBC_23], [
147#include <features.h>
148#ifdef __GNU_LIBRARY__
149 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
150 GLIBC_23
151 #endif
152#endif
153],
154glibc="2.3")
155
gobrye721a522002-03-22 13:38:30 +0000156case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000157 2.1)
158 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000159 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000160 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000161 ;;
162
163 2.2)
164 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000165 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000166 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000167 ;;
168
sewardj08c7f012002-10-07 23:56:55 +0000169 2.3)
170 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000171 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj08c7f012002-10-07 23:56:55 +0000172 ## Use the same suppression for as for 2.2.
173 ## This is a horrible hack that should be gotten
174 ## rid of. JRS, 20021007.
175 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
176 ;;
177
sewardjde4a1d02002-03-22 01:27:54 +0000178 *)
179 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000180 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000181 ;;
182esac
183
sewardj3e909ce2002-06-03 13:27:15 +0000184# APIs introduced in recent glibc versions
185
186AC_MSG_CHECKING([whether sched_param has a sched_priority member])
187AC_CACHE_VAL(vg_have_sched_priority,
188[
189AC_TRY_COMPILE([#include <pthread.h>],[
190struct sched_param p; p.sched_priority=1;],
191vg_have_sched_priority=yes,
192vg_have_sched_priority=no)
193])
194AC_MSG_RESULT($vg_have_sched_priority)
195if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000196AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000197fi
198
199AC_MSG_CHECKING([whether nfds_t is defined])
200AC_CACHE_VAL(vg_have_nfds_t,
201[
202AC_TRY_COMPILE([#include <sys/poll.h>],[
203nfds_t i=0;],
204vg_have_nfds_t=yes,
205vg_have_nfds_t=no)
206])
207AC_MSG_RESULT($vg_have_nfds_t)
208if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000209AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000210fi
211
sewardjde4a1d02002-03-22 01:27:54 +0000212# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000213# JRS 2002-06-17: this is completely bogus because it
214# detects the server version, whereas we need to know the
215# client library version. So what follows is hacked to
216# use all the X supp files regardless of what is detected.
217# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000218
gobrye721a522002-03-22 13:38:30 +0000219AC_PATH_X
220
221if test "${no_x}" != 'yes' ; then
222
223 AC_MSG_CHECKING([XFree version])
224
225 cat<<EOF > conftest.c
226#include <X11/Xlib.h>
227
228int main (int argc, char * argv [])
229{
230 Display * display = XOpenDisplay (NULL);
231
232 if (display) {
233 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
234 }
235
236 return 0;
237}
238EOF
239
240 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
241
242 if test "$?" != 0 ; then
243 AC_MSG_RESULT([cannot compile test program])
244 else
245 xfree=`./conftest`
246
247 case "${xfree}" in
248 *XFree86*)
249 ;;
250
251 *) AC_MSG_RESULT([not a XFree86 server])
252 ;;
253 esac
254
255 case "${xfree}" in
256
257 *version=4*)
258 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000259 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000260 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000261 # haaaaaaack!
262 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000263 ;;
264
265 *version=3*)
266 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000267 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000268 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000269 # haaaaaaack!
270 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000271 ;;
272
273 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000274 # haaaaaaack!
275 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
276 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000277 ;;
278 esac
279 fi
280
281 rm -f conftest conftest.c
282fi
283
sewardj2e10a682003-04-07 19:36:41 +0000284
285
286
287
288AC_MSG_CHECKING([if this is an NPTL-based system])
289
290cat<<EOG > nptltest.c
291#include <pthread.h>
292#include <stdio.h>
293int main (int argc, char * argv [])
294{
295 int ret;
296 pthread_mutexattr_t mutexattr;
297 ret = pthread_mutexattr_init (&mutexattr);
298 if (ret == 0) {
299 ret = pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
300 if (ret == 0) /* nptl */
301 printf("yes");
302 else /* not nptl */
303 printf("no");
304 return 0;
305 }
306 return 1;
307}
308EOG
309
310${CC} -o nptltest nptltest.c -lpthread >&5 2>&1
311have_nptl=`./nptltest`
312
313if test "$?" != 0 ; then
314 AC_MSG_RESULT([couldn't run test program])
315 NPTL_THREADING="no"
316else
317 if test "${have_nptl}" == 'yes' ; then
318 NPTL_THREADING="yes"
319 AC_MSG_RESULT([yes])
320 else
321 NPTL_THREADING="no"
322 AC_MSG_RESULT([no])
323 fi
324fi
325
326AC_SUBST(NPTL_THREADING)
327
328
sewardj5b754b42002-06-03 22:53:35 +0000329# does this compiler support -mpreferred-stack-boundary=2 ?
330AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
331
332CFLAGS="-mpreferred-stack-boundary=2"
333
334AC_TRY_COMPILE(, [
335
336int main () { return 0 ; }
337
338],
339[
340PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
341AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
342], [
343PREFERRED_STACK_BOUNDARY=""
344AC_MSG_RESULT([no])
345])
346
347AC_SUBST(PREFERRED_STACK_BOUNDARY)
348
349
350
sewardjde4a1d02002-03-22 01:27:54 +0000351# Checks for header files.
352AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000353AC_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 +0000354
355# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000356AC_TYPE_UID_T
357AC_TYPE_OFF_T
358AC_TYPE_SIZE_T
359AC_HEADER_TIME
360
361# Checks for library functions.
362AC_FUNC_MEMCMP
363AC_FUNC_MMAP
364AC_TYPE_SIGNAL
365
366AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
367
gobrye721a522002-03-22 13:38:30 +0000368AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000369 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000370 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000371 docs/Makefile
372 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000373 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000374 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000375 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000376 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000377 coregrind/Makefile
378 coregrind/demangle/Makefile
379 coregrind/docs/Makefile
380 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000381 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000382 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000383 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000384 memcheck/Makefile
385 memcheck/tests/Makefile
386 memcheck/docs/Makefile
387 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000388 cachegrind/tests/Makefile
389 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000390 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000391 corecheck/Makefile
392 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000393 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000394 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000395 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000396 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000397 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000398 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000399 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000400 none/Makefile
401 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000402 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000403)
gobry3b777892002-04-04 09:18:39 +0000404
405cat<<EOF
406
407Using the following suppressions by default:
408
409 ${DEFAULT_SUPP}
410EOF
411
412cat<<EOF > default.supp
413# This is a generated file, composed of the following suppression rules:
414#
415# ${DEFAULT_SUPP}
416#
417
418EOF
419
420for file in ${DEFAULT_SUPP} ; do
421 cat ${srcdir}/$file >> default.supp
422done