blob: dc0d7b0de81a13e7806a02ab5b29114cb4c1bacc [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
jsewarddc0b4e82004-08-31 16:26:27 +00002AC_INIT(Valgrind, 2.3.0.CVS, valgrind-users@lists.sourceforge.net)
thughes6dbad732004-08-29 09:46:38 +00003AC_CONFIG_SRCDIR(coregrind/vg_main.c)
sewardjde4a1d02002-03-22 01:27:54 +00004AM_CONFIG_HEADER(config.h)
thughes6dbad732004-08-29 09:46:38 +00005AM_INIT_AUTOMAKE
sewardjde4a1d02002-03-22 01:27:54 +00006
gobryb0ed4672002-03-27 20:58:58 +00007AM_MAINTAINER_MODE
8
sewardjde4a1d02002-03-22 01:27:54 +00009# Checks for programs.
gobrye721a522002-03-22 13:38:30 +000010CFLAGS=""
11
sewardjde4a1d02002-03-22 01:27:54 +000012AC_PROG_LN_S
13AC_PROG_CC
14AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000015AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000016AC_PROG_RANLIB
17
gobrye721a522002-03-22 13:38:30 +000018# Check for the compiler support
19if test "${GCC}" != "yes" ; then
20 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
21fi
22
sewardj2f685952002-12-22 19:32:23 +000023# figure out where perl lives
24AC_PATH_PROG(PERL, perl)
25
njn9315df32003-04-16 20:50:50 +000026# figure out where gdb lives
27AC_PATH_PROG(GDB, gdb)
njn17b85352003-04-18 12:54:24 +000028# autoheader tries to execute the 3rd string or something; I get warnings when
29# it's defined. So just leave it undefined. --njn 2002-Apr-18
30AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", "")
njn9315df32003-04-16 20:50:50 +000031
daywalker48ccca52002-04-15 00:31:58 +000032# some older automake's don't have it so try something on our own
33ifdef([AM_PROG_AS],[AM_PROG_AS],
34[
gobry1be19852002-03-26 20:44:55 +000035AS="${CC}"
36AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000037
gobry1be19852002-03-26 20:44:55 +000038ASFLAGS=""
39AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000040])
gobry3b777892002-04-04 09:18:39 +000041
42# This variable will collect the individual suppression files
43# depending on the results of autoconf
44
45DEFAULT_SUPP=""
46
47
gobrye721a522002-03-22 13:38:30 +000048# We don't want gcc 2.7
49AC_MSG_CHECKING([for a supported version of gcc])
50
daywalker870ac4c2002-05-21 00:09:48 +000051gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000052
53case "${gcc_version}" in
54 gcc-2.7.*)
55 AC_MSG_RESULT([no (${gcc_version})])
56 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
57 ;;
58
59 *)
60 AC_MSG_RESULT([ok (${gcc_version})])
61 ;;
62esac
63
gobrye721a522002-03-22 13:38:30 +000064
sewardjde4a1d02002-03-22 01:27:54 +000065# Checks for the platform
66AC_CANONICAL_HOST
67
68AC_MSG_CHECKING([for a supported CPU])
nethercote888ecb72004-08-23 14:54:40 +000069AC_SUBST(VG_ARCH)
sewardjde4a1d02002-03-22 01:27:54 +000070
gobrye721a522002-03-22 13:38:30 +000071case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000072 i?86)
73 AC_MSG_RESULT([ok (${host_cpu})])
nethercote888ecb72004-08-23 14:54:40 +000074 VG_ARCH="x86"
sewardjde4a1d02002-03-22 01:27:54 +000075 ;;
76
nethercote9bcc9062004-10-13 13:50:01 +000077 powerpc*)
78 AC_MSG_RESULT([no (${host_cpu})])
79 VG_ARCH="powerpc"
80 AC_MSG_ERROR([PowerPC not supported. Sorry])
81 ;;
82
sewardjde4a1d02002-03-22 01:27:54 +000083 *)
84 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +000085 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +000086 ;;
87esac
88
89AC_MSG_CHECKING([for a supported OS])
nethercote888ecb72004-08-23 14:54:40 +000090AC_SUBST(VG_OS)
sewardjde4a1d02002-03-22 01:27:54 +000091
gobrye721a522002-03-22 13:38:30 +000092case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +000093 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +000094 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +000095 VG_OS="linux"
mueller8c68e042004-01-03 15:21:14 +000096
97 # Ok, this is linux. Check the kernel version
98 AC_MSG_CHECKING([for the kernel version])
99
100 kernel=`uname -r`
101
102 case "${kernel}" in
103 2.6.*)
104 AC_MSG_RESULT([2.6 family (${kernel})])
105 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
106 ;;
107
108 2.4.*)
109 AC_MSG_RESULT([2.4 family (${kernel})])
110 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
111 ;;
112
113 2.2.*)
114 AC_MSG_RESULT([2.2 family (${kernel})])
115 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
116 ;;
117
118 *)
119 AC_MSG_RESULT([unsupported (${kernel})])
120 AC_MSG_ERROR([Valgrind works on kernels 2.2, 2.4, 2.6])
121 ;;
122 esac
123
124 ;;
125
126 *freebsd*)
127 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000128 VG_OS="freebsd"
sewardjde4a1d02002-03-22 01:27:54 +0000129 ;;
130
131 *)
132 AC_MSG_RESULT([no (${host_os})])
mueller8c68e042004-01-03 15:21:14 +0000133 AC_MSG_ERROR([Valgrind is operating system specific. Sorry. Please consider doing a port.])
sewardjde4a1d02002-03-22 01:27:54 +0000134 ;;
135esac
136
nethercote888ecb72004-08-23 14:54:40 +0000137AC_MSG_CHECKING([for a supported CPU/OS combination])
138AC_SUBST(VG_PLATFORM)
139
140VG_PLATFORM="$VG_ARCH-$VG_OS"
141
142case $VG_PLATFORM in
143 x86-linux)
144 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
145 ;;
146
147 *)
148 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
149 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doin
150g a port.])
151 ;;
152esac
sewardjde4a1d02002-03-22 01:27:54 +0000153
sewardjde4a1d02002-03-22 01:27:54 +0000154AC_SUBST(DEFAULT_SUPP)
155
sewardjde4a1d02002-03-22 01:27:54 +0000156glibc=""
157
158AC_EGREP_CPP([GLIBC_21], [
159#include <features.h>
160#ifdef __GNU_LIBRARY__
161 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
162 GLIBC_21
163 #endif
164#endif
165],
166glibc="2.1")
167
168AC_EGREP_CPP([GLIBC_22], [
169#include <features.h>
170#ifdef __GNU_LIBRARY__
171 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
172 GLIBC_22
173 #endif
174#endif
175],
176glibc="2.2")
177
sewardj08c7f012002-10-07 23:56:55 +0000178AC_EGREP_CPP([GLIBC_23], [
179#include <features.h>
180#ifdef __GNU_LIBRARY__
181 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
182 GLIBC_23
183 #endif
184#endif
185],
186glibc="2.3")
187
daywalkere9212b32003-06-15 22:39:15 +0000188# Ok, this is linux. Check the kernel version
189AC_MSG_CHECKING([the glibc version])
190
gobrye721a522002-03-22 13:38:30 +0000191case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000192 2.1)
193 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000194 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000195 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000196 ;;
197
198 2.2)
199 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000200 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000201 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000202 ;;
203
sewardj08c7f012002-10-07 23:56:55 +0000204 2.3)
205 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000206 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
daywalker63f6f782003-05-27 00:19:52 +0000207 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.3.supp"
sewardj08c7f012002-10-07 23:56:55 +0000208 ;;
209
sewardjde4a1d02002-03-22 01:27:54 +0000210 *)
211 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000212 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000213 ;;
214esac
215
sewardj3e909ce2002-06-03 13:27:15 +0000216# APIs introduced in recent glibc versions
217
218AC_MSG_CHECKING([whether sched_param has a sched_priority member])
219AC_CACHE_VAL(vg_have_sched_priority,
220[
221AC_TRY_COMPILE([#include <pthread.h>],[
222struct sched_param p; p.sched_priority=1;],
223vg_have_sched_priority=yes,
224vg_have_sched_priority=no)
225])
226AC_MSG_RESULT($vg_have_sched_priority)
227if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000228AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000229fi
230
231AC_MSG_CHECKING([whether nfds_t is defined])
232AC_CACHE_VAL(vg_have_nfds_t,
233[
234AC_TRY_COMPILE([#include <sys/poll.h>],[
235nfds_t i=0;],
236vg_have_nfds_t=yes,
237vg_have_nfds_t=no)
238])
239AC_MSG_RESULT($vg_have_nfds_t)
240if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000241AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000242fi
243
sewardjde4a1d02002-03-22 01:27:54 +0000244# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000245# JRS 2002-06-17: this is completely bogus because it
246# detects the server version, whereas we need to know the
247# client library version. So what follows is hacked to
248# use all the X supp files regardless of what is detected.
249# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000250
gobrye721a522002-03-22 13:38:30 +0000251AC_PATH_X
252
253if test "${no_x}" != 'yes' ; then
254
thughesfd8a3802004-08-30 10:31:21 +0000255 AC_MSG_CHECKING([X version])
gobrye721a522002-03-22 13:38:30 +0000256
257 cat<<EOF > conftest.c
258#include <X11/Xlib.h>
259
260int main (int argc, char * argv [])
261{
262 Display * display = XOpenDisplay (NULL);
263
264 if (display) {
265 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
266 }
267
268 return 0;
269}
270EOF
271
272 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
273
274 if test "$?" != 0 ; then
275 AC_MSG_RESULT([cannot compile test program])
276 else
277 xfree=`./conftest`
278
279 case "${xfree}" in
280 *XFree86*)
thughesfd8a3802004-08-30 10:31:21 +0000281 case "${xfree}" in
282 *version=4*)
283 AC_MSG_RESULT([XFree 4.x family])
284 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
285 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
286 # haaaaaaack!
287 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
288 ;;
gobrye721a522002-03-22 13:38:30 +0000289
thughesfd8a3802004-08-30 10:31:21 +0000290 *version=3*)
291 AC_MSG_RESULT([XFree 3.x family])
292 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
293 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
294 # haaaaaaack!
295 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
296 ;;
297
298 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
299 # haaaaaaack!
300 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
301 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
302 ;;
303 esac
304 ;;
305 *X.Org*)
306 case "${xfree}" in
307 *version=6*)
308 AC_MSG_RESULT([X.Org 6.x family])
309 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
310 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
311 # haaaaaaack!
312 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
313 ;;
314 esac
315 ;;
gobrye721a522002-03-22 13:38:30 +0000316 *) AC_MSG_RESULT([not a XFree86 server])
317 ;;
318 esac
319
gobrye721a522002-03-22 13:38:30 +0000320 fi
321
322 rm -f conftest conftest.c
323fi
324
sewardj2e10a682003-04-07 19:36:41 +0000325
daywalker3664f562003-10-17 13:43:46 +0000326# check if the GNU as supports CFI directives
327AC_MSG_CHECKING([if gas accepts .cfi])
muellerece14bd2003-10-31 03:43:48 +0000328AC_TRY_LINK(, [
daywalker3664f562003-10-17 13:43:46 +0000329
330__asm__ __volatile__ (".cfi_startproc\n"
331 ".cfi_adjust_cfa_offset 0x0\n"
332 ".cfi_endproc\n");
333],
334[
335 AC_DEFINE_UNQUOTED([HAVE_GAS_CFI], 1, [Define if your GNU as supports .cfi])
336 AC_MSG_RESULT(yes)
337],
338 AC_MSG_RESULT(no)
339)
sewardj2e10a682003-04-07 19:36:41 +0000340
sewardj5b754b42002-06-03 22:53:35 +0000341# does this compiler support -mpreferred-stack-boundary=2 ?
342AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
343
daywalker3664f562003-10-17 13:43:46 +0000344safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000345CFLAGS="-mpreferred-stack-boundary=2"
346
347AC_TRY_COMPILE(, [
348
349int main () { return 0 ; }
350
351],
352[
353PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000354AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000355], [
356PREFERRED_STACK_BOUNDARY=""
357AC_MSG_RESULT([no])
358])
daywalker3664f562003-10-17 13:43:46 +0000359CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000360
361AC_SUBST(PREFERRED_STACK_BOUNDARY)
362
363
364
sewardjde4a1d02002-03-22 01:27:54 +0000365# Checks for header files.
366AC_HEADER_STDC
nethercote2baf9aa2004-08-24 14:38:53 +0000367AC_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 mqueue.h linux/compiler.h])
368
thughes33448cc2004-08-24 23:09:07 +0000369AH_TEMPLATE([HAVE_LINUX_MII_H], [])
370AC_MSG_CHECKING([for linux/mii.h])
371AC_PREPROC_IFELSE([#include <linux/mii.h>],
372 [AC_DEFINE([HAVE_LINUX_MII_H])
373 AC_MSG_RESULT([yes])],
374 [AC_MSG_RESULT([no])])
sewardjde4a1d02002-03-22 01:27:54 +0000375
376# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000377AC_TYPE_UID_T
378AC_TYPE_OFF_T
379AC_TYPE_SIZE_T
380AC_HEADER_TIME
thughesebed9982004-06-12 17:25:25 +0000381AC_CHECK_TYPES(__pthread_unwind_buf_t,,,[#include <pthread.h>])
thughesbe811712004-06-17 23:04:58 +0000382AC_CHECK_TYPES(u16,,,[#include <linux/mii.h>])
sewardjde4a1d02002-03-22 01:27:54 +0000383
384# Checks for library functions.
385AC_FUNC_MEMCMP
386AC_FUNC_MMAP
387AC_TYPE_SIGNAL
388
thughesbeb6eb92004-06-14 12:33:43 +0000389AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000390
gobrye721a522002-03-22 13:38:30 +0000391AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000392 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000393 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +0000394 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000395 docs/Makefile
396 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000397 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000398 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000399 include/Makefile
nethercotec06e2132004-09-03 13:45:29 +0000400 include/x86/Makefile
njn7a6e7462002-11-09 17:53:30 +0000401 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000402 coregrind/Makefile
403 coregrind/demangle/Makefile
404 coregrind/docs/Makefile
fitzhardinge98abfc72003-12-16 02:05:15 +0000405 coregrind/x86/Makefile
nethercotef94fe2f2004-09-10 14:23:59 +0000406 coregrind/x86-linux/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000407 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000408 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000409 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000410 memcheck/Makefile
411 memcheck/tests/Makefile
412 memcheck/docs/Makefile
413 cachegrind/Makefile
nethercoteb35a8b92004-09-11 16:45:27 +0000414 cachegrind/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000415 cachegrind/tests/Makefile
416 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000417 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000418 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000419 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000420 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000421 massif/Makefile
422 massif/hp2ps/Makefile
423 massif/tests/Makefile
424 massif/docs/Makefile
425 corecheck/Makefile
426 corecheck/tests/Makefile
427 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000428 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000429 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000430 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000431 none/Makefile
432 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000433 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000434)
gobry3b777892002-04-04 09:18:39 +0000435
436cat<<EOF
437
438Using the following suppressions by default:
439
440 ${DEFAULT_SUPP}
441EOF
442
443cat<<EOF > default.supp
444# This is a generated file, composed of the following suppression rules:
445#
446# ${DEFAULT_SUPP}
447#
448
449EOF
450
451for file in ${DEFAULT_SUPP} ; do
452 cat ${srcdir}/$file >> default.supp
453done