blob: 1c6560dac61833fe85fe97ad68adedb6392990ce [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.
sewardj45a1fd02010-10-15 08:52:43 +000011AC_INIT(Valgrind, 3.7.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)
bart3a2dac02008-03-18 17:40:38 +000014AM_INIT_AUTOMAKE([foreign])
sewardjde4a1d02002-03-22 01:27:54 +000015
gobryb0ed4672002-03-27 20:58:58 +000016AM_MAINTAINER_MODE
17
njn7fd6d382009-01-22 21:56:32 +000018#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +000019# Checks for various programs.
20#----------------------------------------------------------------------------
bartaca399a2010-08-15 18:54:15 +000021CFLAGS="-Wno-long-long $CFLAGS"
gobrye721a522002-03-22 13:38:30 +000022
sewardjde4a1d02002-03-22 01:27:54 +000023AC_PROG_LN_S
24AC_PROG_CC
bart0affa492008-03-18 17:53:09 +000025AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000026AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000027AC_PROG_CXX
njn629a5ec2009-07-14 01:29:39 +000028# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
29# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
30# base (eg. most likely as Darwin-specific tests) we'll need one of the
31# following:
njn0cd26892009-07-12 23:07:13 +000032# - put AC_PROG_OBJC in a Darwin-specific part of this file
33# - Use AC_PROG_OBJC here and up the minimum autoconf version
34# - Use the following, which is apparently equivalent:
35# m4_ifdef([AC_PROG_OBJC],
36# [AC_PROG_OBJC],
37# [AC_CHECK_TOOL([OBJC], [gcc])
38# AC_SUBST([OBJC])
39# AC_SUBST([OBJCFLAGS])
40# ])
sewardjde4a1d02002-03-22 01:27:54 +000041AC_PROG_RANLIB
bart07de2c92010-05-29 06:44:28 +000042# provide a very basic definition for AC_PROG_SED if it's not provided by
43# autoconf (as e.g. in autoconf 2.59).
44m4_ifndef([AC_PROG_SED],
45 [AC_DEFUN([AC_PROG_SED],
46 [AC_ARG_VAR([SED])
47 AC_CHECK_PROGS([SED],[gsed sed])])])
bart12e91122010-05-15 08:37:24 +000048AC_PROG_SED
sewardjde4a1d02002-03-22 01:27:54 +000049
bartcddeaf52008-05-25 15:58:11 +000050# If no AR variable was specified, look up the name of the archiver. Otherwise
51# do not touch the AR variable.
52if test "x$AR" = "x"; then
bart07de2c92010-05-29 06:44:28 +000053 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
bartcddeaf52008-05-25 15:58:11 +000054fi
55AC_ARG_VAR([AR],[Archiver command])
56
gobrye721a522002-03-22 13:38:30 +000057# Check for the compiler support
58if test "${GCC}" != "yes" ; then
59 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
60fi
61
sewardj2f685952002-12-22 19:32:23 +000062# figure out where perl lives
63AC_PATH_PROG(PERL, perl)
64
njn9315df32003-04-16 20:50:50 +000065# figure out where gdb lives
sewardjf8722ca2008-11-17 00:20:45 +000066AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
njnfe408942004-11-23 17:52:24 +000067AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000068
daywalker48ccca52002-04-15 00:31:58 +000069# some older automake's don't have it so try something on our own
70ifdef([AM_PROG_AS],[AM_PROG_AS],
71[
gobry1be19852002-03-26 20:44:55 +000072AS="${CC}"
73AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000074
gobry1be19852002-03-26 20:44:55 +000075ASFLAGS=""
76AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000077])
gobry3b777892002-04-04 09:18:39 +000078
gobry3b777892002-04-04 09:18:39 +000079
njn0d2e58f2009-02-25 04:57:56 +000080# Check if 'diff' supports -u (universal diffs) and use it if possible.
81
82AC_MSG_CHECKING([for diff -u])
83AC_SUBST(DIFF)
84
sewardj6e9de462011-06-28 07:25:29 +000085# Comparing two identical files results in 0.
njn31f665e2009-02-26 21:25:50 +000086tmpfile="tmp-xxx-yyy-zzz"
87touch $tmpfile;
88if diff -u $tmpfile $tmpfile ; then
njn0d2e58f2009-02-25 04:57:56 +000089 AC_MSG_RESULT([yes])
90 DIFF="diff -u"
91else
92 AC_MSG_RESULT([no])
93 DIFF="diff"
94fi
njn31f665e2009-02-26 21:25:50 +000095rm $tmpfile
njn0d2e58f2009-02-25 04:57:56 +000096
97
sewardj535c50f2005-06-04 23:14:53 +000098# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +000099AC_MSG_CHECKING([for a supported version of gcc])
100
bart07de2c92010-05-29 06:44:28 +0000101[gcc_version=`${CC} --version | head -n 1 | $SED 's/^[^0-9]*\([0-9.]*\).*$/\1/'`]
gobrye721a522002-03-22 13:38:30 +0000102
103case "${gcc_version}" in
bart76719bf2008-04-19 07:47:56 +0000104 2.*)
gobrye721a522002-03-22 13:38:30 +0000105 AC_MSG_RESULT([no (${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000106 AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
107 ;;
gobrye721a522002-03-22 13:38:30 +0000108 *)
109 AC_MSG_RESULT([ok (${gcc_version})])
110 ;;
111esac
112
njn7fd6d382009-01-22 21:56:32 +0000113#----------------------------------------------------------------------------
114# Arch/OS/platform tests.
115#----------------------------------------------------------------------------
116# We create a number of arch/OS/platform-related variables. We prefix them
117# all with "VGCONF_" which indicates that they are defined at
118# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
119# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000120
sewardjde4a1d02002-03-22 01:27:54 +0000121AC_CANONICAL_HOST
122
123AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000124
njn7fd6d382009-01-22 21:56:32 +0000125# ARCH_MAX reflects the most that this CPU can do: for example if it
126# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
127# Ditto for amd64. It is used for more configuration below, but is not used
128# outside this file.
gobrye721a522002-03-22 13:38:30 +0000129case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000130 i?86)
131 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000132 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000133 ;;
134
njnfe408942004-11-23 17:52:24 +0000135 x86_64)
136 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000137 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000138 ;;
139
sewardj2c48c7b2005-11-29 13:05:56 +0000140 powerpc64)
141 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000142 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000143 ;;
144
145 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000146 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000147 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000148 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000149 ;;
150
sewardjb5b87402011-03-07 16:05:35 +0000151 s390x)
152 AC_MSG_RESULT([ok (${host_cpu})])
153 ARCH_MAX="s390x"
154 ;;
155
sewardj59570ff2010-01-01 11:59:33 +0000156 armv7*)
157 AC_MSG_RESULT([ok (${host_cpu})])
158 ARCH_MAX="arm"
159 ;;
160
sewardjde4a1d02002-03-22 01:27:54 +0000161 *)
162 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000163 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000164 ;;
165esac
166
njn7fd6d382009-01-22 21:56:32 +0000167#----------------------------------------------------------------------------
168
sewardj86e992f2006-01-28 18:39:09 +0000169# Sometimes it's convenient to subvert the bi-arch build system and
170# just have a single build even though the underlying platform is
171# capable of both. Hence handle --enable-only64bit and
172# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000173# [Actually, if either of these options are used, I think both get built,
174# but only one gets installed. So if you use an in-place build, both can be
175# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000176
177# Check if a 64-bit only build has been requested
178AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
179 [AC_ARG_ENABLE(only64bit,
180 [ --enable-only64bit do a 64-bit only build],
181 [vg_cv_only64bit=$enableval],
182 [vg_cv_only64bit=no])])
183
184# Check if a 32-bit only build has been requested
185AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
186 [AC_ARG_ENABLE(only32bit,
187 [ --enable-only32bit do a 32-bit only build],
188 [vg_cv_only32bit=$enableval],
189 [vg_cv_only32bit=no])])
190
191# Stay sane
192if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
193 AC_MSG_ERROR(
194 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
195fi
196
njn7fd6d382009-01-22 21:56:32 +0000197#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000198
njn311303f2009-02-06 03:46:50 +0000199# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
200# compilation of many C files via -VGO_$(VGCONF_OS) and
201# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000202AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000203AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000204
njnf76d27a2009-05-28 01:53:07 +0000205DEFAULT_SUPP=""
206
gobrye721a522002-03-22 13:38:30 +0000207case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000208 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000209 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000210 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000211
212 # Ok, this is linux. Check the kernel version
213 AC_MSG_CHECKING([for the kernel version])
214
215 kernel=`uname -r`
216
217 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000218 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000219 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
220 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x or Linux 3.x])
mueller8c68e042004-01-03 15:21:14 +0000221 ;;
222
223 2.4.*)
224 AC_MSG_RESULT([2.4 family (${kernel})])
225 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
226 ;;
227
mueller8c68e042004-01-03 15:21:14 +0000228 *)
229 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000230 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000231 ;;
232 esac
233
234 ;;
235
njnf76d27a2009-05-28 01:53:07 +0000236 *darwin*)
237 AC_MSG_RESULT([ok (${host_os})])
238 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000239 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
240 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
241 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
njnf76d27a2009-05-28 01:53:07 +0000242
243 AC_MSG_CHECKING([for the kernel version])
244 kernel=`uname -r`
245
246 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
247 # has only one relevant version, the OS version. The `uname` check
248 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000249 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
250 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000251 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000252 #
253 # XXX: `uname -r` won't do the right thing for cross-compiles, but
254 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000255 #
256 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
257 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
258 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
259 # time support for 10.5 (the 9.* pattern just below), I'll leave it
260 # in for now, just in case anybody wants to give it a try. But I'm
261 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000262 case "${kernel}" in
263 9.*)
264 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000265 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000266 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000267 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000268 ;;
njnea2d6fd2010-07-01 00:20:20 +0000269 10.*)
270 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
271 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
272 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
273 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
274 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000275 11.*)
276 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
277 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
278 # FIXME: change these to xx11.supp
279 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
280 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
281 ;;
282 *)
njnf76d27a2009-05-28 01:53:07 +0000283 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000284 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000285 ;;
286 esac
287 ;;
288
sewardjde4a1d02002-03-22 01:27:54 +0000289 *)
290 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000291 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000292 ;;
293esac
294
njn7fd6d382009-01-22 21:56:32 +0000295#----------------------------------------------------------------------------
296
tomd6398392006-06-07 17:44:36 +0000297# If we are building on a 64 bit platform test to see if the system
298# supports building 32 bit programs and disable 32 bit support if it
299# does not support building 32 bit programs
300
njn7fd6d382009-01-22 21:56:32 +0000301case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000302 amd64-linux|ppc64-linux)
303 AC_MSG_CHECKING([for 32 bit build support])
304 safe_CFLAGS=$CFLAGS
305 CFLAGS="-m32"
306 AC_TRY_LINK(, [
njn9890ee12009-01-21 22:25:50 +0000307 return 0;
tomd6398392006-06-07 17:44:36 +0000308 ],
309 [
310 AC_MSG_RESULT([yes])
311 ], [
312 vg_cv_only64bit="yes"
313 AC_MSG_RESULT([no])
314 ])
315 CFLAGS=$safe_CFLAGS;;
316esac
317
318if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
319 AC_MSG_ERROR(
320 [--enable-only32bit was specified but system does not support 32 bit builds])
321fi
nethercote888ecb72004-08-23 14:54:40 +0000322
njn7fd6d382009-01-22 21:56:32 +0000323#----------------------------------------------------------------------------
324
njn311303f2009-02-06 03:46:50 +0000325# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
326# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
327# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
328# above) will be "amd64" since that reflects the most that this cpu can do,
329# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
330# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000331# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
332# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
333AC_SUBST(VGCONF_ARCH_PRI)
334
njn3f8a6e92009-06-02 00:20:47 +0000335# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
336# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
337# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
338# It is empty if there is no secondary target.
339AC_SUBST(VGCONF_ARCH_SEC)
340
njn311303f2009-02-06 03:46:50 +0000341# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
342# The entire system, including regression and performance tests, will be
343# built for this target. The "_CAPS" indicates that the name is in capital
344# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000345# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000346# convention and cannot contain '-' characters. This is in contrast to
347# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000348AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
349
350# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
351# Valgrind and tools will also be built for this target, but not the
352# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000353#
njn7fd6d382009-01-22 21:56:32 +0000354# By default, the primary arch is the same as the "max" arch, as commented
355# above (at the definition of ARCH_MAX). We may choose to downgrade it in
356# the big case statement just below here, in the case where we're building
357# on a 64 bit machine but have been requested only to do a 32 bit build.
358AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
359
sewardj01262142006-01-04 01:20:28 +0000360AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000361
njnea2d6fd2010-07-01 00:20:20 +0000362# NB. The load address for a given platform may be specified in more
363# than one place, in some cases, depending on whether we're doing a biarch,
364# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
365# Be careful to give consistent values in all subcases. Also, all four
366# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
367# even if it is to "0xUNSET".
368#
njn7fd6d382009-01-22 21:56:32 +0000369case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000370 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000371 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000372 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000373 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
374 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000375 valt_load_address_pri_norml="0x38000000"
376 valt_load_address_pri_inner="0x28000000"
377 valt_load_address_sec_norml="0xUNSET"
378 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000379 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000380 ;;
381 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000382 valt_load_address_sec_norml="0xUNSET"
383 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000384 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000385 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000386 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000387 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
388 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000389 valt_load_address_pri_norml="0x38000000"
390 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000391 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000392 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000393 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000394 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
395 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000396 valt_load_address_pri_norml="0x38000000"
397 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000398 else
njn7fd6d382009-01-22 21:56:32 +0000399 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000400 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000401 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
402 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000403 valt_load_address_pri_norml="0x38000000"
404 valt_load_address_pri_inner="0x28000000"
405 valt_load_address_sec_norml="0x38000000"
406 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000407 fi
njn377c43f2009-05-19 07:39:22 +0000408 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000409 ;;
410 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000411 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000412 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000413 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
414 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000415 valt_load_address_pri_norml="0x38000000"
416 valt_load_address_pri_inner="0x28000000"
417 valt_load_address_sec_norml="0xUNSET"
418 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000419 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000420 ;;
421 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000422 valt_load_address_sec_norml="0xUNSET"
423 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000424 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000425 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000426 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000427 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
428 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000429 valt_load_address_pri_norml="0x38000000"
430 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000431 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000432 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000433 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000434 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
435 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000436 valt_load_address_pri_norml="0x38000000"
437 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000438 else
njn7fd6d382009-01-22 21:56:32 +0000439 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000440 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000441 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
442 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000443 valt_load_address_pri_norml="0x38000000"
444 valt_load_address_pri_inner="0x28000000"
445 valt_load_address_sec_norml="0x38000000"
446 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000447 fi
njn377c43f2009-05-19 07:39:22 +0000448 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000449 ;;
njncc58cea2010-07-05 07:21:22 +0000450 # Darwin gets identified as 32-bit even when it supports 64-bit.
451 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
452 # all Macs support both 32-bit and 64-bit, so we just build both. If
453 # someone has a really old 32-bit only machine they can (hopefully?)
454 # build with --enable-only32bit. See bug 243362.
455 x86-darwin|amd64-darwin)
456 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000457 valt_load_address_sec_norml="0xUNSET"
458 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000459 if test x$vg_cv_only64bit = xyes; then
460 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000461 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000462 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
463 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000464 valt_load_address_pri_norml="0x138000000"
465 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000466 elif test x$vg_cv_only32bit = xyes; then
467 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000468 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000469 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
470 VGCONF_PLATFORM_SEC_CAPS=""
471 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000472 valt_load_address_pri_norml="0x38000000"
473 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000474 else
475 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000476 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000477 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
478 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000479 valt_load_address_pri_norml="0x138000000"
480 valt_load_address_pri_inner="0x128000000"
481 valt_load_address_sec_norml="0x38000000"
482 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000483 fi
njnf76d27a2009-05-28 01:53:07 +0000484 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
485 ;;
sewardj59570ff2010-01-01 11:59:33 +0000486 arm-linux)
487 VGCONF_ARCH_PRI="arm"
488 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
489 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000490 valt_load_address_pri_norml="0x38000000"
491 valt_load_address_pri_inner="0x28000000"
492 valt_load_address_sec_norml="0xUNSET"
493 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000494 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
495 ;;
sewardjb5b87402011-03-07 16:05:35 +0000496 s390x-linux)
497 VGCONF_ARCH_PRI="s390x"
498 VGCONF_ARCH_SEC=""
499 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
500 VGCONF_PLATFORM_SEC_CAPS=""
501 # we want to have the generated code close to the dispatcher
502 valt_load_address_pri_norml="0x401000000"
503 valt_load_address_pri_inner="0x410000000"
504 valt_load_address_sec_norml="0xUNSET"
505 valt_load_address_sec_inner="0xUNSET"
506 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
507 ;;
nethercote888ecb72004-08-23 14:54:40 +0000508 *)
njn7fd6d382009-01-22 21:56:32 +0000509 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000510 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000511 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
512 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000513 valt_load_address_pri_norml="0xUNSET"
514 valt_load_address_pri_inner="0xUNSET"
515 valt_load_address_sec_norml="0xUNSET"
516 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000517 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000518 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000519 ;;
520esac
sewardjde4a1d02002-03-22 01:27:54 +0000521
njn7fd6d382009-01-22 21:56:32 +0000522#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000523
njn7fd6d382009-01-22 21:56:32 +0000524# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
525# defined.
526AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
527 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000528 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
529 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
530 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000531AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000532 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
533 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000534AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
535 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000536 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000537AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000538 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000539AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
540 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000541AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
542 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000543
njn7fd6d382009-01-22 21:56:32 +0000544# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
545# become defined.
546AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
547 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
548 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
549AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
550 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
551AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
552 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
553 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
554AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
555 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000556AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
557 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000558AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
559 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
560 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000561
njnf76d27a2009-05-28 01:53:07 +0000562AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
563 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
564 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
565AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
566 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
567
568
sewardj72a2d802010-07-29 05:24:20 +0000569# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000570# Relies on the assumption that the primary and secondary targets are
571# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000572AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
573 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
574 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
575 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000576 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000577 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
578 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000579AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
580 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
581 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000582
583
njn7fd6d382009-01-22 21:56:32 +0000584# Sometimes, in the Makefile.am files, it's useful to know whether or not
585# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000586AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000587 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000588
tomb637bad2005-11-08 12:28:35 +0000589
njn7fd6d382009-01-22 21:56:32 +0000590#----------------------------------------------------------------------------
591# Inner Valgrind?
592#----------------------------------------------------------------------------
593
njnd74b0ef2009-01-20 06:06:52 +0000594# Check if this should be built as an inner Valgrind, to be run within
595# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000596AC_SUBST(VALT_LOAD_ADDRESS_PRI)
597AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000598AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
599 [AC_ARG_ENABLE(inner,
600 [ --enable-inner enables self-hosting],
601 [vg_cv_inner=$enableval],
602 [vg_cv_inner=no])])
603if test "$vg_cv_inner" = yes; then
604 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000605 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
606 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000607else
njnea2d6fd2010-07-01 00:20:20 +0000608 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
609 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000610fi
611
612
njn7fd6d382009-01-22 21:56:32 +0000613#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000614# Extra fine-tuning of installation directories
615#----------------------------------------------------------------------------
616AC_ARG_WITH(tmpdir,
617 [ --with-tmpdir=PATH Specify path for temporary files],
618 tmpdir="$withval",
619 tmpdir="/tmp")
620AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
621
sewardj0ba37c92011-07-12 11:46:24 +0000622
sewardjcb495c82011-07-11 20:42:34 +0000623#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000624# Libc and suppressions
625#----------------------------------------------------------------------------
626# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000627AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000628
bart12e91122010-05-15 08:37:24 +0000629AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000630
bart12e91122010-05-15 08:37:24 +0000631if test x$ac_cv_header_features_h = xyes; then
632 rm -f conftest.$ac_ext
633 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000634#include <features.h>
bart12e91122010-05-15 08:37:24 +0000635#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
636glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000637#endif
bart12e91122010-05-15 08:37:24 +0000638_ACEOF
639 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
640fi
bartb7c3f082010-05-13 06:32:36 +0000641
njnf76d27a2009-05-28 01:53:07 +0000642# not really a version check
643AC_EGREP_CPP([DARWIN_LIBC], [
644#include <sys/cdefs.h>
645#if defined(__DARWIN_VERS_1050)
646 DARWIN_LIBC
647#endif
648],
649GLIBC_VERSION="darwin")
650
sewardjcb495c82011-07-11 20:42:34 +0000651# not really a version check
652AC_EGREP_CPP([BIONIC_LIBC], [
653#if defined(__ANDROID__)
654 BIONIC_LIBC
655#endif
656],
657GLIBC_VERSION="bionic")
658
659
dirk07596a22008-04-25 11:33:30 +0000660AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000661
dirk07596a22008-04-25 11:33:30 +0000662case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000663 2.2)
664 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000665 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000666 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
667 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000668 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000669 ;;
670
sewardj08c7f012002-10-07 23:56:55 +0000671 2.3)
672 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000673 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000674 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000675 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000676 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000677 ;;
678
njn781dba52005-06-30 04:06:38 +0000679 2.4)
680 AC_MSG_RESULT(2.4 family)
681 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000682 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000683 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000684 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000685 ;;
686
dirkaece45c2006-10-12 08:17:49 +0000687 2.5)
688 AC_MSG_RESULT(2.5 family)
689 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000690 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000691 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000692 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000693 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000694 2.6)
695 AC_MSG_RESULT(2.6 family)
696 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000697 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000698 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000699 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000700 ;;
701 2.7)
702 AC_MSG_RESULT(2.7 family)
703 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000704 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000705 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000706 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000707 ;;
dirk07596a22008-04-25 11:33:30 +0000708 2.8)
709 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000710 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000711 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
712 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
713 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
714 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000715 2.9)
716 AC_MSG_RESULT(2.9 family)
717 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
718 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
719 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
720 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
721 ;;
sewardj5d425e82009-02-01 19:01:11 +0000722 2.10)
723 AC_MSG_RESULT(2.10 family)
724 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
725 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
726 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
727 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
728 ;;
bart0fac7ff2009-11-15 19:11:19 +0000729 2.11)
730 AC_MSG_RESULT(2.11 family)
731 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
732 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
733 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
734 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000735 ;;
736 2.12)
737 AC_MSG_RESULT(2.12 family)
738 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
739 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
740 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
741 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000742 ;;
tomebd619b2011-02-10 09:09:09 +0000743 2.13)
744 AC_MSG_RESULT(2.13 family)
745 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
746 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
747 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
748 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
749 ;;
tomcc077412011-06-07 21:52:26 +0000750 2.14)
751 AC_MSG_RESULT(2.14 family)
752 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
753 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
754 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
755 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
756 ;;
njnf76d27a2009-05-28 01:53:07 +0000757 darwin)
758 AC_MSG_RESULT(Darwin)
759 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
760 # DEFAULT_SUPP set by kernel version check above.
761 ;;
sewardjcb495c82011-07-11 20:42:34 +0000762 bionic)
763 AC_MSG_RESULT(Bionic)
764 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
765 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
766 ;;
dirkaece45c2006-10-12 08:17:49 +0000767
sewardjde4a1d02002-03-22 01:27:54 +0000768 *)
bart12e91122010-05-15 08:37:24 +0000769 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
tomcc077412011-06-07 21:52:26 +0000770 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.14])
njnf76d27a2009-05-28 01:53:07 +0000771 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000772 ;;
773esac
774
dirk07596a22008-04-25 11:33:30 +0000775AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000776
sewardj414f3582008-07-18 20:46:00 +0000777
778# Add default suppressions for the X client libraries. Make no
779# attempt to detect whether such libraries are installed on the
780# build machine (or even if any X facilities are present); just
781# add the suppressions antidisirregardless.
782DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
783DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000784
sewardjd2f95a02011-05-11 16:04:28 +0000785# Add glibc and X11 suppressions for exp-sgcheck
786DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000787
sewardj2e10a682003-04-07 19:36:41 +0000788
njn7fd6d382009-01-22 21:56:32 +0000789#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000790# Platform variants?
791#----------------------------------------------------------------------------
792
793# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
794# But there are times where we need a bit more control. The motivating
795# and currently only case is Android: this is almost identical to arm-linux,
796# but not quite. So this introduces the concept of platform variant tags,
797# which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
798# with the main -DVGP_<arch>_<os> definition.
799#
800# In almost all cases, the <variant> bit is "vanilla". But for Android
801# it is "android" instead.
802#
803# Consequently (eg), plain arm-linux would build with
804#
805# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
806#
807# whilst an Android build would have
808#
809# -DVGP_arm_linux -DVGPV_arm_linux_android
810#
811# The setup of the platform variant is pushed relatively far down this
812# file in order that we can inspect any of the variables set above.
813
814# In the normal case ..
815VGCONF_PLATVARIANT="vanilla"
816
817# Android on ARM ?
818if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
819 -a "$GLIBC_VERSION" = "bionic";
820then
821 VGCONF_PLATVARIANT="android"
822fi
823
824AC_SUBST(VGCONF_PLATVARIANT)
825
826
827# FIXME: do we also want to define automake variables
828# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
829# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
830# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
831# do that. Problem is that we can't do and-ing in Makefile.am's, but
832# that's what we'd need to do to use this, since what we'd want to write
833# is something like
834#
835# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
836#
sewardj0ba37c92011-07-12 11:46:24 +0000837# Hmm. Can't think of a nice clean solution to this.
838
839AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
840 test x$VGCONF_PLATVARIANT = xvanilla)
841AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
842 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000843
844
845#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000846# Checking for various library functions and other definitions
847#----------------------------------------------------------------------------
848
bart59e2f182008-04-28 16:22:53 +0000849# Check for CLOCK_MONOTONIC
850
851AC_MSG_CHECKING([for CLOCK_MONOTONIC])
852
853AC_TRY_COMPILE(
854[
855#include <time.h>
856], [
857 struct timespec t;
858 clock_gettime(CLOCK_MONOTONIC, &t);
859 return 0;
860],
861[
862AC_MSG_RESULT([yes])
863AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
864 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
865], [
866AC_MSG_RESULT([no])
867])
868
bartfea06922008-05-03 09:12:15 +0000869
sewardj0c09bf02011-07-11 22:11:58 +0000870# Check for PTHREAD_RWLOCK_T
871
872AC_MSG_CHECKING([for pthread_rwlock_t])
873
874AC_TRY_COMPILE(
875[
876#define _GNU_SOURCE
877#include <pthread.h>
878], [
879 pthread_rwlock_t rwl;
880],
881[
882AC_MSG_RESULT([yes])
883AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
884 [Define to 1 if you have the `pthread_rwlock_t' type.])
885], [
886AC_MSG_RESULT([no])
887])
888
889
bartfea06922008-05-03 09:12:15 +0000890# Check for PTHREAD_MUTEX_ADAPTIVE_NP
891
892AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
893
894AC_TRY_COMPILE(
895[
896#define _GNU_SOURCE
897#include <pthread.h>
898], [
899 return (PTHREAD_MUTEX_ADAPTIVE_NP);
900],
901[
902AC_MSG_RESULT([yes])
903AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
904 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
905], [
906AC_MSG_RESULT([no])
907])
908
909
910# Check for PTHREAD_MUTEX_ERRORCHECK_NP
911
912AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
913
914AC_TRY_COMPILE(
915[
916#define _GNU_SOURCE
917#include <pthread.h>
918], [
919 return (PTHREAD_MUTEX_ERRORCHECK_NP);
920],
921[
922AC_MSG_RESULT([yes])
923AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
924 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
925], [
926AC_MSG_RESULT([no])
927])
928
929
930# Check for PTHREAD_MUTEX_RECURSIVE_NP
931
932AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
933
934AC_TRY_COMPILE(
935[
936#define _GNU_SOURCE
937#include <pthread.h>
938], [
939 return (PTHREAD_MUTEX_RECURSIVE_NP);
940],
941[
942AC_MSG_RESULT([yes])
943AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
944 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
945], [
946AC_MSG_RESULT([no])
947])
948
949
950# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
951
952AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
953
954AC_TRY_COMPILE(
955[
956#define _GNU_SOURCE
957#include <pthread.h>
958], [
959 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
960 return 0;
961],
962[
963AC_MSG_RESULT([yes])
964AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
965 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
966], [
967AC_MSG_RESULT([no])
968])
969
970
bart5e389f12008-04-05 12:53:15 +0000971# Check whether pthread_mutex_t has a member called __m_kind.
972
bartb11355c2010-04-29 16:37:26 +0000973AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
974 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
975 1,
976 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
977 ],
978 [],
979 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +0000980
981
982# Check whether pthread_mutex_t has a member called __data.__kind.
983
bartb11355c2010-04-29 16:37:26 +0000984AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
985 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
986 1,
987 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
988 ],
989 [],
990 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +0000991
992
bart62c370e2008-05-12 18:50:51 +0000993# does this compiler support -maltivec and does it have the include file
994# <altivec.h> ?
995
996AC_MSG_CHECKING([for Altivec])
997
998safe_CFLAGS=$CFLAGS
999CFLAGS="-maltivec"
1000
1001AC_TRY_COMPILE(
1002[
1003#include <altivec.h>
1004], [
1005 vector unsigned int v;
1006],
1007[
1008ac_have_altivec=yes
1009AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001010AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001011 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001012], [
1013ac_have_altivec=no
1014AC_MSG_RESULT([no])
1015])
1016CFLAGS=$safe_CFLAGS
1017
sewardj0e342a02010-09-03 23:49:33 +00001018AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001019
1020
sewardjf34eb492011-04-15 11:57:05 +00001021# Check that both: the compiler supports -mvsx and that the assembler
1022# understands VSX instructions. If either of those doesn't work,
1023# conclude that we can't do VSX. NOTE: basically this is a kludge
1024# in that it conflates two things that should be separate -- whether
1025# the compiler understands the flag vs whether the assembler
1026# understands the opcodes. This really ought to be cleaned up
1027# and done properly, like it is for x86/x86_64.
1028
1029AC_MSG_CHECKING([for VSX])
1030
1031safe_CFLAGS=$CFLAGS
1032CFLAGS="-mvsx"
1033
1034AC_TRY_COMPILE(
1035[
1036#include <altivec.h>
1037], [
1038 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001039 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
sewardjf34eb492011-04-15 11:57:05 +00001040],
1041[
1042ac_have_vsx=yes
1043AC_MSG_RESULT([yes])
1044], [
1045ac_have_vsx=no
1046AC_MSG_RESULT([no])
1047])
1048CFLAGS=$safe_CFLAGS
1049
1050AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1051
1052
bart36dd85a2009-04-26 07:11:48 +00001053# Check for pthread_create@GLIBC2.0
1054AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1055
bart16e1c5a2009-04-26 07:38:53 +00001056safe_CFLAGS=$CFLAGS
1057CFLAGS="-lpthread"
bart36dd85a2009-04-26 07:11:48 +00001058AC_TRY_LINK(
1059[
1060extern int pthread_create_glibc_2_0(void*, const void*,
1061 void *(*)(void*), void*);
1062__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1063], [
bart276ed3a2009-05-10 15:41:45 +00001064#ifdef __powerpc__
1065/*
1066 * Apparently on PowerPC linking this program succeeds and generates an
1067 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1068 */
1069#error This test does not work properly on PowerPC.
1070#else
bart16e1c5a2009-04-26 07:38:53 +00001071 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001072#endif
bart16e1c5a2009-04-26 07:38:53 +00001073 return 0;
bart36dd85a2009-04-26 07:11:48 +00001074],
1075[
1076ac_have_pthread_create_glibc_2_0=yes
1077AC_MSG_RESULT([yes])
1078AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1079 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1080], [
1081ac_have_pthread_create_glibc_2_0=no
1082AC_MSG_RESULT([no])
1083])
bart16e1c5a2009-04-26 07:38:53 +00001084CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001085
1086AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001087 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001088
1089
barta50aa8a2008-04-27 06:06:57 +00001090# Check for eventfd_t, eventfd() and eventfd_read()
1091AC_MSG_CHECKING([for eventfd()])
1092
1093AC_TRY_LINK(
1094[
1095#include <sys/eventfd.h>
1096], [
1097 eventfd_t ev;
1098 int fd;
1099
1100 fd = eventfd(5, 0);
1101 eventfd_read(fd, &ev);
1102 return 0;
1103],
1104[
1105AC_MSG_RESULT([yes])
1106AC_DEFINE([HAVE_EVENTFD], 1,
1107 [Define to 1 if you have the `eventfd' function.])
1108AC_DEFINE([HAVE_EVENTFD_READ], 1,
1109 [Define to 1 if you have the `eventfd_read' function.])
1110], [
1111AC_MSG_RESULT([no])
1112])
1113
1114
njn7fd6d382009-01-22 21:56:32 +00001115#----------------------------------------------------------------------------
1116# Checking for supported compiler flags.
1117#----------------------------------------------------------------------------
1118
sewardj535c50f2005-06-04 23:14:53 +00001119# does this compiler support -m32 ?
1120AC_MSG_CHECKING([if gcc accepts -m32])
1121
1122safe_CFLAGS=$CFLAGS
1123CFLAGS="-m32"
1124
1125AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001126 return 0;
sewardj535c50f2005-06-04 23:14:53 +00001127],
1128[
1129FLAG_M32="-m32"
1130AC_MSG_RESULT([yes])
1131], [
1132FLAG_M32=""
1133AC_MSG_RESULT([no])
1134])
1135CFLAGS=$safe_CFLAGS
1136
1137AC_SUBST(FLAG_M32)
1138
1139
sewardj01262142006-01-04 01:20:28 +00001140# does this compiler support -m64 ?
1141AC_MSG_CHECKING([if gcc accepts -m64])
1142
1143safe_CFLAGS=$CFLAGS
1144CFLAGS="-m64"
1145
1146AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001147 return 0;
sewardj01262142006-01-04 01:20:28 +00001148],
1149[
1150FLAG_M64="-m64"
1151AC_MSG_RESULT([yes])
1152], [
1153FLAG_M64=""
1154AC_MSG_RESULT([no])
1155])
1156CFLAGS=$safe_CFLAGS
1157
1158AC_SUBST(FLAG_M64)
1159
1160
sewardj67f1fcc2005-07-03 10:41:02 +00001161# does this compiler support -mmmx ?
1162AC_MSG_CHECKING([if gcc accepts -mmmx])
1163
1164safe_CFLAGS=$CFLAGS
1165CFLAGS="-mmmx"
1166
1167AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001168 return 0;
sewardj67f1fcc2005-07-03 10:41:02 +00001169],
1170[
1171FLAG_MMMX="-mmmx"
1172AC_MSG_RESULT([yes])
1173], [
1174FLAG_MMMX=""
1175AC_MSG_RESULT([no])
1176])
1177CFLAGS=$safe_CFLAGS
1178
1179AC_SUBST(FLAG_MMMX)
1180
1181
1182# does this compiler support -msse ?
1183AC_MSG_CHECKING([if gcc accepts -msse])
1184
1185safe_CFLAGS=$CFLAGS
1186CFLAGS="-msse"
1187
1188AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001189 return 0;
sewardj67f1fcc2005-07-03 10:41:02 +00001190],
1191[
1192FLAG_MSSE="-msse"
1193AC_MSG_RESULT([yes])
1194], [
1195FLAG_MSSE=""
1196AC_MSG_RESULT([no])
1197])
1198CFLAGS=$safe_CFLAGS
1199
1200AC_SUBST(FLAG_MSSE)
1201
1202
sewardj5b754b42002-06-03 22:53:35 +00001203# does this compiler support -mpreferred-stack-boundary=2 ?
1204AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1205
daywalker3664f562003-10-17 13:43:46 +00001206safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001207CFLAGS="-mpreferred-stack-boundary=2"
1208
1209AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001210 return 0;
sewardj5b754b42002-06-03 22:53:35 +00001211],
1212[
1213PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001214AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001215], [
1216PREFERRED_STACK_BOUNDARY=""
1217AC_MSG_RESULT([no])
1218])
daywalker3664f562003-10-17 13:43:46 +00001219CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001220
1221AC_SUBST(PREFERRED_STACK_BOUNDARY)
1222
sewardj535c50f2005-06-04 23:14:53 +00001223
sewardjb5f6f512005-03-10 23:59:00 +00001224# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001225AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001226
1227safe_CFLAGS=$CFLAGS
1228CFLAGS="-Wno-pointer-sign"
1229
1230AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001231 return 0;
sewardjb5f6f512005-03-10 23:59:00 +00001232],
1233[
1234no_pointer_sign=yes
1235AC_MSG_RESULT([yes])
1236], [
1237no_pointer_sign=no
1238AC_MSG_RESULT([no])
1239])
1240CFLAGS=$safe_CFLAGS
1241
1242if test x$no_pointer_sign = xyes; then
1243 CFLAGS="$CFLAGS -Wno-pointer-sign"
1244fi
1245
sewardj535c50f2005-06-04 23:14:53 +00001246
barte026bd22009-07-04 12:17:07 +00001247# does this compiler support -Wno-empty-body ?
1248
1249AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1250
1251safe_CFLAGS=$CFLAGS
1252CFLAGS="-Wno-empty-body"
1253
1254AC_TRY_COMPILE(
1255[ ],
1256[
1257 return 0;
1258],
1259[
1260AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1261AC_MSG_RESULT([yes])
1262],
1263[
1264AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1265AC_MSG_RESULT([no])
1266])
1267CFLAGS=$safe_CFLAGS
1268
1269
bart9d865fa2008-06-23 12:11:49 +00001270# does this compiler support -Wno-format-zero-length ?
1271
1272AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1273
1274safe_CFLAGS=$CFLAGS
1275CFLAGS="-Wno-format-zero-length"
1276
1277AC_TRY_COMPILE(
1278[ ],
1279[
1280 return 0;
1281],
1282[
1283AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1284AC_MSG_RESULT([yes])
1285],
1286[
1287AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1288AC_MSG_RESULT([no])
1289])
1290CFLAGS=$safe_CFLAGS
1291
1292
bart8e216312011-05-15 17:05:36 +00001293# does this compiler support -Wno-nonnull ?
1294
1295AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1296
1297safe_CFLAGS=$CFLAGS
1298CFLAGS="-Wno-nonnull"
1299
1300AC_TRY_COMPILE(
1301[ ],
1302[
1303 return 0;
1304],
1305[
1306AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1307AC_MSG_RESULT([yes])
1308],
1309[
1310AC_SUBST([FLAG_W_NO_NONNULL], [])
1311AC_MSG_RESULT([no])
1312])
1313CFLAGS=$safe_CFLAGS
1314
1315
1316# does this compiler support -Wno-overflow ?
1317
1318AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1319
1320safe_CFLAGS=$CFLAGS
1321CFLAGS="-Wno-overflow"
1322
1323AC_TRY_COMPILE(
1324[ ],
1325[
1326 return 0;
1327],
1328[
1329AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1330AC_MSG_RESULT([yes])
1331],
1332[
1333AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1334AC_MSG_RESULT([no])
1335])
1336CFLAGS=$safe_CFLAGS
1337
1338
bartbf9b85c2009-08-12 12:55:56 +00001339# does this compiler support -Wno-uninitialized ?
1340
1341AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1342
1343safe_CFLAGS=$CFLAGS
1344CFLAGS="-Wno-uninitialized"
1345
1346AC_TRY_COMPILE(
1347[ ],
1348[
1349 return 0;
1350],
1351[
1352AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1353AC_MSG_RESULT([yes])
1354],
1355[
1356AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1357AC_MSG_RESULT([no])
1358])
1359CFLAGS=$safe_CFLAGS
1360
1361
bart56730cd2008-05-11 06:41:46 +00001362# does this compiler support -Wextra or the older -W ?
1363
1364AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1365
1366safe_CFLAGS=$CFLAGS
1367CFLAGS="-Wextra"
1368
1369AC_TRY_COMPILE(
1370[ ],
1371[
1372 return 0;
1373],
1374[
1375AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1376AC_MSG_RESULT([-Wextra])
1377], [
1378 CFLAGS="-W"
1379 AC_TRY_COMPILE(
1380 [ ],
1381 [
1382 return 0;
1383 ],
1384 [
1385 AC_SUBST([FLAG_W_EXTRA], [-W])
1386 AC_MSG_RESULT([-W])
1387 ], [
1388 AC_SUBST([FLAG_W_EXTRA], [])
1389 AC_MSG_RESULT([not supported])
1390 ])
1391])
1392CFLAGS=$safe_CFLAGS
1393
1394
sewardja72c26d2007-05-01 13:44:08 +00001395# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001396AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001397
1398safe_CFLAGS=$CFLAGS
1399CFLAGS="-fno-stack-protector"
1400
1401AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001402 return 0;
sewardja72c26d2007-05-01 13:44:08 +00001403],
1404[
1405no_stack_protector=yes
1406FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1407AC_MSG_RESULT([yes])
1408], [
1409no_stack_protector=no
1410FLAG_FNO_STACK_PROTECTOR=""
1411AC_MSG_RESULT([no])
1412])
1413CFLAGS=$safe_CFLAGS
1414
1415AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1416
1417if test x$no_stack_protector = xyes; then
1418 CFLAGS="$CFLAGS -fno-stack-protector"
1419fi
1420
1421
bart56730cd2008-05-11 06:41:46 +00001422# does this compiler support --param inline-unit-growth=... ?
1423
1424AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1425
1426safe_CFLAGS=$CFLAGS
1427CFLAGS="--param inline-unit-growth=900"
1428
1429AC_TRY_COMPILE(
1430[ ],
1431[
1432 return 0;
1433],
1434[
1435AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1436 ["--param inline-unit-growth=900"])
1437AC_MSG_RESULT([yes])
1438], [
1439AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1440AC_MSG_RESULT([no])
1441])
1442CFLAGS=$safe_CFLAGS
1443
1444
sewardjd3645802010-06-13 22:13:58 +00001445# does the linker support -Wl,--build-id=none ? Note, it's
1446# important that we test indirectly via whichever C compiler
1447# is selected, rather than testing /usr/bin/ld or whatever
1448# directly.
bart699fbac2010-06-08 18:23:59 +00001449
sewardjd3645802010-06-13 22:13:58 +00001450AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001451
1452safe_CFLAGS=$CFLAGS
1453CFLAGS="-Wl,--build-id=none"
1454
bart8508c752010-06-10 06:26:21 +00001455AC_LINK_IFELSE(
1456[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001457[
1458 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1459 AC_MSG_RESULT([yes])
1460], [
1461 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1462 AC_MSG_RESULT([no])
1463])
1464CFLAGS=$safe_CFLAGS
1465
1466
sewardj00f1e622006-03-12 16:47:10 +00001467# does the ppc assembler support "mtocrf" et al?
1468AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1469
1470AC_TRY_COMPILE(, [
sewardjdd4cbe12006-03-12 17:27:44 +00001471__asm__ __volatile__("mtocrf 4,0");
1472__asm__ __volatile__("mfocrf 0,4");
sewardj00f1e622006-03-12 16:47:10 +00001473],
1474[
1475ac_have_as_ppc_mftocrf=yes
1476AC_MSG_RESULT([yes])
1477], [
1478ac_have_as_ppc_mftocrf=no
1479AC_MSG_RESULT([no])
1480])
1481if test x$ac_have_as_ppc_mftocrf = xyes ; then
1482 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1483fi
1484
1485
sewardjb5b87402011-03-07 16:05:35 +00001486CFLAGS=$safe_CFLAGS
1487
sewardjf0aabf82007-03-22 00:24:21 +00001488# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001489# Note, this doesn't generate a C-level symbol. It generates a
1490# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001491AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1492
1493AC_TRY_COMPILE(, [
1494 do { long long int x;
1495 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1496 while (0)
1497],
1498[
1499ac_have_as_sse3=yes
1500AC_MSG_RESULT([yes])
1501], [
1502ac_have_as_sse3=no
1503AC_MSG_RESULT([no])
1504])
sewardjfa18a262007-03-22 12:13:13 +00001505
1506AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001507
1508
sewardj6d6da5b2008-02-09 12:07:40 +00001509# Ditto for SSSE3 instructions (note extra S)
1510# Note, this doesn't generate a C-level symbol. It generates a
1511# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1512AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1513
1514AC_TRY_COMPILE(, [
1515 do { long long int x;
1516 __asm__ __volatile__(
1517 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1518 while (0)
1519],
1520[
1521ac_have_as_ssse3=yes
1522AC_MSG_RESULT([yes])
1523], [
1524ac_have_as_ssse3=no
1525AC_MSG_RESULT([no])
1526])
1527
1528AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1529
1530
sewardj27d176a2011-01-17 11:15:48 +00001531# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1532# Note, this doesn't generate a C-level symbol. It generates a
1533# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001534AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
1535AC_TRY_COMPILE(, [
1536 do {
1537 __asm__ __volatile__(
1538 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1539 while (0)
1540],
1541[
1542ac_have_as_pclmulqdq=yes
1543AC_MSG_RESULT([yes])
1544], [
1545ac_have_as_pclmulqdq=no
1546AC_MSG_RESULT([no])
1547])
1548
1549AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1550
1551
sewardj27d176a2011-01-17 11:15:48 +00001552# does the x86/amd64 assembler understand the LZCNT instruction?
1553# Note, this doesn't generate a C-level symbol. It generates a
1554# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001555AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1556
1557AC_TRY_COMPILE([], [
1558 do {
1559 __asm__ __volatile__("lzcnt %rax,%rax");
1560 } while (0)
1561],
1562[
1563 ac_have_as_lzcnt=yes
1564 AC_MSG_RESULT([yes])
1565], [
1566 ac_have_as_lzcnt=no
1567 AC_MSG_RESULT([no])
1568])
1569
1570AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1571
sewardj27d176a2011-01-17 11:15:48 +00001572
1573# does the x86/amd64 assembler understand SSE 4.2 instructions?
1574# Note, this doesn't generate a C-level symbol. It generates a
1575# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1576AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1577
1578AC_TRY_COMPILE(, [
1579 do { long long int x;
1580 __asm__ __volatile__(
1581 "crc32q %%r15,%%r15" : : : "r15" ); }
1582 while (0)
1583],
1584[
1585ac_have_as_sse42=yes
1586AC_MSG_RESULT([yes])
1587], [
1588ac_have_as_sse42=no
1589AC_MSG_RESULT([no])
1590])
1591
1592AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1593
1594
sewardje089f012010-10-13 21:47:29 +00001595# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1596# when building the tool executables. I think we should get rid of it.
1597#
sewardjb5f6f512005-03-10 23:59:00 +00001598# Check for TLS support in the compiler and linker
bartca9f2ad2008-06-02 07:14:20 +00001599if test "x${cross_compiling}" = "xno"; then
1600# Native compilation: check whether running a program using TLS succeeds.
1601# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1602# succeeds but running programs using TLS fails.
1603AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1604 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1605 [vg_cv_tls=$enableval],
1606 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1607 [[return foo;]])],
1608 [vg_cv_tls=yes],
1609 [vg_cv_tls=no])])])
1610else
1611# Cross-compiling: check whether linking a program using TLS succeeds.
sewardjb5f6f512005-03-10 23:59:00 +00001612AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1613 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1614 [vg_cv_tls=$enableval],
bartcddeaf52008-05-25 15:58:11 +00001615 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
sewardjb5f6f512005-03-10 23:59:00 +00001616 [[return foo;]])],
1617 [vg_cv_tls=yes],
1618 [vg_cv_tls=no])])])
bartca9f2ad2008-06-02 07:14:20 +00001619fi
sewardjb5f6f512005-03-10 23:59:00 +00001620
1621if test "$vg_cv_tls" = yes; then
1622AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1623fi
sewardj5b754b42002-06-03 22:53:35 +00001624
sewardj535c50f2005-06-04 23:14:53 +00001625
njn7fd6d382009-01-22 21:56:32 +00001626#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001627# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001628#----------------------------------------------------------------------------
1629
sewardjde4a1d02002-03-22 01:27:54 +00001630AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001631AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001632 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001633 endian.h \
1634 mqueue.h \
1635 sys/endian.h \
1636 sys/epoll.h \
1637 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001638 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001639 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001640 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001641 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001642 sys/syscall.h \
1643 sys/time.h \
1644 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001645 ])
sewardjde4a1d02002-03-22 01:27:54 +00001646
bart818f17e2011-09-17 06:24:49 +00001647# Verify whether the <linux/futex.h> header is usable.
1648AC_MSG_CHECKING([if <linux/futex.h> is usable])
1649
1650AC_TRY_COMPILE([
1651#include <linux/futex.h>
1652], [
1653 return FUTEX_WAIT;
1654],
1655[
1656AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1657 [Define to 1 if you have a usable <linux/futex.h> header file.])
1658AC_MSG_RESULT([yes])
1659], [
1660AC_MSG_RESULT([no])
1661])
1662
njn7fd6d382009-01-22 21:56:32 +00001663#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001664# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001665#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001666AC_TYPE_UID_T
1667AC_TYPE_OFF_T
1668AC_TYPE_SIZE_T
1669AC_HEADER_TIME
1670
sewardj535c50f2005-06-04 23:14:53 +00001671
njn7fd6d382009-01-22 21:56:32 +00001672#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001673# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001674#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001675AC_FUNC_MEMCMP
1676AC_FUNC_MMAP
1677AC_TYPE_SIGNAL
1678
bart26288e42011-04-03 16:46:01 +00001679AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001680AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001681
bartf5ceec82008-04-26 07:45:10 +00001682AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001683 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001684 epoll_create \
1685 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001686 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001687 mallinfo \
1688 memchr \
1689 memset \
1690 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001691 mremap \
bartf5ceec82008-04-26 07:45:10 +00001692 ppoll \
bart6d45e922009-01-20 13:45:38 +00001693 pthread_barrier_init \
1694 pthread_condattr_setclock \
1695 pthread_mutex_timedlock \
1696 pthread_rwlock_timedrdlock \
1697 pthread_rwlock_timedwrlock \
1698 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001699 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001700 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001701 semtimedop \
1702 signalfd \
njn6cc22472009-03-16 03:46:48 +00001703 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001704 strchr \
1705 strdup \
1706 strpbrk \
1707 strrchr \
1708 strstr \
barta72a27b2010-04-29 06:22:17 +00001709 syscall \
bartf5ceec82008-04-26 07:45:10 +00001710 utimensat \
1711 ])
sewardjde4a1d02002-03-22 01:27:54 +00001712
bart623eec32008-07-29 17:54:49 +00001713# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1714# libraries with any shared object and/or executable. This is NOT what we
1715# want for e.g. vgpreload_core-x86-linux.so
1716LIBS=""
sewardj80637752006-03-02 13:48:21 +00001717
bart6d45e922009-01-20 13:45:38 +00001718AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1719 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001720AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1721 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001722AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1723 [test x$ac_cv_func_pthread_spin_lock = xyes])
1724
njn7fd6d382009-01-22 21:56:32 +00001725
1726#----------------------------------------------------------------------------
1727# MPI checks
1728#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001729# Do we have a useable MPI setup on the primary and/or secondary targets?
1730# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001731# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001732# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001733# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001734MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001735
sewardje9fa5062006-03-12 18:29:18 +00001736mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001737if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001738 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1739 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001740 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001741elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001742 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1743 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001744 mflag_primary=$FLAG_M64
1745fi
1746
sewardj03d86f22006-10-17 00:57:24 +00001747mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001748if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1749 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001750 mflag_secondary=$FLAG_M32
sewardj03d86f22006-10-17 00:57:24 +00001751fi
1752
1753
sewardj0ad46092006-03-02 17:09:16 +00001754AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001755 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001756 MPI_CC=$withval
1757)
sewardj03d86f22006-10-17 00:57:24 +00001758AC_SUBST(MPI_CC)
1759
1760## See if MPI_CC works for the primary target
1761##
1762AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001763saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001764saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001765CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +00001766CFLAGS=$mflag_primary
sewardjd3fcc642006-03-09 02:49:56 +00001767AC_TRY_LINK([
sewardj1a85e602006-03-08 15:26:10 +00001768#include <mpi.h>
1769#include <stdio.h>
sewardjde4f3842006-03-09 02:41:41 +00001770],[
1771 int r = MPI_Init(NULL,NULL);
1772 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1773 return r;
1774], [
sewardj03d86f22006-10-17 00:57:24 +00001775ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001776AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001777], [
sewardj03d86f22006-10-17 00:57:24 +00001778ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001779AC_MSG_RESULT([no])
1780])
sewardj0ad46092006-03-02 17:09:16 +00001781CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001782CFLAGS=$saved_CFLAGS
sewardj03d86f22006-10-17 00:57:24 +00001783AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001784
sewardj03d86f22006-10-17 00:57:24 +00001785## See if MPI_CC works for the secondary target. Complication: what if
1786## there is no secondary target? We need this to then fail.
1787## Kludge this by making MPI_CC something which will surely fail in
1788## such a case.
1789##
1790AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1791saved_CC=$CC
1792saved_CFLAGS=$CFLAGS
njn7fd6d382009-01-22 21:56:32 +00001793if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001794 CC="$MPI_CC this will surely fail"
1795else
1796 CC=$MPI_CC
1797fi
1798CFLAGS=$mflag_secondary
1799AC_TRY_LINK([
1800#include <mpi.h>
1801#include <stdio.h>
1802],[
1803 int r = MPI_Init(NULL,NULL);
1804 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1805 return r;
1806], [
1807ac_have_mpi2_sec=yes
1808AC_MSG_RESULT([yes, $MPI_CC])
1809], [
1810ac_have_mpi2_sec=no
1811AC_MSG_RESULT([no])
1812])
1813CC=$saved_CC
1814CFLAGS=$saved_CFLAGS
1815AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001816
1817
njn7fd6d382009-01-22 21:56:32 +00001818#----------------------------------------------------------------------------
1819# Other library checks
1820#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00001821# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00001822# tests are present because Drd has some regression tests that use
1823# these packages. All regression test programs all compiled only
1824# for the primary target. And so it is important that the configure
1825# checks that follow, use the correct -m32 or -m64 flag for the
1826# primary target (called $mflag_primary). Otherwise, we can end up
1827# in a situation (eg) where, on amd64-linux, the test for Boost checks
1828# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1829# only build (meaning, the primary target is x86-linux), the build
1830# of the regtest programs that use Boost fails, because they are
1831# build as 32-bit (IN THIS EXAMPLE).
1832#
1833# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1834# NEEDED BY THE REGRESSION TEST PROGRAMS.
1835
1836
sewardj493c4ef2008-12-13 16:45:19 +00001837# Check whether the boost library 1.35 or later has been installed.
1838# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1839
1840AC_MSG_CHECKING([for boost])
1841
1842AC_LANG(C++)
1843safe_CXXFLAGS=$CXXFLAGS
1844CXXFLAGS="-lboost_thread-mt $mflag_primary"
1845
bart128fc522011-03-12 10:36:35 +00001846AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001847#include <boost/thread.hpp>
1848static void thread_func(void)
1849{ }
1850int main(int argc, char** argv)
1851{
1852 boost::thread t(thread_func);
1853 return 0;
1854}
bart128fc522011-03-12 10:36:35 +00001855])],
sewardj493c4ef2008-12-13 16:45:19 +00001856[
1857ac_have_boost_1_35=yes
1858AC_SUBST([BOOST_CFLAGS], [])
1859AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1860AC_MSG_RESULT([yes])
1861], [
1862ac_have_boost_1_35=no
1863AC_MSG_RESULT([no])
1864])
1865
1866CXXFLAGS=$safe_CXXFLAGS
1867AC_LANG(C)
1868
1869AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1870
1871
1872# does this compiler support -fopenmp, does it have the include file
1873# <omp.h> and does it have libgomp ?
1874
1875AC_MSG_CHECKING([for OpenMP])
1876
1877safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001878CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001879
bart128fc522011-03-12 10:36:35 +00001880AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001881#include <omp.h>
1882int main(int argc, char** argv)
1883{
1884 omp_set_dynamic(0);
1885 return 0;
1886}
bart128fc522011-03-12 10:36:35 +00001887])],
sewardj493c4ef2008-12-13 16:45:19 +00001888[
1889ac_have_openmp=yes
1890AC_MSG_RESULT([yes])
1891], [
1892ac_have_openmp=no
1893AC_MSG_RESULT([no])
1894])
1895CFLAGS=$safe_CFLAGS
1896
1897AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1898
1899
sewardjc876a2f2009-01-22 22:44:30 +00001900# does this compiler have built-in functions for atomic memory access ?
1901AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
1902
1903safe_CFLAGS=$CFLAGS
1904CFLAGS="$mflag_primary"
1905
1906AC_TRY_LINK(,
1907[
1908 int variable = 1;
1909 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1910 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1911],
1912[
bartc82d1372009-05-31 16:21:23 +00001913 ac_have_builtin_atomic=yes
sewardjc876a2f2009-01-22 22:44:30 +00001914 AC_MSG_RESULT([yes])
barte8740422011-03-24 20:27:54 +00001915 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
sewardjc876a2f2009-01-22 22:44:30 +00001916],
1917[
bartc82d1372009-05-31 16:21:23 +00001918 ac_have_builtin_atomic=no
sewardjc876a2f2009-01-22 22:44:30 +00001919 AC_MSG_RESULT([no])
1920])
1921
1922CFLAGS=$safe_CFLAGS
1923
bartc82d1372009-05-31 16:21:23 +00001924AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC], [test x$ac_have_builtin_atomic = xyes])
1925
barte8740422011-03-24 20:27:54 +00001926# does g++ have built-in functions for atomic memory access ?
1927AC_MSG_CHECKING([if g++ supports __sync_bool_compare_and_swap])
1928
1929safe_CXXFLAGS=$CXXFLAGS
1930CXXFLAGS="$mflag_primary"
1931
1932AC_LANG_PUSH(C++)
1933AC_TRY_LINK(,
1934[
1935 int variable = 1;
1936 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1937 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1938],
1939[
1940 ac_have_builtin_atomic_cxx=yes
1941 AC_MSG_RESULT([yes])
1942 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
1943],
1944[
1945 ac_have_builtin_atomic_cxx=no
1946 AC_MSG_RESULT([no])
1947])
1948AC_LANG_POP(C++)
1949
1950CXXFLAGS=$safe_CXXFLAGS
1951
1952AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00001953
njn7fd6d382009-01-22 21:56:32 +00001954#----------------------------------------------------------------------------
1955# Ok. We're done checking.
1956#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00001957
njn8b68b642009-06-24 00:37:09 +00001958# Nb: VEX/Makefile is generated from Makefile.vex.in.
1959AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00001960 Makefile
njn8b68b642009-06-24 00:37:09 +00001961 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00001962 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00001963 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00001964 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00001965 docs/Makefile
1966 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00001967 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00001968 perf/Makefile
1969 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00001970 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00001971 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00001972 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00001973 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00001974 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001975 memcheck/Makefile
1976 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00001977 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00001978 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00001979 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00001980 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00001981 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00001982 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00001983 memcheck/tests/ppc32/Makefile
1984 memcheck/tests/ppc64/Makefile
njn29a5c012009-05-06 06:15:55 +00001985 memcheck/perf/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001986 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001987 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00001988 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00001989 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00001990 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00001991 callgrind/Makefile
1992 callgrind/callgrind_annotate
1993 callgrind/callgrind_control
1994 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001995 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00001996 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00001997 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00001998 massif/tests/Makefile
njn734b8052007-11-01 04:40:37 +00001999 massif/perf/Makefile
njnd5a8d242007-11-02 20:44:57 +00002000 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002001 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002002 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002003 none/Makefile
2004 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002005 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002006 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002007 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002008 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002009 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002010 none/tests/s390x/Makefile
njn0458a122009-02-13 06:23:46 +00002011 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002012 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002013 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002014 exp-sgcheck/Makefile
2015 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002016 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002017 drd/scripts/download-and-build-splash2
2018 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002019 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002020 exp-bbv/tests/Makefile
2021 exp-bbv/tests/x86/Makefile
2022 exp-bbv/tests/x86-linux/Makefile
2023 exp-bbv/tests/amd64-linux/Makefile
2024 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002025 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002026 exp-dhat/Makefile
2027 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002028])
sewardjd3645802010-06-13 22:13:58 +00002029AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2030 [chmod +x coregrind/link_tool_exe_linux])
2031AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2032 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002033AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002034
2035cat<<EOF
2036
njn311303f2009-02-06 03:46:50 +00002037 Maximum build arch: ${ARCH_MAX}
2038 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002039 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002040 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002041 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2042 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002043 Platform variant: ${VGCONF_PLATVARIANT}
2044 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002045 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002046
gobry3b777892002-04-04 09:18:39 +00002047EOF