blob: 30c215b7dcad005cf20004ede20d43c591d402ed [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)
jseward684ac092004-07-18 11:47:55 +00004AM_INIT_AUTOMAKE(valgrind, 2.1.3.CVS)
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)
njn17b85352003-04-18 12:54:24 +000027# autoheader tries to execute the 3rd string or something; I get warnings when
28# it's defined. So just leave it undefined. --njn 2002-Apr-18
29AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", "")
njn9315df32003-04-16 20:50:50 +000030
daywalker48ccca52002-04-15 00:31:58 +000031# some older automake's don't have it so try something on our own
32ifdef([AM_PROG_AS],[AM_PROG_AS],
33[
gobry1be19852002-03-26 20:44:55 +000034AS="${CC}"
35AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000036
gobry1be19852002-03-26 20:44:55 +000037ASFLAGS=""
38AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000039])
gobry3b777892002-04-04 09:18:39 +000040
41# This variable will collect the individual suppression files
42# depending on the results of autoconf
43
44DEFAULT_SUPP=""
45
46
gobrye721a522002-03-22 13:38:30 +000047# We don't want gcc 2.7
48AC_MSG_CHECKING([for a supported version of gcc])
49
daywalker870ac4c2002-05-21 00:09:48 +000050gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000051
52case "${gcc_version}" in
53 gcc-2.7.*)
54 AC_MSG_RESULT([no (${gcc_version})])
55 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
56 ;;
57
58 *)
59 AC_MSG_RESULT([ok (${gcc_version})])
60 ;;
61esac
62
gobrye721a522002-03-22 13:38:30 +000063
sewardjde4a1d02002-03-22 01:27:54 +000064# Checks for the platform
65AC_CANONICAL_HOST
66
67AC_MSG_CHECKING([for a supported CPU])
nethercote888ecb72004-08-23 14:54:40 +000068AC_SUBST(VG_ARCH)
sewardjde4a1d02002-03-22 01:27:54 +000069
gobrye721a522002-03-22 13:38:30 +000070case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000071 i?86)
72 AC_MSG_RESULT([ok (${host_cpu})])
nethercote888ecb72004-08-23 14:54:40 +000073 VG_ARCH="x86"
sewardjde4a1d02002-03-22 01:27:54 +000074 ;;
75
76 *)
77 AC_MSG_RESULT([no (${host_cpu})])
78 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
79 ;;
80esac
81
82AC_MSG_CHECKING([for a supported OS])
nethercote888ecb72004-08-23 14:54:40 +000083AC_SUBST(VG_OS)
sewardjde4a1d02002-03-22 01:27:54 +000084
gobrye721a522002-03-22 13:38:30 +000085case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +000086 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +000087 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +000088 VG_OS="linux"
mueller8c68e042004-01-03 15:21:14 +000089
90 # Ok, this is linux. Check the kernel version
91 AC_MSG_CHECKING([for the kernel version])
92
93 kernel=`uname -r`
94
95 case "${kernel}" in
96 2.6.*)
97 AC_MSG_RESULT([2.6 family (${kernel})])
98 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
99 ;;
100
101 2.4.*)
102 AC_MSG_RESULT([2.4 family (${kernel})])
103 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
104 ;;
105
106 2.2.*)
107 AC_MSG_RESULT([2.2 family (${kernel})])
108 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
109 ;;
110
111 *)
112 AC_MSG_RESULT([unsupported (${kernel})])
113 AC_MSG_ERROR([Valgrind works on kernels 2.2, 2.4, 2.6])
114 ;;
115 esac
116
117 ;;
118
119 *freebsd*)
120 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000121 VG_OS="freebsd"
sewardjde4a1d02002-03-22 01:27:54 +0000122 ;;
123
124 *)
125 AC_MSG_RESULT([no (${host_os})])
mueller8c68e042004-01-03 15:21:14 +0000126 AC_MSG_ERROR([Valgrind is operating system specific. Sorry. Please consider doing a port.])
sewardjde4a1d02002-03-22 01:27:54 +0000127 ;;
128esac
129
nethercote888ecb72004-08-23 14:54:40 +0000130AC_MSG_CHECKING([for a supported CPU/OS combination])
131AC_SUBST(VG_PLATFORM)
132
133VG_PLATFORM="$VG_ARCH-$VG_OS"
134
135case $VG_PLATFORM in
136 x86-linux)
137 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
138 ;;
139
140 *)
141 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
142 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doin
143g a port.])
144 ;;
145esac
sewardjde4a1d02002-03-22 01:27:54 +0000146
sewardjde4a1d02002-03-22 01:27:54 +0000147AC_SUBST(DEFAULT_SUPP)
148
sewardjde4a1d02002-03-22 01:27:54 +0000149glibc=""
150
151AC_EGREP_CPP([GLIBC_21], [
152#include <features.h>
153#ifdef __GNU_LIBRARY__
154 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
155 GLIBC_21
156 #endif
157#endif
158],
159glibc="2.1")
160
161AC_EGREP_CPP([GLIBC_22], [
162#include <features.h>
163#ifdef __GNU_LIBRARY__
164 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
165 GLIBC_22
166 #endif
167#endif
168],
169glibc="2.2")
170
sewardj08c7f012002-10-07 23:56:55 +0000171AC_EGREP_CPP([GLIBC_23], [
172#include <features.h>
173#ifdef __GNU_LIBRARY__
174 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
175 GLIBC_23
176 #endif
177#endif
178],
179glibc="2.3")
180
daywalkere9212b32003-06-15 22:39:15 +0000181# Ok, this is linux. Check the kernel version
182AC_MSG_CHECKING([the glibc version])
183
gobrye721a522002-03-22 13:38:30 +0000184case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000185 2.1)
186 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000187 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000188 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000189 ;;
190
191 2.2)
192 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000193 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000194 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000195 ;;
196
sewardj08c7f012002-10-07 23:56:55 +0000197 2.3)
198 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000199 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
daywalker63f6f782003-05-27 00:19:52 +0000200 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.3.supp"
sewardj08c7f012002-10-07 23:56:55 +0000201 ;;
202
sewardjde4a1d02002-03-22 01:27:54 +0000203 *)
204 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000205 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000206 ;;
207esac
208
sewardj3e909ce2002-06-03 13:27:15 +0000209# APIs introduced in recent glibc versions
210
211AC_MSG_CHECKING([whether sched_param has a sched_priority member])
212AC_CACHE_VAL(vg_have_sched_priority,
213[
214AC_TRY_COMPILE([#include <pthread.h>],[
215struct sched_param p; p.sched_priority=1;],
216vg_have_sched_priority=yes,
217vg_have_sched_priority=no)
218])
219AC_MSG_RESULT($vg_have_sched_priority)
220if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000221AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000222fi
223
224AC_MSG_CHECKING([whether nfds_t is defined])
225AC_CACHE_VAL(vg_have_nfds_t,
226[
227AC_TRY_COMPILE([#include <sys/poll.h>],[
228nfds_t i=0;],
229vg_have_nfds_t=yes,
230vg_have_nfds_t=no)
231])
232AC_MSG_RESULT($vg_have_nfds_t)
233if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000234AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000235fi
236
sewardjde4a1d02002-03-22 01:27:54 +0000237# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000238# JRS 2002-06-17: this is completely bogus because it
239# detects the server version, whereas we need to know the
240# client library version. So what follows is hacked to
241# use all the X supp files regardless of what is detected.
242# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000243
gobrye721a522002-03-22 13:38:30 +0000244AC_PATH_X
245
246if test "${no_x}" != 'yes' ; then
247
248 AC_MSG_CHECKING([XFree version])
249
250 cat<<EOF > conftest.c
251#include <X11/Xlib.h>
252
253int main (int argc, char * argv [])
254{
255 Display * display = XOpenDisplay (NULL);
256
257 if (display) {
258 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
259 }
260
261 return 0;
262}
263EOF
264
265 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
266
267 if test "$?" != 0 ; then
268 AC_MSG_RESULT([cannot compile test program])
269 else
270 xfree=`./conftest`
271
272 case "${xfree}" in
273 *XFree86*)
274 ;;
275
276 *) AC_MSG_RESULT([not a XFree86 server])
277 ;;
278 esac
279
280 case "${xfree}" in
281
282 *version=4*)
283 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000284 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000285 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000286 # haaaaaaack!
287 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000288 ;;
289
290 *version=3*)
291 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000292 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000293 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000294 # haaaaaaack!
295 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000296 ;;
297
298 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000299 # haaaaaaack!
300 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
301 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000302 ;;
303 esac
304 fi
305
306 rm -f conftest conftest.c
307fi
308
sewardj2e10a682003-04-07 19:36:41 +0000309
daywalker3664f562003-10-17 13:43:46 +0000310# check if the GNU as supports CFI directives
311AC_MSG_CHECKING([if gas accepts .cfi])
muellerece14bd2003-10-31 03:43:48 +0000312AC_TRY_LINK(, [
daywalker3664f562003-10-17 13:43:46 +0000313
314__asm__ __volatile__ (".cfi_startproc\n"
315 ".cfi_adjust_cfa_offset 0x0\n"
316 ".cfi_endproc\n");
317],
318[
319 AC_DEFINE_UNQUOTED([HAVE_GAS_CFI], 1, [Define if your GNU as supports .cfi])
320 AC_MSG_RESULT(yes)
321],
322 AC_MSG_RESULT(no)
323)
sewardj2e10a682003-04-07 19:36:41 +0000324
sewardj5b754b42002-06-03 22:53:35 +0000325# does this compiler support -mpreferred-stack-boundary=2 ?
326AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
327
daywalker3664f562003-10-17 13:43:46 +0000328safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000329CFLAGS="-mpreferred-stack-boundary=2"
330
331AC_TRY_COMPILE(, [
332
333int main () { return 0 ; }
334
335],
336[
337PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000338AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000339], [
340PREFERRED_STACK_BOUNDARY=""
341AC_MSG_RESULT([no])
342])
daywalker3664f562003-10-17 13:43:46 +0000343CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000344
345AC_SUBST(PREFERRED_STACK_BOUNDARY)
346
347
348
sewardjde4a1d02002-03-22 01:27:54 +0000349# Checks for header files.
350AC_HEADER_STDC
thughesacec02f2004-08-18 08:11:34 +0000351AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h sys/statfs.h sys/time.h sys/endian.h endian.h termios.h unistd.h utime.h linux/fb.h linux/mii.h mqueue.h linux/compiler.h])
sewardjde4a1d02002-03-22 01:27:54 +0000352
353# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000354AC_TYPE_UID_T
355AC_TYPE_OFF_T
356AC_TYPE_SIZE_T
357AC_HEADER_TIME
thughesebed9982004-06-12 17:25:25 +0000358AC_CHECK_TYPES(__pthread_unwind_buf_t,,,[#include <pthread.h>])
thughesbe811712004-06-17 23:04:58 +0000359AC_CHECK_TYPES(u16,,,[#include <linux/mii.h>])
sewardjde4a1d02002-03-22 01:27:54 +0000360
361# Checks for library functions.
362AC_FUNC_MEMCMP
363AC_FUNC_MMAP
364AC_TYPE_SIGNAL
365
thughesbeb6eb92004-06-14 12:33:43 +0000366AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000367
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
muellerbddd6072003-11-19 21:50:07 +0000371 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000372 docs/Makefile
373 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000374 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000375 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000376 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000377 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000378 coregrind/Makefile
379 coregrind/demangle/Makefile
380 coregrind/docs/Makefile
fitzhardinge98abfc72003-12-16 02:05:15 +0000381 coregrind/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000382 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000383 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000384 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000385 memcheck/Makefile
386 memcheck/tests/Makefile
387 memcheck/docs/Makefile
388 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000389 cachegrind/tests/Makefile
390 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000391 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000392 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000393 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000394 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000395 massif/Makefile
396 massif/hp2ps/Makefile
397 massif/tests/Makefile
398 massif/docs/Makefile
399 corecheck/Makefile
400 corecheck/tests/Makefile
401 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000402 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000403 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000404 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000405 none/Makefile
406 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000407 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000408)
gobry3b777892002-04-04 09:18:39 +0000409
410cat<<EOF
411
412Using the following suppressions by default:
413
414 ${DEFAULT_SUPP}
415EOF
416
417cat<<EOF > default.supp
418# This is a generated file, composed of the following suppression rules:
419#
420# ${DEFAULT_SUPP}
421#
422
423EOF
424
425for file in ${DEFAULT_SUPP} ; do
426 cat ${srcdir}/$file >> default.supp
427done