blob: 89c4d1604abb42eb7f88fcf688eae8b26c6a7a61 [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
dirkaece45c2006-10-12 08:17:49 +0000377AC_EGREP_CPP([GLIBC_25], [
378#include <features.h>
379#ifdef __GNU_LIBRARY__
380 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 5)
381 GLIBC_25
382 #endif
383#endif
384],
385glibc="2.5")
386
daywalkere9212b32003-06-15 22:39:15 +0000387AC_MSG_CHECKING([the glibc version])
388
gobrye721a522002-03-22 13:38:30 +0000389case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000390 2.2)
391 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000392 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj01262142006-01-04 01:20:28 +0000393 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000394 ;;
395
sewardj08c7f012002-10-07 23:56:55 +0000396 2.3)
397 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000398 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj01262142006-01-04 01:20:28 +0000399 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000400 ;;
401
njn781dba52005-06-30 04:06:38 +0000402 2.4)
403 AC_MSG_RESULT(2.4 family)
404 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj01262142006-01-04 01:20:28 +0000405 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000406 ;;
407
dirkaece45c2006-10-12 08:17:49 +0000408 2.5)
409 AC_MSG_RESULT(2.5 family)
410 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
411 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
412 ;;
413
sewardjde4a1d02002-03-22 01:27:54 +0000414 *)
415 AC_MSG_RESULT(unsupported version)
dirkaece45c2006-10-12 08:17:49 +0000416 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.5])
sewardjde4a1d02002-03-22 01:27:54 +0000417 ;;
418esac
419
sewardj535c50f2005-06-04 23:14:53 +0000420
nethercote3d260f62004-10-31 19:39:18 +0000421# We don't know how to detect the X client library version
422# (detecting the server version is easy, bu no help). So we
423# just use a hack: always include the suppressions for both
424# versions 3 and 4.
gobrye721a522002-03-22 13:38:30 +0000425AC_PATH_X
gobrye721a522002-03-22 13:38:30 +0000426if test "${no_x}" != 'yes' ; then
sewardj01262142006-01-04 01:20:28 +0000427 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
428 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000429fi
430
sewardj2e10a682003-04-07 19:36:41 +0000431
sewardj535c50f2005-06-04 23:14:53 +0000432# does this compiler support -m32 ?
433AC_MSG_CHECKING([if gcc accepts -m32])
434
435safe_CFLAGS=$CFLAGS
436CFLAGS="-m32"
437
438AC_TRY_COMPILE(, [
439int main () { return 0 ; }
440],
441[
442FLAG_M32="-m32"
443AC_MSG_RESULT([yes])
444], [
445FLAG_M32=""
446AC_MSG_RESULT([no])
447])
448CFLAGS=$safe_CFLAGS
449
450AC_SUBST(FLAG_M32)
451
452
sewardj01262142006-01-04 01:20:28 +0000453# does this compiler support -m64 ?
454AC_MSG_CHECKING([if gcc accepts -m64])
455
456safe_CFLAGS=$CFLAGS
457CFLAGS="-m64"
458
459AC_TRY_COMPILE(, [
460int main () { return 0 ; }
461],
462[
463FLAG_M64="-m64"
464AC_MSG_RESULT([yes])
465], [
466FLAG_M64=""
467AC_MSG_RESULT([no])
468])
469CFLAGS=$safe_CFLAGS
470
471AC_SUBST(FLAG_M64)
472
473
sewardj67f1fcc2005-07-03 10:41:02 +0000474# does this compiler support -mmmx ?
475AC_MSG_CHECKING([if gcc accepts -mmmx])
476
477safe_CFLAGS=$CFLAGS
478CFLAGS="-mmmx"
479
480AC_TRY_COMPILE(, [
481int main () { return 0 ; }
482],
483[
484FLAG_MMMX="-mmmx"
485AC_MSG_RESULT([yes])
486], [
487FLAG_MMMX=""
488AC_MSG_RESULT([no])
489])
490CFLAGS=$safe_CFLAGS
491
492AC_SUBST(FLAG_MMMX)
493
494
495# does this compiler support -msse ?
496AC_MSG_CHECKING([if gcc accepts -msse])
497
498safe_CFLAGS=$CFLAGS
499CFLAGS="-msse"
500
501AC_TRY_COMPILE(, [
502int main () { return 0 ; }
503],
504[
505FLAG_MSSE="-msse"
506AC_MSG_RESULT([yes])
507], [
508FLAG_MSSE=""
509AC_MSG_RESULT([no])
510])
511CFLAGS=$safe_CFLAGS
512
513AC_SUBST(FLAG_MSSE)
514
515
sewardj5b754b42002-06-03 22:53:35 +0000516# does this compiler support -mpreferred-stack-boundary=2 ?
517AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
518
daywalker3664f562003-10-17 13:43:46 +0000519safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000520CFLAGS="-mpreferred-stack-boundary=2"
521
522AC_TRY_COMPILE(, [
sewardj5b754b42002-06-03 22:53:35 +0000523int main () { return 0 ; }
sewardj5b754b42002-06-03 22:53:35 +0000524],
525[
526PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000527AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000528], [
529PREFERRED_STACK_BOUNDARY=""
530AC_MSG_RESULT([no])
531])
daywalker3664f562003-10-17 13:43:46 +0000532CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000533
534AC_SUBST(PREFERRED_STACK_BOUNDARY)
535
sewardj535c50f2005-06-04 23:14:53 +0000536
sewardjb5f6f512005-03-10 23:59:00 +0000537# does this compiler support -Wno-pointer-sign ?
538AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ])
539
540safe_CFLAGS=$CFLAGS
541CFLAGS="-Wno-pointer-sign"
542
543AC_TRY_COMPILE(, [
544int main () { return 0 ; }
545],
546[
547no_pointer_sign=yes
548AC_MSG_RESULT([yes])
549], [
550no_pointer_sign=no
551AC_MSG_RESULT([no])
552])
553CFLAGS=$safe_CFLAGS
554
555if test x$no_pointer_sign = xyes; then
556 CFLAGS="$CFLAGS -Wno-pointer-sign"
557fi
558
sewardj535c50f2005-06-04 23:14:53 +0000559
tom1e946682005-10-12 11:27:33 +0000560# does this compiler support -Wdeclaration-after-statement ?
561AC_MSG_CHECKING([if gcc accepts -Wdeclaration-after-statement ])
562
563safe_CFLAGS=$CFLAGS
564CFLAGS="-Wdeclaration-after-statement"
565
566AC_TRY_COMPILE(, [
567int main () { return 0 ; }
568],
569[
tome9814c32005-10-12 11:30:43 +0000570declaration_after_statement=yes
sewardj72a547e2006-01-25 02:58:28 +0000571FLAG_WDECL_AFTER_STMT="-Wdeclaration-after-statement"
tom1e946682005-10-12 11:27:33 +0000572AC_MSG_RESULT([yes])
573], [
tome9814c32005-10-12 11:30:43 +0000574declaration_after_statement=no
sewardj72a547e2006-01-25 02:58:28 +0000575FLAG_WDECL_AFTER_STMT=""
tom1e946682005-10-12 11:27:33 +0000576AC_MSG_RESULT([no])
577])
578CFLAGS=$safe_CFLAGS
579
sewardj72a547e2006-01-25 02:58:28 +0000580AC_SUBST(FLAG_WDECL_AFTER_STMT)
581
tome9814c32005-10-12 11:30:43 +0000582if test x$declaration_after_statement = xyes; then
tom1e946682005-10-12 11:27:33 +0000583 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
584fi
585
sewardj00f1e622006-03-12 16:47:10 +0000586
tomd55121e2005-12-19 12:40:13 +0000587# does this compiler support __builtin_expect?
588AC_MSG_CHECKING([if gcc supports __builtin_expect])
589
590AC_TRY_LINK(, [
591return __builtin_expect(1, 1) ? 1 : 0
592],
593[
594ac_have_builtin_expect=yes
595AC_MSG_RESULT([yes])
596], [
597ac_have_builtin_expect=no
598AC_MSG_RESULT([no])
599])
600if test x$ac_have_builtin_expect = xyes ; then
601 AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if gcc supports __builtin_expect.])
602fi
603
tom1e946682005-10-12 11:27:33 +0000604
sewardj00f1e622006-03-12 16:47:10 +0000605# does the ppc assembler support "mtocrf" et al?
606AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
607
608AC_TRY_COMPILE(, [
sewardjdd4cbe12006-03-12 17:27:44 +0000609__asm__ __volatile__("mtocrf 4,0");
610__asm__ __volatile__("mfocrf 0,4");
sewardj00f1e622006-03-12 16:47:10 +0000611],
612[
613ac_have_as_ppc_mftocrf=yes
614AC_MSG_RESULT([yes])
615], [
616ac_have_as_ppc_mftocrf=no
617AC_MSG_RESULT([no])
618])
619if test x$ac_have_as_ppc_mftocrf = xyes ; then
620 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
621fi
622
623
sewardjb5f6f512005-03-10 23:59:00 +0000624# Check for TLS support in the compiler and linker
625AC_CACHE_CHECK([for TLS support], vg_cv_tls,
626 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
627 [vg_cv_tls=$enableval],
628 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
629 [[return foo;]])],
630 [vg_cv_tls=yes],
631 [vg_cv_tls=no])])])
632
633if test "$vg_cv_tls" = yes; then
634AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
635fi
sewardj5b754b42002-06-03 22:53:35 +0000636
sewardj535c50f2005-06-04 23:14:53 +0000637
sewardjde4a1d02002-03-22 01:27:54 +0000638# Checks for header files.
639AC_HEADER_STDC
nethercote3d260f62004-10-31 19:39:18 +0000640AC_CHECK_HEADERS([sys/endian.h endian.h mqueue.h])
sewardjde4a1d02002-03-22 01:27:54 +0000641
sewardj535c50f2005-06-04 23:14:53 +0000642
sewardjde4a1d02002-03-22 01:27:54 +0000643# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000644AC_TYPE_UID_T
645AC_TYPE_OFF_T
646AC_TYPE_SIZE_T
647AC_HEADER_TIME
648
sewardj535c50f2005-06-04 23:14:53 +0000649
sewardjde4a1d02002-03-22 01:27:54 +0000650# Checks for library functions.
651AC_FUNC_MEMCMP
652AC_FUNC_MMAP
653AC_TYPE_SIGNAL
654
thughesbeb6eb92004-06-14 12:33:43 +0000655AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000656
sewardj80637752006-03-02 13:48:21 +0000657
sewardje9fa5062006-03-12 18:29:18 +0000658# Do we have a useable MPI setup on the primary target
659# (mpicc, and suitable MPI2 headers?)
660# Note: this is a kludge in that it assumes the specified mpicc
661# understands '-m32' or '-m64', as established above
sewardj0ad46092006-03-02 17:09:16 +0000662MPI_CC="mpicc"
sewardje9fa5062006-03-12 18:29:18 +0000663mflag_primary=
664if test x$VG_PLATFORM_PRI = xX86_LINUX \
665 -o x$VG_PLATFORM_PRI = xPPC32_LINUX ; then
666 mflag_primary=$FLAG_M32
667elif test x$VG_PLATFORM_PRI = xAMD64_LINUX \
668 -o x$VG_PLATFORM_PRI = xPPC64_LINUX ; then
669 mflag_primary=$FLAG_M64
670fi
671
sewardj0ad46092006-03-02 17:09:16 +0000672AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +0000673 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +0000674 MPI_CC=$withval
675)
sewardj1a85e602006-03-08 15:26:10 +0000676AC_MSG_CHECKING([for usable MPI2-compliant mpicc and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +0000677saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +0000678saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +0000679CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +0000680CFLAGS=$mflag_primary
sewardjd3fcc642006-03-09 02:49:56 +0000681AC_TRY_LINK([
sewardj1a85e602006-03-08 15:26:10 +0000682#include <mpi.h>
683#include <stdio.h>
sewardjde4f3842006-03-09 02:41:41 +0000684],[
685 int r = MPI_Init(NULL,NULL);
686 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
687 return r;
688], [
sewardj1a85e602006-03-08 15:26:10 +0000689ac_have_mpi2=yes
690AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +0000691], [
sewardj1a85e602006-03-08 15:26:10 +0000692ac_have_mpi2=no
sewardj80637752006-03-02 13:48:21 +0000693AC_MSG_RESULT([no])
694])
sewardj0ad46092006-03-02 17:09:16 +0000695CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +0000696CFLAGS=$saved_CFLAGS
sewardj80637752006-03-02 13:48:21 +0000697
sewardj1a85e602006-03-08 15:26:10 +0000698AM_CONDITIONAL(BUILD_MPIWRAP, test x$ac_have_mpi2 = xyes)
sewardj0ad46092006-03-02 17:09:16 +0000699AC_SUBST(MPI_CC)
sewardj80637752006-03-02 13:48:21 +0000700
701
702# -------------------- ok. We're done. --------------------
703
gobrye721a522002-03-22 13:38:30 +0000704AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000705 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000706 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +0000707 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000708 docs/Makefile
njn3e986b22004-11-30 10:43:45 +0000709 docs/lib/Makefile
710 docs/images/Makefile
njnf7c00b12005-07-19 21:46:19 +0000711 docs/internals/Makefile
njn3e986b22004-11-30 10:43:45 +0000712 docs/xml/Makefile
njn254d542432002-09-23 16:09:39 +0000713 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000714 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +0000715 perf/Makefile
716 perf/vg_perf
njn254d542432002-09-23 16:09:39 +0000717 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000718 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000719 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000720 memcheck/Makefile
721 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000722 memcheck/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000723 memcheck/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000724 memcheck/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000725 memcheck/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000726 memcheck/docs/Makefile
727 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000728 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000729 cachegrind/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000730 cachegrind/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000731 cachegrind/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000732 cachegrind/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000733 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000734 cachegrind/cg_annotate
weidendoa17f2a32006-03-20 10:27:30 +0000735 callgrind/Makefile
736 callgrind/callgrind_annotate
737 callgrind/callgrind_control
738 callgrind/tests/Makefile
739 callgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000740 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000741 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000742 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000743 massif/Makefile
744 massif/hp2ps/Makefile
745 massif/tests/Makefile
746 massif/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000747 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000748 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000749 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000750 none/Makefile
751 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000752 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000753 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000754 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000755 none/tests/x86/Makefile
njn9bc8c002002-10-02 13:49:13 +0000756 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000757)
gobry3b777892002-04-04 09:18:39 +0000758
759cat<<EOF
760
sewardj01262142006-01-04 01:20:28 +0000761 Primary build target: ${VG_PLATFORM_PRI}
sewardj80637752006-03-02 13:48:21 +0000762 Secondary build target: ${VG_PLATFORM_SEC}
sewardj01262142006-01-04 01:20:28 +0000763 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +0000764
gobry3b777892002-04-04 09:18:39 +0000765EOF
766
767cat<<EOF > default.supp
768# This is a generated file, composed of the following suppression rules:
769#
770# ${DEFAULT_SUPP}
771#
772
773EOF
774
775for file in ${DEFAULT_SUPP} ; do
776 cat ${srcdir}/$file >> default.supp
777done