blob: 7f99e918575a194339d53b9e8b012d6ef59f480e [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.
sewardjaf924992006-05-26 13:51:37 +000011AC_INIT(Valgrind, 3.2.0rc1, 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
nethercote888ecb72004-08-23 14:54:40 +0000241
sewardj01262142006-01-04 01:20:28 +0000242# Establish VG_PLATFORM_PRI. This is the primary build target. The
243# entire system, including regression and performance tests, will be
sewardjbc692db2006-01-04 03:31:07 +0000244# built for this target.
sewardj01262142006-01-04 01:20:28 +0000245#
sewardjbc692db2006-01-04 03:31:07 +0000246# Also establish VG_PLATFORM_SEC, the secondary build target, if
sewardj01262142006-01-04 01:20:28 +0000247# possible. The system will also be built for this target, but not
sewardjbc692db2006-01-04 03:31:07 +0000248# the regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000249#
250AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000251
sewardj01262142006-01-04 01:20:28 +0000252AC_SUBST(VG_PLATFORM_PRI)
253AC_SUBST(VG_PLATFORM_SEC)
254
255case "$VG_ARCH-$VG_OS" in
256 x86-linux)
257 VG_PLATFORM_PRI="X86_LINUX"
258 VG_PLATFORM_SEC=""
sewardj3e38ce02004-11-23 01:17:29 +0000259 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
sewardj01262142006-01-04 01:20:28 +0000260 ;;
261 amd64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000262 if test x$vg_cv_only64bit = xyes; then
263 VG_PLATFORM_PRI="AMD64_LINUX"
264 VG_PLATFORM_SEC=""
265 elif test x$vg_cv_only32bit = xyes; then
266 VG_PLATFORM_PRI="X86_LINUX"
267 VG_PLATFORM_SEC=""
268 else
269 VG_PLATFORM_PRI="AMD64_LINUX"
270 VG_PLATFORM_SEC="X86_LINUX"
271 fi
sewardj01262142006-01-04 01:20:28 +0000272 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
273 ;;
274 ppc32-linux)
275 VG_PLATFORM_PRI="PPC32_LINUX"
276 VG_PLATFORM_SEC=""
277 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
278 ;;
279 ppc64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000280 if test x$vg_cv_only64bit = xyes; then
281 VG_PLATFORM_PRI="PPC64_LINUX"
282 VG_PLATFORM_SEC=""
283 elif test x$vg_cv_only32bit = xyes; then
284 VG_PLATFORM_PRI="PPC32_LINUX"
285 VG_PLATFORM_SEC=""
286 else
287 VG_PLATFORM_PRI="PPC64_LINUX"
288 VG_PLATFORM_SEC="PPC32_LINUX"
289 fi
sewardj01262142006-01-04 01:20:28 +0000290 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
291 ;;
nethercote888ecb72004-08-23 14:54:40 +0000292 *)
sewardj01262142006-01-04 01:20:28 +0000293 VG_PLATFORM_PRI="unknown"
294 VG_PLATFORM_SEC="unknown"
nethercote888ecb72004-08-23 14:54:40 +0000295 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
sewardj3e38ce02004-11-23 01:17:29 +0000296 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000297 ;;
298esac
sewardjde4a1d02002-03-22 01:27:54 +0000299
sewardj01262142006-01-04 01:20:28 +0000300# Set up VG_<platform>. Either one or two of these become defined.
301#
302AM_CONDITIONAL(VG_X86_LINUX,
sewardjbc692db2006-01-04 03:31:07 +0000303 test x$VG_PLATFORM_PRI = xX86_LINUX \
304 -o x$VG_PLATFORM_SEC = xX86_LINUX)
sewardj01262142006-01-04 01:20:28 +0000305AM_CONDITIONAL(VG_AMD64_LINUX,
306 test x$VG_PLATFORM_PRI = xAMD64_LINUX)
307AM_CONDITIONAL(VG_PPC32_LINUX,
sewardjbc692db2006-01-04 03:31:07 +0000308 test x$VG_PLATFORM_PRI = xPPC32_LINUX \
309 -o x$VG_PLATFORM_SEC = xPPC32_LINUX)
sewardj01262142006-01-04 01:20:28 +0000310AM_CONDITIONAL(VG_PPC64_LINUX,
311 test x$VG_PLATFORM_PRI = xPPC64_LINUX)
tomfb7bcde2005-11-07 15:24:38 +0000312
tomb637bad2005-11-08 12:28:35 +0000313
sewardj01262142006-01-04 01:20:28 +0000314# This variable will collect the individual suppression files
315# depending on the results of autoconf
316DEFAULT_SUPP=""
sewardjde4a1d02002-03-22 01:27:54 +0000317AC_SUBST(DEFAULT_SUPP)
318
sewardj01262142006-01-04 01:20:28 +0000319
sewardjde4a1d02002-03-22 01:27:54 +0000320glibc=""
321
sewardjde4a1d02002-03-22 01:27:54 +0000322AC_EGREP_CPP([GLIBC_22], [
323#include <features.h>
324#ifdef __GNU_LIBRARY__
325 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
326 GLIBC_22
327 #endif
328#endif
329],
330glibc="2.2")
331
sewardj08c7f012002-10-07 23:56:55 +0000332AC_EGREP_CPP([GLIBC_23], [
333#include <features.h>
334#ifdef __GNU_LIBRARY__
335 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
336 GLIBC_23
337 #endif
338#endif
339],
340glibc="2.3")
341
njn781dba52005-06-30 04:06:38 +0000342AC_EGREP_CPP([GLIBC_24], [
343#include <features.h>
344#ifdef __GNU_LIBRARY__
345 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 4)
346 GLIBC_24
347 #endif
348#endif
349],
350glibc="2.4")
351
daywalkere9212b32003-06-15 22:39:15 +0000352AC_MSG_CHECKING([the glibc version])
353
gobrye721a522002-03-22 13:38:30 +0000354case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000355 2.2)
356 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000357 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj01262142006-01-04 01:20:28 +0000358 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000359 ;;
360
sewardj08c7f012002-10-07 23:56:55 +0000361 2.3)
362 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000363 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj01262142006-01-04 01:20:28 +0000364 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000365 ;;
366
njn781dba52005-06-30 04:06:38 +0000367 2.4)
368 AC_MSG_RESULT(2.4 family)
369 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj01262142006-01-04 01:20:28 +0000370 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000371 ;;
372
sewardjde4a1d02002-03-22 01:27:54 +0000373 *)
374 AC_MSG_RESULT(unsupported version)
sewardj3080a862005-07-03 10:18:33 +0000375 AC_MSG_ERROR([Valgrind requires glibc version 2.2, 2.3 or 2.4])
sewardjde4a1d02002-03-22 01:27:54 +0000376 ;;
377esac
378
sewardj535c50f2005-06-04 23:14:53 +0000379
nethercote3d260f62004-10-31 19:39:18 +0000380# We don't know how to detect the X client library version
381# (detecting the server version is easy, bu no help). So we
382# just use a hack: always include the suppressions for both
383# versions 3 and 4.
gobrye721a522002-03-22 13:38:30 +0000384AC_PATH_X
gobrye721a522002-03-22 13:38:30 +0000385if test "${no_x}" != 'yes' ; then
sewardj01262142006-01-04 01:20:28 +0000386 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
387 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000388fi
389
sewardj2e10a682003-04-07 19:36:41 +0000390
sewardj535c50f2005-06-04 23:14:53 +0000391# does this compiler support -m32 ?
392AC_MSG_CHECKING([if gcc accepts -m32])
393
394safe_CFLAGS=$CFLAGS
395CFLAGS="-m32"
396
397AC_TRY_COMPILE(, [
398int main () { return 0 ; }
399],
400[
401FLAG_M32="-m32"
402AC_MSG_RESULT([yes])
403], [
404FLAG_M32=""
405AC_MSG_RESULT([no])
406])
407CFLAGS=$safe_CFLAGS
408
409AC_SUBST(FLAG_M32)
410
411
sewardj01262142006-01-04 01:20:28 +0000412# does this compiler support -m64 ?
413AC_MSG_CHECKING([if gcc accepts -m64])
414
415safe_CFLAGS=$CFLAGS
416CFLAGS="-m64"
417
418AC_TRY_COMPILE(, [
419int main () { return 0 ; }
420],
421[
422FLAG_M64="-m64"
423AC_MSG_RESULT([yes])
424], [
425FLAG_M64=""
426AC_MSG_RESULT([no])
427])
428CFLAGS=$safe_CFLAGS
429
430AC_SUBST(FLAG_M64)
431
432
sewardj67f1fcc2005-07-03 10:41:02 +0000433# does this compiler support -mmmx ?
434AC_MSG_CHECKING([if gcc accepts -mmmx])
435
436safe_CFLAGS=$CFLAGS
437CFLAGS="-mmmx"
438
439AC_TRY_COMPILE(, [
440int main () { return 0 ; }
441],
442[
443FLAG_MMMX="-mmmx"
444AC_MSG_RESULT([yes])
445], [
446FLAG_MMMX=""
447AC_MSG_RESULT([no])
448])
449CFLAGS=$safe_CFLAGS
450
451AC_SUBST(FLAG_MMMX)
452
453
454# does this compiler support -msse ?
455AC_MSG_CHECKING([if gcc accepts -msse])
456
457safe_CFLAGS=$CFLAGS
458CFLAGS="-msse"
459
460AC_TRY_COMPILE(, [
461int main () { return 0 ; }
462],
463[
464FLAG_MSSE="-msse"
465AC_MSG_RESULT([yes])
466], [
467FLAG_MSSE=""
468AC_MSG_RESULT([no])
469])
470CFLAGS=$safe_CFLAGS
471
472AC_SUBST(FLAG_MSSE)
473
474
sewardj5b754b42002-06-03 22:53:35 +0000475# does this compiler support -mpreferred-stack-boundary=2 ?
476AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
477
daywalker3664f562003-10-17 13:43:46 +0000478safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000479CFLAGS="-mpreferred-stack-boundary=2"
480
481AC_TRY_COMPILE(, [
sewardj5b754b42002-06-03 22:53:35 +0000482int main () { return 0 ; }
sewardj5b754b42002-06-03 22:53:35 +0000483],
484[
485PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000486AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000487], [
488PREFERRED_STACK_BOUNDARY=""
489AC_MSG_RESULT([no])
490])
daywalker3664f562003-10-17 13:43:46 +0000491CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000492
493AC_SUBST(PREFERRED_STACK_BOUNDARY)
494
sewardj535c50f2005-06-04 23:14:53 +0000495
sewardjb5f6f512005-03-10 23:59:00 +0000496# does this compiler support -Wno-pointer-sign ?
497AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ])
498
499safe_CFLAGS=$CFLAGS
500CFLAGS="-Wno-pointer-sign"
501
502AC_TRY_COMPILE(, [
503int main () { return 0 ; }
504],
505[
506no_pointer_sign=yes
507AC_MSG_RESULT([yes])
508], [
509no_pointer_sign=no
510AC_MSG_RESULT([no])
511])
512CFLAGS=$safe_CFLAGS
513
514if test x$no_pointer_sign = xyes; then
515 CFLAGS="$CFLAGS -Wno-pointer-sign"
516fi
517
sewardj535c50f2005-06-04 23:14:53 +0000518
tom1e946682005-10-12 11:27:33 +0000519# does this compiler support -Wdeclaration-after-statement ?
520AC_MSG_CHECKING([if gcc accepts -Wdeclaration-after-statement ])
521
522safe_CFLAGS=$CFLAGS
523CFLAGS="-Wdeclaration-after-statement"
524
525AC_TRY_COMPILE(, [
526int main () { return 0 ; }
527],
528[
tome9814c32005-10-12 11:30:43 +0000529declaration_after_statement=yes
sewardj72a547e2006-01-25 02:58:28 +0000530FLAG_WDECL_AFTER_STMT="-Wdeclaration-after-statement"
tom1e946682005-10-12 11:27:33 +0000531AC_MSG_RESULT([yes])
532], [
tome9814c32005-10-12 11:30:43 +0000533declaration_after_statement=no
sewardj72a547e2006-01-25 02:58:28 +0000534FLAG_WDECL_AFTER_STMT=""
tom1e946682005-10-12 11:27:33 +0000535AC_MSG_RESULT([no])
536])
537CFLAGS=$safe_CFLAGS
538
sewardj72a547e2006-01-25 02:58:28 +0000539AC_SUBST(FLAG_WDECL_AFTER_STMT)
540
tome9814c32005-10-12 11:30:43 +0000541if test x$declaration_after_statement = xyes; then
tom1e946682005-10-12 11:27:33 +0000542 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
543fi
544
sewardj00f1e622006-03-12 16:47:10 +0000545
tomd55121e2005-12-19 12:40:13 +0000546# does this compiler support __builtin_expect?
547AC_MSG_CHECKING([if gcc supports __builtin_expect])
548
549AC_TRY_LINK(, [
550return __builtin_expect(1, 1) ? 1 : 0
551],
552[
553ac_have_builtin_expect=yes
554AC_MSG_RESULT([yes])
555], [
556ac_have_builtin_expect=no
557AC_MSG_RESULT([no])
558])
559if test x$ac_have_builtin_expect = xyes ; then
560 AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if gcc supports __builtin_expect.])
561fi
562
tom1e946682005-10-12 11:27:33 +0000563
sewardj00f1e622006-03-12 16:47:10 +0000564# does the ppc assembler support "mtocrf" et al?
565AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
566
567AC_TRY_COMPILE(, [
sewardjdd4cbe12006-03-12 17:27:44 +0000568__asm__ __volatile__("mtocrf 4,0");
569__asm__ __volatile__("mfocrf 0,4");
sewardj00f1e622006-03-12 16:47:10 +0000570],
571[
572ac_have_as_ppc_mftocrf=yes
573AC_MSG_RESULT([yes])
574], [
575ac_have_as_ppc_mftocrf=no
576AC_MSG_RESULT([no])
577])
578if test x$ac_have_as_ppc_mftocrf = xyes ; then
579 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
580fi
581
582
sewardjb5f6f512005-03-10 23:59:00 +0000583# Check for TLS support in the compiler and linker
584AC_CACHE_CHECK([for TLS support], vg_cv_tls,
585 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
586 [vg_cv_tls=$enableval],
587 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
588 [[return foo;]])],
589 [vg_cv_tls=yes],
590 [vg_cv_tls=no])])])
591
592if test "$vg_cv_tls" = yes; then
593AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
594fi
sewardj5b754b42002-06-03 22:53:35 +0000595
sewardj535c50f2005-06-04 23:14:53 +0000596
sewardjde4a1d02002-03-22 01:27:54 +0000597# Checks for header files.
598AC_HEADER_STDC
nethercote3d260f62004-10-31 19:39:18 +0000599AC_CHECK_HEADERS([sys/endian.h endian.h mqueue.h])
sewardjde4a1d02002-03-22 01:27:54 +0000600
sewardj535c50f2005-06-04 23:14:53 +0000601
sewardjde4a1d02002-03-22 01:27:54 +0000602# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000603AC_TYPE_UID_T
604AC_TYPE_OFF_T
605AC_TYPE_SIZE_T
606AC_HEADER_TIME
607
sewardj535c50f2005-06-04 23:14:53 +0000608
sewardjde4a1d02002-03-22 01:27:54 +0000609# Checks for library functions.
610AC_FUNC_MEMCMP
611AC_FUNC_MMAP
612AC_TYPE_SIGNAL
613
thughesbeb6eb92004-06-14 12:33:43 +0000614AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000615
sewardj80637752006-03-02 13:48:21 +0000616
sewardje9fa5062006-03-12 18:29:18 +0000617# Do we have a useable MPI setup on the primary target
618# (mpicc, and suitable MPI2 headers?)
619# Note: this is a kludge in that it assumes the specified mpicc
620# understands '-m32' or '-m64', as established above
sewardj0ad46092006-03-02 17:09:16 +0000621MPI_CC="mpicc"
sewardje9fa5062006-03-12 18:29:18 +0000622mflag_primary=
623if test x$VG_PLATFORM_PRI = xX86_LINUX \
624 -o x$VG_PLATFORM_PRI = xPPC32_LINUX ; then
625 mflag_primary=$FLAG_M32
626elif test x$VG_PLATFORM_PRI = xAMD64_LINUX \
627 -o x$VG_PLATFORM_PRI = xPPC64_LINUX ; then
628 mflag_primary=$FLAG_M64
629fi
630
sewardj0ad46092006-03-02 17:09:16 +0000631AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +0000632 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +0000633 MPI_CC=$withval
634)
sewardj1a85e602006-03-08 15:26:10 +0000635AC_MSG_CHECKING([for usable MPI2-compliant mpicc and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +0000636saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +0000637saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +0000638CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +0000639CFLAGS=$mflag_primary
sewardjd3fcc642006-03-09 02:49:56 +0000640AC_TRY_LINK([
sewardj1a85e602006-03-08 15:26:10 +0000641#include <mpi.h>
642#include <stdio.h>
sewardjde4f3842006-03-09 02:41:41 +0000643],[
644 int r = MPI_Init(NULL,NULL);
645 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
646 return r;
647], [
sewardj1a85e602006-03-08 15:26:10 +0000648ac_have_mpi2=yes
649AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +0000650], [
sewardj1a85e602006-03-08 15:26:10 +0000651ac_have_mpi2=no
sewardj80637752006-03-02 13:48:21 +0000652AC_MSG_RESULT([no])
653])
sewardj0ad46092006-03-02 17:09:16 +0000654CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +0000655CFLAGS=$saved_CFLAGS
sewardj80637752006-03-02 13:48:21 +0000656
sewardj1a85e602006-03-08 15:26:10 +0000657AM_CONDITIONAL(BUILD_MPIWRAP, test x$ac_have_mpi2 = xyes)
sewardj0ad46092006-03-02 17:09:16 +0000658AC_SUBST(MPI_CC)
sewardj80637752006-03-02 13:48:21 +0000659
660
661# -------------------- ok. We're done. --------------------
662
gobrye721a522002-03-22 13:38:30 +0000663AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000664 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000665 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +0000666 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000667 docs/Makefile
njn3e986b22004-11-30 10:43:45 +0000668 docs/lib/Makefile
669 docs/images/Makefile
njnf7c00b12005-07-19 21:46:19 +0000670 docs/internals/Makefile
njn3e986b22004-11-30 10:43:45 +0000671 docs/xml/Makefile
njn254d542432002-09-23 16:09:39 +0000672 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000673 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +0000674 perf/Makefile
675 perf/vg_perf
njn254d542432002-09-23 16:09:39 +0000676 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000677 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000678 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000679 memcheck/Makefile
680 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000681 memcheck/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000682 memcheck/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000683 memcheck/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000684 memcheck/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000685 memcheck/docs/Makefile
686 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000687 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000688 cachegrind/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000689 cachegrind/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000690 cachegrind/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000691 cachegrind/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000692 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000693 cachegrind/cg_annotate
weidendoa17f2a32006-03-20 10:27:30 +0000694 callgrind/Makefile
695 callgrind/callgrind_annotate
696 callgrind/callgrind_control
697 callgrind/tests/Makefile
698 callgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000699 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000700 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000701 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000702 massif/Makefile
703 massif/hp2ps/Makefile
704 massif/tests/Makefile
705 massif/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000706 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000707 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000708 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000709 none/Makefile
710 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +0000711 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +0000712 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +0000713 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +0000714 none/tests/x86/Makefile
njn9bc8c002002-10-02 13:49:13 +0000715 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000716)
gobry3b777892002-04-04 09:18:39 +0000717
718cat<<EOF
719
sewardj01262142006-01-04 01:20:28 +0000720 Primary build target: ${VG_PLATFORM_PRI}
sewardj80637752006-03-02 13:48:21 +0000721 Secondary build target: ${VG_PLATFORM_SEC}
sewardj01262142006-01-04 01:20:28 +0000722 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +0000723
gobry3b777892002-04-04 09:18:39 +0000724EOF
725
726cat<<EOF > default.supp
727# This is a generated file, composed of the following suppression rules:
728#
729# ${DEFAULT_SUPP}
730#
731
732EOF
733
734for file in ${DEFAULT_SUPP} ; do
735 cat ${srcdir}/$file >> default.supp
736done