blob: d342e09ed8e5d343b9e9f1852987b03e6a49bca7 [file] [log] [blame]
sewardj01262142006-01-04 01:20:28 +00001
2##------------------------------------------------------------##
3#
4# The multiple-architecture stuff in this file is pretty
5# cryptic. Read docs/internals/multiple-architectures.txt
6# for at least a partial explanation of what is going on.
7#
8##------------------------------------------------------------##
9
sewardjde4a1d02002-03-22 01:27:54 +000010# Process this file with autoconf to produce a configure script.
sewardj484afbe2006-06-07 13:14:07 +000011AC_INIT(Valgrind, 3.3.0.SVN, valgrind-users@lists.sourceforge.net)
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
sewardjde4a1d02002-03-22 01:27:54 +000013AM_CONFIG_HEADER(config.h)
thughes6dbad732004-08-29 09:46:38 +000014AM_INIT_AUTOMAKE
sewardjde4a1d02002-03-22 01:27:54 +000015
gobryb0ed4672002-03-27 20:58:58 +000016AM_MAINTAINER_MODE
17
njn8738c282004-11-23 16:31:56 +000018# Where is VEX ?
njnfe408942004-11-23 17:52:24 +000019# Nb: For the 2nd arg, the help string, AS_HELP_STRING is the proper way, but
20# older autoconfs don't support it... here's what it would say:
21#
sewardj85a9dca2005-07-26 10:42:57 +000022# AS_HELP_STRING([--with-vex], [Vex directory]),
njnfe408942004-11-23 17:52:24 +000023#
njn8738c282004-11-23 16:31:56 +000024AC_ARG_WITH(vex,
sewardj85a9dca2005-07-26 10:42:57 +000025 [ --with-vex=/path/to/vex/dir Vex directory],
njn8738c282004-11-23 16:31:56 +000026[
27 AC_CHECK_FILE($withval/pub/libvex.h,
28 [VEX_DIR=$withval],
29 [AC_MSG_ERROR([Directory '$withval' does not exist, or does not contain Vex])])
30],
31[
njn17adf1e2005-09-16 03:59:37 +000032 VEX_DIR='$(top_srcdir)/VEX'
njn8738c282004-11-23 16:31:56 +000033])
sewardj50629ec2004-11-22 13:44:11 +000034AC_SUBST(VEX_DIR)
35
njn657d9512005-06-24 15:20:52 +000036# "make distcheck" first builds a tarball, then extracts it.
37# Then it creates a build directory different from the extracted sources
38# (called _build), and issues
39#
40# ../configure $(DISTCHECK_CONFIGURE_FLAGS)
41#
42# and then builds, runs "make check", installs using DESTDIR, runs make
43# installcheck, uninstalls, checks whether the installed base is empty
44# again, then does yet another "make dist" and compares the resulting
45# tarball with the one it started off with for identical content. Then it
46# tests "make distclean" for no leftover files.
47#
48# So this line means: when doing "make dist", use the same --with-vex value
49# that you used when running configure to configure this tree in the first
50# place.
51AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], [--with-vex=$VEX_DIR])
52
sewardjde4a1d02002-03-22 01:27:54 +000053# Checks for programs.
sewardjb5f6f512005-03-10 23:59:00 +000054CFLAGS="-Wno-long-long"
gobrye721a522002-03-22 13:38:30 +000055
sewardjde4a1d02002-03-22 01:27:54 +000056AC_PROG_LN_S
57AC_PROG_CC
njnca0518d2004-11-26 19:34:36 +000058##AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000059AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000060AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000061AC_PROG_RANLIB
62
gobrye721a522002-03-22 13:38:30 +000063# Check for the compiler support
64if test "${GCC}" != "yes" ; then
65 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
66fi
67
sewardj2f685952002-12-22 19:32:23 +000068# figure out where perl lives
69AC_PATH_PROG(PERL, perl)
70
njn9315df32003-04-16 20:50:50 +000071# figure out where gdb lives
72AC_PATH_PROG(GDB, gdb)
njnfe408942004-11-23 17:52:24 +000073AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000074
daywalker48ccca52002-04-15 00:31:58 +000075# some older automake's don't have it so try something on our own
76ifdef([AM_PROG_AS],[AM_PROG_AS],
77[
gobry1be19852002-03-26 20:44:55 +000078AS="${CC}"
79AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000080
gobry1be19852002-03-26 20:44:55 +000081ASFLAGS=""
82AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000083])
gobry3b777892002-04-04 09:18:39 +000084
gobry3b777892002-04-04 09:18:39 +000085
sewardj535c50f2005-06-04 23:14:53 +000086# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +000087AC_MSG_CHECKING([for a supported version of gcc])
88
daywalker870ac4c2002-05-21 00:09:48 +000089gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000090
91case "${gcc_version}" in
92 gcc-2.7.*)
93 AC_MSG_RESULT([no (${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +000094 AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
95 ;;
96 gcc-2.8.*)
97 AC_MSG_RESULT([no (${gcc_version})])
98 AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
99 ;;
100 gcc-2.9*)
101 AC_MSG_RESULT([no (${gcc_version})])
102 AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
gobrye721a522002-03-22 13:38:30 +0000103 ;;
104
105 *)
106 AC_MSG_RESULT([ok (${gcc_version})])
107 ;;
108esac
109
gobrye721a522002-03-22 13:38:30 +0000110
sewardjde4a1d02002-03-22 01:27:54 +0000111# Checks for the platform
112AC_CANONICAL_HOST
113
114AC_MSG_CHECKING([for a supported CPU])
nethercote888ecb72004-08-23 14:54:40 +0000115AC_SUBST(VG_ARCH)
sewardjbc692db2006-01-04 03:31:07 +0000116
sewardj9b0567a2006-01-17 02:56:18 +0000117AC_SUBST(VG_ARCH_ALL)
118VG_ARCH_ALL="amd64 ppc32 ppc64 x86"
119
sewardj45f4e7c2005-09-27 19:20:21 +0000120AC_SUBST(VALT_LOAD_ADDRESS)
sewardjde4a1d02002-03-22 01:27:54 +0000121
gobrye721a522002-03-22 13:38:30 +0000122case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000123 i?86)
124 AC_MSG_RESULT([ok (${host_cpu})])
nethercote888ecb72004-08-23 14:54:40 +0000125 VG_ARCH="x86"
sewardjd7baad42006-05-20 01:13:38 +0000126 valt_load_address_normal="0x38000000"
127 valt_load_address_inner="0x28000000"
sewardjde4a1d02002-03-22 01:27:54 +0000128 ;;
129
njnfe408942004-11-23 17:52:24 +0000130 x86_64)
131 AC_MSG_RESULT([ok (${host_cpu})])
132 VG_ARCH="amd64"
sewardjd7baad42006-05-20 01:13:38 +0000133 valt_load_address_normal="0x38000000"
134 valt_load_address_inner="0x28000000"
njnfe408942004-11-23 17:52:24 +0000135 ;;
136
sewardj2c48c7b2005-11-29 13:05:56 +0000137 powerpc64)
138 AC_MSG_RESULT([ok (${host_cpu})])
139 VG_ARCH="ppc64"
sewardjd7baad42006-05-20 01:13:38 +0000140 valt_load_address_normal="0x38000000"
141 valt_load_address_inner="0x28000000"
sewardj2c48c7b2005-11-29 13:05:56 +0000142 ;;
143
144 powerpc)
cerion85665ca2005-06-20 15:51:07 +0000145 AC_MSG_RESULT([ok (${host_cpu})])
146 VG_ARCH="ppc32"
sewardjd7baad42006-05-20 01:13:38 +0000147 valt_load_address_normal="0x38000000"
148 valt_load_address_inner="0x28000000"
nethercote9bcc9062004-10-13 13:50:01 +0000149 ;;
150
sewardjde4a1d02002-03-22 01:27:54 +0000151 *)
152 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000153 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000154 ;;
155esac
156
sewardj45f4e7c2005-09-27 19:20:21 +0000157# Check if this should be built as an inner Valgrind, to be run within
158# another Valgrind. Choose the load address accordingly.
sewardj86e992f2006-01-28 18:39:09 +0000159AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
160 [AC_ARG_ENABLE(inner,
161 [ --enable-inner enables self-hosting],
162 [vg_cv_inner=$enableval],
163 [vg_cv_inner=no])])
sewardj45f4e7c2005-09-27 19:20:21 +0000164if test "$vg_cv_inner" = yes; then
165 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
166 VALT_LOAD_ADDRESS=$valt_load_address_inner
167else
168 VALT_LOAD_ADDRESS=$valt_load_address_normal
169fi
170
sewardj86e992f2006-01-28 18:39:09 +0000171# Sometimes it's convenient to subvert the bi-arch build system and
172# just have a single build even though the underlying platform is
173# capable of both. Hence handle --enable-only64bit and
174# --enable-only32bit. Complain if both are issued :-)
175
176# Check if a 64-bit only build has been requested
177AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
178 [AC_ARG_ENABLE(only64bit,
179 [ --enable-only64bit do a 64-bit only build],
180 [vg_cv_only64bit=$enableval],
181 [vg_cv_only64bit=no])])
182
183# Check if a 32-bit only build has been requested
184AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
185 [AC_ARG_ENABLE(only32bit,
186 [ --enable-only32bit do a 32-bit only build],
187 [vg_cv_only32bit=$enableval],
188 [vg_cv_only32bit=no])])
189
190# Stay sane
191if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
192 AC_MSG_ERROR(
193 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
194fi
195
196
197
sewardjde4a1d02002-03-22 01:27:54 +0000198AC_MSG_CHECKING([for a supported OS])
nethercote888ecb72004-08-23 14:54:40 +0000199AC_SUBST(VG_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000200
gobrye721a522002-03-22 13:38:30 +0000201case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000202 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000203 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000204 VG_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000205
206 # Ok, this is linux. Check the kernel version
207 AC_MSG_CHECKING([for the kernel version])
208
209 kernel=`uname -r`
210
211 case "${kernel}" in
212 2.6.*)
213 AC_MSG_RESULT([2.6 family (${kernel})])
214 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
215 ;;
216
217 2.4.*)
218 AC_MSG_RESULT([2.4 family (${kernel})])
219 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
220 ;;
221
mueller8c68e042004-01-03 15:21:14 +0000222 *)
223 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000224 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000225 ;;
226 esac
227
228 ;;
229
230 *freebsd*)
231 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000232 VG_OS="freebsd"
sewardjde4a1d02002-03-22 01:27:54 +0000233 ;;
234
235 *)
236 AC_MSG_RESULT([no (${host_os})])
mueller8c68e042004-01-03 15:21:14 +0000237 AC_MSG_ERROR([Valgrind is operating system specific. Sorry. Please consider doing a port.])
sewardjde4a1d02002-03-22 01:27:54 +0000238 ;;
239esac
240
tomd6398392006-06-07 17:44:36 +0000241# If we are building on a 64 bit platform test to see if the system
242# supports building 32 bit programs and disable 32 bit support if it
243# does not support building 32 bit programs
244
245case "$VG_ARCH-$VG_OS" in
246 amd64-linux|ppc64-linux)
247 AC_MSG_CHECKING([for 32 bit build support])
248 safe_CFLAGS=$CFLAGS
249 CFLAGS="-m32"
250 AC_TRY_LINK(, [
251 int main () { return 0 ; }
252 ],
253 [
254 AC_MSG_RESULT([yes])
255 ], [
256 vg_cv_only64bit="yes"
257 AC_MSG_RESULT([no])
258 ])
259 CFLAGS=$safe_CFLAGS;;
260esac
261
262if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
263 AC_MSG_ERROR(
264 [--enable-only32bit was specified but system does not support 32 bit builds])
265fi
nethercote888ecb72004-08-23 14:54:40 +0000266
sewardj01262142006-01-04 01:20:28 +0000267# Establish VG_PLATFORM_PRI. This is the primary build target. The
268# entire system, including regression and performance tests, will be
sewardjbc692db2006-01-04 03:31:07 +0000269# built for this target.
sewardj01262142006-01-04 01:20:28 +0000270#
sewardjbc692db2006-01-04 03:31:07 +0000271# Also establish VG_PLATFORM_SEC, the secondary build target, if
sewardj01262142006-01-04 01:20:28 +0000272# possible. The system will also be built for this target, but not
sewardjbc692db2006-01-04 03:31:07 +0000273# the regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000274#
275AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000276
sewardj01262142006-01-04 01:20:28 +0000277AC_SUBST(VG_PLATFORM_PRI)
278AC_SUBST(VG_PLATFORM_SEC)
279
280case "$VG_ARCH-$VG_OS" in
281 x86-linux)
282 VG_PLATFORM_PRI="X86_LINUX"
283 VG_PLATFORM_SEC=""
sewardj3e38ce02004-11-23 01:17:29 +0000284 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
sewardj01262142006-01-04 01:20:28 +0000285 ;;
286 amd64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000287 if test x$vg_cv_only64bit = xyes; then
288 VG_PLATFORM_PRI="AMD64_LINUX"
289 VG_PLATFORM_SEC=""
290 elif test x$vg_cv_only32bit = xyes; then
291 VG_PLATFORM_PRI="X86_LINUX"
292 VG_PLATFORM_SEC=""
293 else
294 VG_PLATFORM_PRI="AMD64_LINUX"
295 VG_PLATFORM_SEC="X86_LINUX"
296 fi
sewardj01262142006-01-04 01:20:28 +0000297 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
298 ;;
299 ppc32-linux)
300 VG_PLATFORM_PRI="PPC32_LINUX"
301 VG_PLATFORM_SEC=""
302 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
303 ;;
304 ppc64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000305 if test x$vg_cv_only64bit = xyes; then
306 VG_PLATFORM_PRI="PPC64_LINUX"
307 VG_PLATFORM_SEC=""
308 elif test x$vg_cv_only32bit = xyes; then
309 VG_PLATFORM_PRI="PPC32_LINUX"
310 VG_PLATFORM_SEC=""
311 else
312 VG_PLATFORM_PRI="PPC64_LINUX"
313 VG_PLATFORM_SEC="PPC32_LINUX"
314 fi
sewardj01262142006-01-04 01:20:28 +0000315 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
316 ;;
nethercote888ecb72004-08-23 14:54:40 +0000317 *)
sewardj01262142006-01-04 01:20:28 +0000318 VG_PLATFORM_PRI="unknown"
319 VG_PLATFORM_SEC="unknown"
nethercote888ecb72004-08-23 14:54:40 +0000320 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
sewardj3e38ce02004-11-23 01:17:29 +0000321 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000322 ;;
323esac
sewardjde4a1d02002-03-22 01:27:54 +0000324
sewardj01262142006-01-04 01:20:28 +0000325# Set up VG_<platform>. Either one or two of these become defined.
326#
327AM_CONDITIONAL(VG_X86_LINUX,
sewardjbc692db2006-01-04 03:31:07 +0000328 test x$VG_PLATFORM_PRI = xX86_LINUX \
329 -o x$VG_PLATFORM_SEC = xX86_LINUX)
sewardj01262142006-01-04 01:20:28 +0000330AM_CONDITIONAL(VG_AMD64_LINUX,
331 test x$VG_PLATFORM_PRI = xAMD64_LINUX)
332AM_CONDITIONAL(VG_PPC32_LINUX,
sewardjbc692db2006-01-04 03:31:07 +0000333 test x$VG_PLATFORM_PRI = xPPC32_LINUX \
334 -o x$VG_PLATFORM_SEC = xPPC32_LINUX)
sewardj01262142006-01-04 01:20:28 +0000335AM_CONDITIONAL(VG_PPC64_LINUX,
336 test x$VG_PLATFORM_PRI = xPPC64_LINUX)
tomfb7bcde2005-11-07 15:24:38 +0000337
tomb637bad2005-11-08 12:28:35 +0000338
sewardj01262142006-01-04 01:20:28 +0000339# This variable will collect the individual suppression files
340# depending on the results of autoconf
341DEFAULT_SUPP=""
sewardjde4a1d02002-03-22 01:27:54 +0000342AC_SUBST(DEFAULT_SUPP)
343
sewardj01262142006-01-04 01:20:28 +0000344
sewardjde4a1d02002-03-22 01:27:54 +0000345glibc=""
346
sewardjde4a1d02002-03-22 01:27:54 +0000347AC_EGREP_CPP([GLIBC_22], [
348#include <features.h>
349#ifdef __GNU_LIBRARY__
350 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
351 GLIBC_22
352 #endif
353#endif
354],
355glibc="2.2")
356
sewardj08c7f012002-10-07 23:56:55 +0000357AC_EGREP_CPP([GLIBC_23], [
358#include <features.h>
359#ifdef __GNU_LIBRARY__
360 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
361 GLIBC_23
362 #endif
363#endif
364],
365glibc="2.3")
366
njn781dba52005-06-30 04:06:38 +0000367AC_EGREP_CPP([GLIBC_24], [
368#include <features.h>
369#ifdef __GNU_LIBRARY__
370 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 4)
371 GLIBC_24
372 #endif
373#endif
374],
375glibc="2.4")
376
daywalkere9212b32003-06-15 22:39:15 +0000377AC_MSG_CHECKING([the glibc version])
378
gobrye721a522002-03-22 13:38:30 +0000379case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000380 2.2)
381 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000382 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj01262142006-01-04 01:20:28 +0000383 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000384 ;;
385
sewardj08c7f012002-10-07 23:56:55 +0000386 2.3)
387 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000388 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj01262142006-01-04 01:20:28 +0000389 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000390 ;;
391
njn781dba52005-06-30 04:06:38 +0000392 2.4)
393 AC_MSG_RESULT(2.4 family)
394 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj01262142006-01-04 01:20:28 +0000395 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000396 ;;
397
sewardjde4a1d02002-03-22 01:27:54 +0000398 *)
399 AC_MSG_RESULT(unsupported version)
sewardj3080a862005-07-03 10:18:33 +0000400 AC_MSG_ERROR([Valgrind requires glibc version 2.2, 2.3 or 2.4])
sewardjde4a1d02002-03-22 01:27:54 +0000401 ;;
402esac
403
sewardj535c50f2005-06-04 23:14:53 +0000404
nethercote3d260f62004-10-31 19:39:18 +0000405# We don't know how to detect the X client library version
406# (detecting the server version is easy, bu no help). So we
407# just use a hack: always include the suppressions for both
408# versions 3 and 4.
gobrye721a522002-03-22 13:38:30 +0000409AC_PATH_X
gobrye721a522002-03-22 13:38:30 +0000410if test "${no_x}" != 'yes' ; then
sewardj01262142006-01-04 01:20:28 +0000411 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
412 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000413fi
414
sewardj2e10a682003-04-07 19:36:41 +0000415
sewardj535c50f2005-06-04 23:14:53 +0000416# does this compiler support -m32 ?
417AC_MSG_CHECKING([if gcc accepts -m32])
418
419safe_CFLAGS=$CFLAGS
420CFLAGS="-m32"
421
422AC_TRY_COMPILE(, [
423int main () { return 0 ; }
424],
425[
426FLAG_M32="-m32"
427AC_MSG_RESULT([yes])
428], [
429FLAG_M32=""
430AC_MSG_RESULT([no])
431])
432CFLAGS=$safe_CFLAGS
433
434AC_SUBST(FLAG_M32)
435
436
sewardj01262142006-01-04 01:20:28 +0000437# does this compiler support -m64 ?
438AC_MSG_CHECKING([if gcc accepts -m64])
439
440safe_CFLAGS=$CFLAGS
441CFLAGS="-m64"
442
443AC_TRY_COMPILE(, [
444int main () { return 0 ; }
445],
446[
447FLAG_M64="-m64"
448AC_MSG_RESULT([yes])
449], [
450FLAG_M64=""
451AC_MSG_RESULT([no])
452])
453CFLAGS=$safe_CFLAGS
454
455AC_SUBST(FLAG_M64)
456
457
sewardj67f1fcc2005-07-03 10:41:02 +0000458# does this compiler support -mmmx ?
459AC_MSG_CHECKING([if gcc accepts -mmmx])
460
461safe_CFLAGS=$CFLAGS
462CFLAGS="-mmmx"
463
464AC_TRY_COMPILE(, [
465int main () { return 0 ; }
466],
467[
468FLAG_MMMX="-mmmx"
469AC_MSG_RESULT([yes])
470], [
471FLAG_MMMX=""
472AC_MSG_RESULT([no])
473])
474CFLAGS=$safe_CFLAGS
475
476AC_SUBST(FLAG_MMMX)
477
478
479# does this compiler support -msse ?
480AC_MSG_CHECKING([if gcc accepts -msse])
481
482safe_CFLAGS=$CFLAGS
483CFLAGS="-msse"
484
485AC_TRY_COMPILE(, [
486int main () { return 0 ; }
487],
488[
489FLAG_MSSE="-msse"
490AC_MSG_RESULT([yes])
491], [
492FLAG_MSSE=""
493AC_MSG_RESULT([no])
494])
495CFLAGS=$safe_CFLAGS
496
497AC_SUBST(FLAG_MSSE)
498
499
sewardj5b754b42002-06-03 22:53:35 +0000500# does this compiler support -mpreferred-stack-boundary=2 ?
501AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
502
daywalker3664f562003-10-17 13:43:46 +0000503safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000504CFLAGS="-mpreferred-stack-boundary=2"
505
506AC_TRY_COMPILE(, [
sewardj5b754b42002-06-03 22:53:35 +0000507int main () { return 0 ; }
sewardj5b754b42002-06-03 22:53:35 +0000508],
509[
510PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000511AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000512], [
513PREFERRED_STACK_BOUNDARY=""
514AC_MSG_RESULT([no])
515])
daywalker3664f562003-10-17 13:43:46 +0000516CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000517
518AC_SUBST(PREFERRED_STACK_BOUNDARY)
519
sewardj535c50f2005-06-04 23:14:53 +0000520
sewardjb5f6f512005-03-10 23:59:00 +0000521# does this compiler support -Wno-pointer-sign ?
522AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ])
523
524safe_CFLAGS=$CFLAGS
525CFLAGS="-Wno-pointer-sign"
526
527AC_TRY_COMPILE(, [
528int main () { return 0 ; }
529],
530[
531no_pointer_sign=yes
532AC_MSG_RESULT([yes])
533], [
534no_pointer_sign=no
535AC_MSG_RESULT([no])
536])
537CFLAGS=$safe_CFLAGS
538
539if test x$no_pointer_sign = xyes; then
540 CFLAGS="$CFLAGS -Wno-pointer-sign"
541fi
542
sewardj535c50f2005-06-04 23:14:53 +0000543
tom1e946682005-10-12 11:27:33 +0000544# does this compiler support -Wdeclaration-after-statement ?
545AC_MSG_CHECKING([if gcc accepts -Wdeclaration-after-statement ])
546
547safe_CFLAGS=$CFLAGS
548CFLAGS="-Wdeclaration-after-statement"
549
550AC_TRY_COMPILE(, [
551int main () { return 0 ; }
552],
553[
tome9814c32005-10-12 11:30:43 +0000554declaration_after_statement=yes
sewardj72a547e2006-01-25 02:58:28 +0000555FLAG_WDECL_AFTER_STMT="-Wdeclaration-after-statement"
tom1e946682005-10-12 11:27:33 +0000556AC_MSG_RESULT([yes])
557], [
tome9814c32005-10-12 11:30:43 +0000558declaration_after_statement=no
sewardj72a547e2006-01-25 02:58:28 +0000559FLAG_WDECL_AFTER_STMT=""
tom1e946682005-10-12 11:27:33 +0000560AC_MSG_RESULT([no])
561])
562CFLAGS=$safe_CFLAGS
563
sewardj72a547e2006-01-25 02:58:28 +0000564AC_SUBST(FLAG_WDECL_AFTER_STMT)
565
tome9814c32005-10-12 11:30:43 +0000566if test x$declaration_after_statement = xyes; then
tom1e946682005-10-12 11:27:33 +0000567 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
568fi
569
sewardj00f1e622006-03-12 16:47:10 +0000570
tomd55121e2005-12-19 12:40:13 +0000571# does this compiler support __builtin_expect?
572AC_MSG_CHECKING([if gcc supports __builtin_expect])
573
574AC_TRY_LINK(, [
575return __builtin_expect(1, 1) ? 1 : 0
576],
577[
578ac_have_builtin_expect=yes
579AC_MSG_RESULT([yes])
580], [
581ac_have_builtin_expect=no
582AC_MSG_RESULT([no])
583])
584if test x$ac_have_builtin_expect = xyes ; then
585 AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if gcc supports __builtin_expect.])
586fi
587
tom1e946682005-10-12 11:27:33 +0000588
sewardj00f1e622006-03-12 16:47:10 +0000589# does the ppc assembler support "mtocrf" et al?
590AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
591
592AC_TRY_COMPILE(, [
sewardjdd4cbe12006-03-12 17:27:44 +0000593__asm__ __volatile__("mtocrf 4,0");
594__asm__ __volatile__("mfocrf 0,4");
sewardj00f1e622006-03-12 16:47:10 +0000595],
596[
597ac_have_as_ppc_mftocrf=yes
598AC_MSG_RESULT([yes])
599], [
600ac_have_as_ppc_mftocrf=no
601AC_MSG_RESULT([no])
602])
603if test x$ac_have_as_ppc_mftocrf = xyes ; then
604 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
605fi
606
607
sewardjb5f6f512005-03-10 23:59:00 +0000608# Check for TLS support in the compiler and linker
609AC_CACHE_CHECK([for TLS support], vg_cv_tls,
610 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
611 [vg_cv_tls=$enableval],
612 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
613 [[return foo;]])],
614 [vg_cv_tls=yes],
615 [vg_cv_tls=no])])])
616
617if test "$vg_cv_tls" = yes; then
618AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
619fi
sewardj5b754b42002-06-03 22:53:35 +0000620
sewardj535c50f2005-06-04 23:14:53 +0000621
sewardjde4a1d02002-03-22 01:27:54 +0000622# Checks for header files.
623AC_HEADER_STDC
nethercote3d260f62004-10-31 19:39:18 +0000624AC_CHECK_HEADERS([sys/endian.h endian.h mqueue.h])
sewardjde4a1d02002-03-22 01:27:54 +0000625
sewardj535c50f2005-06-04 23:14:53 +0000626
sewardjde4a1d02002-03-22 01:27:54 +0000627# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000628AC_TYPE_UID_T
629AC_TYPE_OFF_T
630AC_TYPE_SIZE_T
631AC_HEADER_TIME
632
sewardj535c50f2005-06-04 23:14:53 +0000633
sewardjde4a1d02002-03-22 01:27:54 +0000634# Checks for library functions.
635AC_FUNC_MEMCMP
636AC_FUNC_MMAP
637AC_TYPE_SIGNAL
638
thughesbeb6eb92004-06-14 12:33:43 +0000639AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000640
sewardj80637752006-03-02 13:48:21 +0000641
sewardje9fa5062006-03-12 18:29:18 +0000642# Do we have a useable MPI setup on the primary target
643# (mpicc, and suitable MPI2 headers?)
644# Note: this is a kludge in that it assumes the specified mpicc
645# understands '-m32' or '-m64', as established above
sewardj0ad46092006-03-02 17:09:16 +0000646MPI_CC="mpicc"
sewardje9fa5062006-03-12 18:29:18 +0000647mflag_primary=
648if test x$VG_PLATFORM_PRI = xX86_LINUX \
649 -o x$VG_PLATFORM_PRI = xPPC32_LINUX ; then
650 mflag_primary=$FLAG_M32
651elif test x$VG_PLATFORM_PRI = xAMD64_LINUX \
652 -o x$VG_PLATFORM_PRI = xPPC64_LINUX ; then
653 mflag_primary=$FLAG_M64
654fi
655
sewardj0ad46092006-03-02 17:09:16 +0000656AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +0000657 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +0000658 MPI_CC=$withval
659)
sewardj1a85e602006-03-08 15:26:10 +0000660AC_MSG_CHECKING([for usable MPI2-compliant mpicc and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +0000661saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +0000662saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +0000663CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +0000664CFLAGS=$mflag_primary
sewardjd3fcc642006-03-09 02:49:56 +0000665AC_TRY_LINK([
sewardj1a85e602006-03-08 15:26:10 +0000666#include <mpi.h>
667#include <stdio.h>
sewardjde4f3842006-03-09 02:41:41 +0000668],[
669 int r = MPI_Init(NULL,NULL);
670 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
671 return r;
672], [
sewardj1a85e602006-03-08 15:26:10 +0000673ac_have_mpi2=yes
674AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +0000675], [
sewardj1a85e602006-03-08 15:26:10 +0000676ac_have_mpi2=no
sewardj80637752006-03-02 13:48:21 +0000677AC_MSG_RESULT([no])
678])
sewardj0ad46092006-03-02 17:09:16 +0000679CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +0000680CFLAGS=$saved_CFLAGS
sewardj80637752006-03-02 13:48:21 +0000681
sewardj1a85e602006-03-08 15:26:10 +0000682AM_CONDITIONAL(BUILD_MPIWRAP, test x$ac_have_mpi2 = xyes)
sewardj0ad46092006-03-02 17:09:16 +0000683AC_SUBST(MPI_CC)
sewardj80637752006-03-02 13:48:21 +0000684
685
686# -------------------- ok. We're done. --------------------
687
gobrye721a522002-03-22 13:38:30 +0000688AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000689 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000690 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +0000691 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000692 docs/Makefile
njn3e986b22004-11-30 10:43:45 +0000693 docs/lib/Makefile
694 docs/images/Makefile
njnf7c00b12005-07-19 21:46:19 +0000695 docs/internals/Makefile
njn3e986b22004-11-30 10:43:45 +0000696 docs/xml/Makefile
njn254d542432002-09-23 16:09:39 +0000697 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000698 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +0000699 perf/Makefile
700 perf/vg_perf
njn254d542432002-09-23 16:09:39 +0000701 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000702 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000703 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000704 memcheck/Makefile
705 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000706 memcheck/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000707 memcheck/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000708 memcheck/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000709 memcheck/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000710 memcheck/docs/Makefile
711 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000712 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000713 cachegrind/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000714 cachegrind/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000715 cachegrind/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000716 cachegrind/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000717 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000718 cachegrind/cg_annotate
weidendoa17f2a32006-03-20 10:27:30 +0000719 callgrind/Makefile
720 callgrind/callgrind_annotate
721 callgrind/callgrind_control
722 callgrind/tests/Makefile
723 callgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000724 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000725 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000726 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000727 massif/Makefile
728 massif/hp2ps/Makefile
729 massif/tests/Makefile
730 massif/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000731 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000732 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000733 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000734 none/Makefile
735 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000736 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000737 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000738 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000739 none/tests/x86/Makefile
njn9bc8c002002-10-02 13:49:13 +0000740 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000741)
gobry3b777892002-04-04 09:18:39 +0000742
743cat<<EOF
744
sewardj01262142006-01-04 01:20:28 +0000745 Primary build target: ${VG_PLATFORM_PRI}
sewardj80637752006-03-02 13:48:21 +0000746 Secondary build target: ${VG_PLATFORM_SEC}
sewardj01262142006-01-04 01:20:28 +0000747 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +0000748
gobry3b777892002-04-04 09:18:39 +0000749EOF
750
751cat<<EOF > default.supp
752# This is a generated file, composed of the following suppression rules:
753#
754# ${DEFAULT_SUPP}
755#
756
757EOF
758
759for file in ${DEFAULT_SUPP} ; do
760 cat ${srcdir}/$file >> default.supp
761done