blob: d22871e4e67933d0570d0d87e52fd523ff443bca [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.
sewardj96e6aa62011-10-25 09:20:05 +000011AC_INIT([Valgrind],[3.8.0.SVN],[valgrind-users@lists.sourceforge.net])
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
bart417cf3e2011-10-22 09:21:24 +000013AC_CONFIG_HEADERS([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
bart85037442011-11-22 14:41:31 +0000101# Obtain the compiler version.
sewardja8ca2c52011-09-29 18:18:37 +0000102#
bart85037442011-11-22 14:41:31 +0000103# A few examples of how the ${CC} --version output looks like:
104#
105# Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
106# Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
107# openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
108# Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
bartc5214062012-01-11 11:34:23 +0000109# MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
bart85037442011-11-22 14:41:31 +0000110# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
111# OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
112# Clang: clang version 2.9 (tags/RELEASE_29/final)
sewardja8ca2c52011-09-29 18:18:37 +0000113#
bartc5214062012-01-11 11:34:23 +0000114[
115 gcc_version=`${CC} -dumpversion 2>/dev/null`
116 if test "x$gcc_version" = x; then
117 gcc_version=`${CC} --version \
118 | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p' \
119 -e 's/[^ ]*clang version \([0-9.]*\).*$/\1/p'`
120 fi
121]
gobrye721a522002-03-22 13:38:30 +0000122
sewardj3ab7b662011-09-29 17:30:13 +0000123is_clang="notclang"
124if test "x`${CC} --version | head -n 1 | $SED 's/\(clang\) version.*/\1/'`" = "xclang" ; then
125 is_clang="clang"
126fi
127
128case "${is_clang}-${gcc_version}" in
129 notclang-3.*)
130 AC_MSG_RESULT([ok (${gcc_version})])
131 ;;
132 notclang-4.*)
133 AC_MSG_RESULT([ok (${gcc_version})])
134 ;;
135 clang-2.9)
136 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000137 ;;
gobrye721a522002-03-22 13:38:30 +0000138 *)
sewardj3ab7b662011-09-29 17:30:13 +0000139 AC_MSG_RESULT([no (${gcc_version})])
140 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000141 ;;
142esac
143
njn7fd6d382009-01-22 21:56:32 +0000144#----------------------------------------------------------------------------
145# Arch/OS/platform tests.
146#----------------------------------------------------------------------------
147# We create a number of arch/OS/platform-related variables. We prefix them
148# all with "VGCONF_" which indicates that they are defined at
149# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
150# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000151
sewardjde4a1d02002-03-22 01:27:54 +0000152AC_CANONICAL_HOST
153
154AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000155
njn7fd6d382009-01-22 21:56:32 +0000156# ARCH_MAX reflects the most that this CPU can do: for example if it
157# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
158# Ditto for amd64. It is used for more configuration below, but is not used
159# outside this file.
gobrye721a522002-03-22 13:38:30 +0000160case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000161 i?86)
162 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000163 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000164 ;;
165
njnfe408942004-11-23 17:52:24 +0000166 x86_64)
167 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000168 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000169 ;;
170
sewardj2c48c7b2005-11-29 13:05:56 +0000171 powerpc64)
172 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000173 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000174 ;;
175
176 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000177 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000178 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000179 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000180 ;;
181
sewardjb5b87402011-03-07 16:05:35 +0000182 s390x)
183 AC_MSG_RESULT([ok (${host_cpu})])
184 ARCH_MAX="s390x"
185 ;;
186
sewardj59570ff2010-01-01 11:59:33 +0000187 armv7*)
188 AC_MSG_RESULT([ok (${host_cpu})])
189 ARCH_MAX="arm"
190 ;;
191
sewardjde4a1d02002-03-22 01:27:54 +0000192 *)
193 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000194 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000195 ;;
196esac
197
njn7fd6d382009-01-22 21:56:32 +0000198#----------------------------------------------------------------------------
199
sewardj86e992f2006-01-28 18:39:09 +0000200# Sometimes it's convenient to subvert the bi-arch build system and
201# just have a single build even though the underlying platform is
202# capable of both. Hence handle --enable-only64bit and
203# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000204# [Actually, if either of these options are used, I think both get built,
205# but only one gets installed. So if you use an in-place build, both can be
206# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000207
208# Check if a 64-bit only build has been requested
209AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
210 [AC_ARG_ENABLE(only64bit,
211 [ --enable-only64bit do a 64-bit only build],
212 [vg_cv_only64bit=$enableval],
213 [vg_cv_only64bit=no])])
214
215# Check if a 32-bit only build has been requested
216AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
217 [AC_ARG_ENABLE(only32bit,
218 [ --enable-only32bit do a 32-bit only build],
219 [vg_cv_only32bit=$enableval],
220 [vg_cv_only32bit=no])])
221
222# Stay sane
223if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
224 AC_MSG_ERROR(
225 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
226fi
227
njn7fd6d382009-01-22 21:56:32 +0000228#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000229
njn311303f2009-02-06 03:46:50 +0000230# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
231# compilation of many C files via -VGO_$(VGCONF_OS) and
232# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000233AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000234AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000235
njnf76d27a2009-05-28 01:53:07 +0000236DEFAULT_SUPP=""
237
gobrye721a522002-03-22 13:38:30 +0000238case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000239 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000240 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000241 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000242
243 # Ok, this is linux. Check the kernel version
244 AC_MSG_CHECKING([for the kernel version])
245
246 kernel=`uname -r`
247
248 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000249 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000250 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
251 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 +0000252 ;;
253
254 2.4.*)
255 AC_MSG_RESULT([2.4 family (${kernel})])
256 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
257 ;;
258
mueller8c68e042004-01-03 15:21:14 +0000259 *)
260 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000261 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000262 ;;
263 esac
264
265 ;;
266
njnf76d27a2009-05-28 01:53:07 +0000267 *darwin*)
268 AC_MSG_RESULT([ok (${host_os})])
269 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000270 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
271 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
272 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
njnf76d27a2009-05-28 01:53:07 +0000273
274 AC_MSG_CHECKING([for the kernel version])
275 kernel=`uname -r`
276
277 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
278 # has only one relevant version, the OS version. The `uname` check
279 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000280 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
281 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000282 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000283 #
284 # XXX: `uname -r` won't do the right thing for cross-compiles, but
285 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000286 #
287 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
288 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
289 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
290 # time support for 10.5 (the 9.* pattern just below), I'll leave it
291 # in for now, just in case anybody wants to give it a try. But I'm
292 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000293 case "${kernel}" in
294 9.*)
295 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000296 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000297 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000298 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000299 ;;
njnea2d6fd2010-07-01 00:20:20 +0000300 10.*)
301 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
302 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
303 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
304 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
305 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000306 11.*)
307 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
308 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
309 # FIXME: change these to xx11.supp
310 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
311 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
312 ;;
313 *)
njnf76d27a2009-05-28 01:53:07 +0000314 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000315 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000316 ;;
317 esac
318 ;;
319
sewardjde4a1d02002-03-22 01:27:54 +0000320 *)
321 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000322 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000323 ;;
324esac
325
njn7fd6d382009-01-22 21:56:32 +0000326#----------------------------------------------------------------------------
327
tomd6398392006-06-07 17:44:36 +0000328# If we are building on a 64 bit platform test to see if the system
329# supports building 32 bit programs and disable 32 bit support if it
330# does not support building 32 bit programs
331
njn7fd6d382009-01-22 21:56:32 +0000332case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000333 amd64-linux|ppc64-linux)
334 AC_MSG_CHECKING([for 32 bit build support])
335 safe_CFLAGS=$CFLAGS
336 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000337 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000338 return 0;
bart417cf3e2011-10-22 09:21:24 +0000339 ]])], [
tomd6398392006-06-07 17:44:36 +0000340 AC_MSG_RESULT([yes])
341 ], [
342 vg_cv_only64bit="yes"
343 AC_MSG_RESULT([no])
344 ])
345 CFLAGS=$safe_CFLAGS;;
346esac
347
348if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
349 AC_MSG_ERROR(
350 [--enable-only32bit was specified but system does not support 32 bit builds])
351fi
nethercote888ecb72004-08-23 14:54:40 +0000352
njn7fd6d382009-01-22 21:56:32 +0000353#----------------------------------------------------------------------------
354
njn311303f2009-02-06 03:46:50 +0000355# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
356# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
357# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
358# above) will be "amd64" since that reflects the most that this cpu can do,
359# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
360# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000361# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
362# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
363AC_SUBST(VGCONF_ARCH_PRI)
364
njn3f8a6e92009-06-02 00:20:47 +0000365# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
366# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
367# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
368# It is empty if there is no secondary target.
369AC_SUBST(VGCONF_ARCH_SEC)
370
njn311303f2009-02-06 03:46:50 +0000371# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
372# The entire system, including regression and performance tests, will be
373# built for this target. The "_CAPS" indicates that the name is in capital
374# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000375# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000376# convention and cannot contain '-' characters. This is in contrast to
377# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000378AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
379
380# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
381# Valgrind and tools will also be built for this target, but not the
382# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000383#
njn7fd6d382009-01-22 21:56:32 +0000384# By default, the primary arch is the same as the "max" arch, as commented
385# above (at the definition of ARCH_MAX). We may choose to downgrade it in
386# the big case statement just below here, in the case where we're building
387# on a 64 bit machine but have been requested only to do a 32 bit build.
388AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
389
sewardj01262142006-01-04 01:20:28 +0000390AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000391
njnea2d6fd2010-07-01 00:20:20 +0000392# NB. The load address for a given platform may be specified in more
393# than one place, in some cases, depending on whether we're doing a biarch,
394# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
395# Be careful to give consistent values in all subcases. Also, all four
396# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
397# even if it is to "0xUNSET".
398#
njn7fd6d382009-01-22 21:56:32 +0000399case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000400 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000401 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000402 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000403 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
404 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000405 valt_load_address_pri_norml="0x38000000"
406 valt_load_address_pri_inner="0x28000000"
407 valt_load_address_sec_norml="0xUNSET"
408 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000409 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000410 ;;
411 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000412 valt_load_address_sec_norml="0xUNSET"
413 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000414 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000415 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000416 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000417 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
418 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000419 valt_load_address_pri_norml="0x38000000"
420 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000421 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000422 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000423 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000424 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
425 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000426 valt_load_address_pri_norml="0x38000000"
427 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000428 else
njn7fd6d382009-01-22 21:56:32 +0000429 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000430 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000431 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
432 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000433 valt_load_address_pri_norml="0x38000000"
434 valt_load_address_pri_inner="0x28000000"
435 valt_load_address_sec_norml="0x38000000"
436 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000437 fi
njn377c43f2009-05-19 07:39:22 +0000438 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000439 ;;
440 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000441 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000442 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000443 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
444 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000445 valt_load_address_pri_norml="0x38000000"
446 valt_load_address_pri_inner="0x28000000"
447 valt_load_address_sec_norml="0xUNSET"
448 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000449 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000450 ;;
451 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000452 valt_load_address_sec_norml="0xUNSET"
453 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000454 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000455 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000456 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000457 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
458 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000459 valt_load_address_pri_norml="0x38000000"
460 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000461 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000462 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000463 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000464 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
465 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000466 valt_load_address_pri_norml="0x38000000"
467 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000468 else
njn7fd6d382009-01-22 21:56:32 +0000469 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000470 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000471 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
472 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000473 valt_load_address_pri_norml="0x38000000"
474 valt_load_address_pri_inner="0x28000000"
475 valt_load_address_sec_norml="0x38000000"
476 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000477 fi
njn377c43f2009-05-19 07:39:22 +0000478 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000479 ;;
njncc58cea2010-07-05 07:21:22 +0000480 # Darwin gets identified as 32-bit even when it supports 64-bit.
481 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
482 # all Macs support both 32-bit and 64-bit, so we just build both. If
483 # someone has a really old 32-bit only machine they can (hopefully?)
484 # build with --enable-only32bit. See bug 243362.
485 x86-darwin|amd64-darwin)
486 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000487 valt_load_address_sec_norml="0xUNSET"
488 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000489 if test x$vg_cv_only64bit = xyes; then
490 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000491 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000492 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
493 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000494 valt_load_address_pri_norml="0x138000000"
495 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000496 elif test x$vg_cv_only32bit = xyes; then
497 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000498 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000499 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
500 VGCONF_PLATFORM_SEC_CAPS=""
501 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000502 valt_load_address_pri_norml="0x38000000"
503 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000504 else
505 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000506 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000507 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
508 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000509 valt_load_address_pri_norml="0x138000000"
510 valt_load_address_pri_inner="0x128000000"
511 valt_load_address_sec_norml="0x38000000"
512 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000513 fi
njnf76d27a2009-05-28 01:53:07 +0000514 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
515 ;;
sewardj59570ff2010-01-01 11:59:33 +0000516 arm-linux)
517 VGCONF_ARCH_PRI="arm"
518 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
519 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000520 valt_load_address_pri_norml="0x38000000"
521 valt_load_address_pri_inner="0x28000000"
522 valt_load_address_sec_norml="0xUNSET"
523 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000524 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
525 ;;
sewardjb5b87402011-03-07 16:05:35 +0000526 s390x-linux)
527 VGCONF_ARCH_PRI="s390x"
528 VGCONF_ARCH_SEC=""
529 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
530 VGCONF_PLATFORM_SEC_CAPS=""
531 # we want to have the generated code close to the dispatcher
532 valt_load_address_pri_norml="0x401000000"
533 valt_load_address_pri_inner="0x410000000"
534 valt_load_address_sec_norml="0xUNSET"
535 valt_load_address_sec_inner="0xUNSET"
536 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
537 ;;
nethercote888ecb72004-08-23 14:54:40 +0000538 *)
njn7fd6d382009-01-22 21:56:32 +0000539 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000540 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000541 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
542 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000543 valt_load_address_pri_norml="0xUNSET"
544 valt_load_address_pri_inner="0xUNSET"
545 valt_load_address_sec_norml="0xUNSET"
546 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000547 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000548 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000549 ;;
550esac
sewardjde4a1d02002-03-22 01:27:54 +0000551
njn7fd6d382009-01-22 21:56:32 +0000552#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000553
njn7fd6d382009-01-22 21:56:32 +0000554# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
555# defined.
556AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
557 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000558 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
559 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
560 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000561AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000562 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
563 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000564AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
565 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000566 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000567AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000568 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000569AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
570 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000571AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
572 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000573
njn7fd6d382009-01-22 21:56:32 +0000574# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
575# become defined.
576AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
577 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
578 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
579AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
580 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
581AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
582 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
583 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
584AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
585 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000586AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
587 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000588AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
589 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
590 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000591
njnf76d27a2009-05-28 01:53:07 +0000592AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
593 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
594 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
595AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
596 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
597
598
sewardj72a2d802010-07-29 05:24:20 +0000599# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000600# Relies on the assumption that the primary and secondary targets are
601# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000602AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
603 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
604 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
605 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000606 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000607 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
608 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000609AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
610 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
611 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000612
613
njn7fd6d382009-01-22 21:56:32 +0000614# Sometimes, in the Makefile.am files, it's useful to know whether or not
615# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000616AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000617 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000618
tomb637bad2005-11-08 12:28:35 +0000619
njn7fd6d382009-01-22 21:56:32 +0000620#----------------------------------------------------------------------------
621# Inner Valgrind?
622#----------------------------------------------------------------------------
623
njnd74b0ef2009-01-20 06:06:52 +0000624# Check if this should be built as an inner Valgrind, to be run within
625# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000626AC_SUBST(VALT_LOAD_ADDRESS_PRI)
627AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000628AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
629 [AC_ARG_ENABLE(inner,
630 [ --enable-inner enables self-hosting],
631 [vg_cv_inner=$enableval],
632 [vg_cv_inner=no])])
633if test "$vg_cv_inner" = yes; then
634 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000635 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
636 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000637else
njnea2d6fd2010-07-01 00:20:20 +0000638 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
639 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000640fi
641
642
njn7fd6d382009-01-22 21:56:32 +0000643#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000644# Extra fine-tuning of installation directories
645#----------------------------------------------------------------------------
646AC_ARG_WITH(tmpdir,
647 [ --with-tmpdir=PATH Specify path for temporary files],
648 tmpdir="$withval",
649 tmpdir="/tmp")
650AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
651
sewardj0ba37c92011-07-12 11:46:24 +0000652
sewardjcb495c82011-07-11 20:42:34 +0000653#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000654# Libc and suppressions
655#----------------------------------------------------------------------------
656# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000657AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000658
bart12e91122010-05-15 08:37:24 +0000659AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000660
bart12e91122010-05-15 08:37:24 +0000661if test x$ac_cv_header_features_h = xyes; then
662 rm -f conftest.$ac_ext
663 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000664#include <features.h>
bart12e91122010-05-15 08:37:24 +0000665#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
666glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000667#endif
bart12e91122010-05-15 08:37:24 +0000668_ACEOF
669 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
670fi
bartb7c3f082010-05-13 06:32:36 +0000671
njnf76d27a2009-05-28 01:53:07 +0000672# not really a version check
673AC_EGREP_CPP([DARWIN_LIBC], [
674#include <sys/cdefs.h>
675#if defined(__DARWIN_VERS_1050)
676 DARWIN_LIBC
677#endif
678],
679GLIBC_VERSION="darwin")
680
sewardjcb495c82011-07-11 20:42:34 +0000681# not really a version check
682AC_EGREP_CPP([BIONIC_LIBC], [
683#if defined(__ANDROID__)
684 BIONIC_LIBC
685#endif
686],
687GLIBC_VERSION="bionic")
688
689
dirk07596a22008-04-25 11:33:30 +0000690AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000691
dirk07596a22008-04-25 11:33:30 +0000692case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000693 2.2)
694 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000695 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000696 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
697 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000698 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000699 ;;
700
sewardj08c7f012002-10-07 23:56:55 +0000701 2.3)
702 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000703 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000704 DEFAULT_SUPP="glibc-2.3.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}"
sewardj08c7f012002-10-07 23:56:55 +0000707 ;;
708
njn781dba52005-06-30 04:06:38 +0000709 2.4)
710 AC_MSG_RESULT(2.4 family)
711 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000712 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000713 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000714 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000715 ;;
716
dirkaece45c2006-10-12 08:17:49 +0000717 2.5)
718 AC_MSG_RESULT(2.5 family)
719 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000720 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000721 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000722 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000723 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000724 2.6)
725 AC_MSG_RESULT(2.6 family)
726 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000727 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000728 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000729 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000730 ;;
731 2.7)
732 AC_MSG_RESULT(2.7 family)
733 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000734 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000735 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000736 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000737 ;;
dirk07596a22008-04-25 11:33:30 +0000738 2.8)
739 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000740 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000741 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
742 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
743 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
744 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000745 2.9)
746 AC_MSG_RESULT(2.9 family)
747 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
748 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
749 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
750 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
751 ;;
sewardj5d425e82009-02-01 19:01:11 +0000752 2.10)
753 AC_MSG_RESULT(2.10 family)
754 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
755 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
756 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
757 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
758 ;;
bart0fac7ff2009-11-15 19:11:19 +0000759 2.11)
760 AC_MSG_RESULT(2.11 family)
761 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
762 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
763 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
764 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000765 ;;
766 2.12)
767 AC_MSG_RESULT(2.12 family)
768 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
769 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
770 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
771 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000772 ;;
tomebd619b2011-02-10 09:09:09 +0000773 2.13)
774 AC_MSG_RESULT(2.13 family)
775 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
776 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
777 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
778 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
779 ;;
tomcc077412011-06-07 21:52:26 +0000780 2.14)
781 AC_MSG_RESULT(2.14 family)
782 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
783 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
784 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
785 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
786 ;;
dirke75fdeb2011-12-29 08:24:55 +0000787 2.15)
788 AC_MSG_RESULT(2.15 family)
789 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
790 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
791 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
792 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
793 ;;
njnf76d27a2009-05-28 01:53:07 +0000794 darwin)
795 AC_MSG_RESULT(Darwin)
796 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
797 # DEFAULT_SUPP set by kernel version check above.
798 ;;
sewardjcb495c82011-07-11 20:42:34 +0000799 bionic)
800 AC_MSG_RESULT(Bionic)
801 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
802 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
803 ;;
dirkaece45c2006-10-12 08:17:49 +0000804
sewardjde4a1d02002-03-22 01:27:54 +0000805 *)
bart12e91122010-05-15 08:37:24 +0000806 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
dirke75fdeb2011-12-29 08:24:55 +0000807 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.15])
njnf76d27a2009-05-28 01:53:07 +0000808 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000809 ;;
810esac
811
dirk07596a22008-04-25 11:33:30 +0000812AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000813
sewardj414f3582008-07-18 20:46:00 +0000814
815# Add default suppressions for the X client libraries. Make no
816# attempt to detect whether such libraries are installed on the
817# build machine (or even if any X facilities are present); just
818# add the suppressions antidisirregardless.
819DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
820DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000821
sewardjd2f95a02011-05-11 16:04:28 +0000822# Add glibc and X11 suppressions for exp-sgcheck
823DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000824
sewardj2e10a682003-04-07 19:36:41 +0000825
njn7fd6d382009-01-22 21:56:32 +0000826#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000827# Platform variants?
828#----------------------------------------------------------------------------
829
830# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
831# But there are times where we need a bit more control. The motivating
832# and currently only case is Android: this is almost identical to arm-linux,
833# but not quite. So this introduces the concept of platform variant tags,
834# which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
835# with the main -DVGP_<arch>_<os> definition.
836#
837# In almost all cases, the <variant> bit is "vanilla". But for Android
838# it is "android" instead.
839#
840# Consequently (eg), plain arm-linux would build with
841#
842# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
843#
844# whilst an Android build would have
845#
846# -DVGP_arm_linux -DVGPV_arm_linux_android
847#
848# The setup of the platform variant is pushed relatively far down this
849# file in order that we can inspect any of the variables set above.
850
851# In the normal case ..
852VGCONF_PLATVARIANT="vanilla"
853
854# Android on ARM ?
855if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
856 -a "$GLIBC_VERSION" = "bionic";
857then
858 VGCONF_PLATVARIANT="android"
859fi
860
861AC_SUBST(VGCONF_PLATVARIANT)
862
863
864# FIXME: do we also want to define automake variables
865# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
866# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
867# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
868# do that. Problem is that we can't do and-ing in Makefile.am's, but
869# that's what we'd need to do to use this, since what we'd want to write
870# is something like
871#
872# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
873#
sewardj0ba37c92011-07-12 11:46:24 +0000874# Hmm. Can't think of a nice clean solution to this.
875
876AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
877 test x$VGCONF_PLATVARIANT = xvanilla)
878AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
879 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000880
881
882#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000883# Checking for various library functions and other definitions
884#----------------------------------------------------------------------------
885
bart59e2f182008-04-28 16:22:53 +0000886# Check for CLOCK_MONOTONIC
887
888AC_MSG_CHECKING([for CLOCK_MONOTONIC])
889
bart417cf3e2011-10-22 09:21:24 +0000890AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +0000891#include <time.h>
bart417cf3e2011-10-22 09:21:24 +0000892]], [[
bart59e2f182008-04-28 16:22:53 +0000893 struct timespec t;
894 clock_gettime(CLOCK_MONOTONIC, &t);
895 return 0;
bart417cf3e2011-10-22 09:21:24 +0000896]])], [
bart59e2f182008-04-28 16:22:53 +0000897AC_MSG_RESULT([yes])
898AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
899 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
900], [
901AC_MSG_RESULT([no])
902])
903
bartfea06922008-05-03 09:12:15 +0000904
sewardj0c09bf02011-07-11 22:11:58 +0000905# Check for PTHREAD_RWLOCK_T
906
907AC_MSG_CHECKING([for pthread_rwlock_t])
908
bart417cf3e2011-10-22 09:21:24 +0000909AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +0000910#define _GNU_SOURCE
911#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000912]], [[
sewardj0c09bf02011-07-11 22:11:58 +0000913 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +0000914]])], [
sewardj0c09bf02011-07-11 22:11:58 +0000915AC_MSG_RESULT([yes])
916AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
917 [Define to 1 if you have the `pthread_rwlock_t' type.])
918], [
919AC_MSG_RESULT([no])
920])
921
922
bartfea06922008-05-03 09:12:15 +0000923# Check for PTHREAD_MUTEX_ADAPTIVE_NP
924
925AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
926
bart417cf3e2011-10-22 09:21:24 +0000927AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000928#define _GNU_SOURCE
929#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000930]], [[
bartfea06922008-05-03 09:12:15 +0000931 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000932]])], [
bartfea06922008-05-03 09:12:15 +0000933AC_MSG_RESULT([yes])
934AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
935 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
936], [
937AC_MSG_RESULT([no])
938])
939
940
941# Check for PTHREAD_MUTEX_ERRORCHECK_NP
942
943AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
944
bart417cf3e2011-10-22 09:21:24 +0000945AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000946#define _GNU_SOURCE
947#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000948]], [[
bartfea06922008-05-03 09:12:15 +0000949 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +0000950]])], [
bartfea06922008-05-03 09:12:15 +0000951AC_MSG_RESULT([yes])
952AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
953 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
954], [
955AC_MSG_RESULT([no])
956])
957
958
959# Check for PTHREAD_MUTEX_RECURSIVE_NP
960
961AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
962
bart417cf3e2011-10-22 09:21:24 +0000963AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000964#define _GNU_SOURCE
965#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000966]], [[
bartfea06922008-05-03 09:12:15 +0000967 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000968]])], [
bartfea06922008-05-03 09:12:15 +0000969AC_MSG_RESULT([yes])
970AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
971 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
972], [
973AC_MSG_RESULT([no])
974])
975
976
977# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
978
979AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
980
bart417cf3e2011-10-22 09:21:24 +0000981AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000982#define _GNU_SOURCE
983#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000984]], [[
bartfea06922008-05-03 09:12:15 +0000985 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
986 return 0;
bart417cf3e2011-10-22 09:21:24 +0000987]])], [
bartfea06922008-05-03 09:12:15 +0000988AC_MSG_RESULT([yes])
989AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
990 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
991], [
992AC_MSG_RESULT([no])
993])
994
995
bart5e389f12008-04-05 12:53:15 +0000996# Check whether pthread_mutex_t has a member called __m_kind.
997
bartb11355c2010-04-29 16:37:26 +0000998AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
999 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1000 1,
1001 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1002 ],
1003 [],
1004 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001005
1006
1007# Check whether pthread_mutex_t has a member called __data.__kind.
1008
bartb11355c2010-04-29 16:37:26 +00001009AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1010 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1011 1,
1012 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1013 ],
1014 [],
1015 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001016
1017
bart62c370e2008-05-12 18:50:51 +00001018# does this compiler support -maltivec and does it have the include file
1019# <altivec.h> ?
1020
1021AC_MSG_CHECKING([for Altivec])
1022
1023safe_CFLAGS=$CFLAGS
1024CFLAGS="-maltivec"
1025
bart417cf3e2011-10-22 09:21:24 +00001026AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001027#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001028]], [[
bart62c370e2008-05-12 18:50:51 +00001029 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001030]])], [
bart62c370e2008-05-12 18:50:51 +00001031ac_have_altivec=yes
1032AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001033AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001034 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001035], [
1036ac_have_altivec=no
1037AC_MSG_RESULT([no])
1038])
1039CFLAGS=$safe_CFLAGS
1040
sewardj0e342a02010-09-03 23:49:33 +00001041AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001042
1043
sewardjf34eb492011-04-15 11:57:05 +00001044# Check that both: the compiler supports -mvsx and that the assembler
1045# understands VSX instructions. If either of those doesn't work,
1046# conclude that we can't do VSX. NOTE: basically this is a kludge
1047# in that it conflates two things that should be separate -- whether
1048# the compiler understands the flag vs whether the assembler
1049# understands the opcodes. This really ought to be cleaned up
1050# and done properly, like it is for x86/x86_64.
1051
1052AC_MSG_CHECKING([for VSX])
1053
1054safe_CFLAGS=$CFLAGS
1055CFLAGS="-mvsx"
1056
bart417cf3e2011-10-22 09:21:24 +00001057AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001058#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001059]], [[
sewardjf34eb492011-04-15 11:57:05 +00001060 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001061 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001062]])], [
sewardjf34eb492011-04-15 11:57:05 +00001063ac_have_vsx=yes
1064AC_MSG_RESULT([yes])
1065], [
1066ac_have_vsx=no
1067AC_MSG_RESULT([no])
1068])
1069CFLAGS=$safe_CFLAGS
1070
1071AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1072
1073
bart36dd85a2009-04-26 07:11:48 +00001074# Check for pthread_create@GLIBC2.0
1075AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1076
bart16e1c5a2009-04-26 07:38:53 +00001077safe_CFLAGS=$CFLAGS
1078CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001079AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001080extern int pthread_create_glibc_2_0(void*, const void*,
1081 void *(*)(void*), void*);
1082__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001083]], [[
bart276ed3a2009-05-10 15:41:45 +00001084#ifdef __powerpc__
1085/*
1086 * Apparently on PowerPC linking this program succeeds and generates an
1087 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1088 */
1089#error This test does not work properly on PowerPC.
1090#else
bart16e1c5a2009-04-26 07:38:53 +00001091 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001092#endif
bart16e1c5a2009-04-26 07:38:53 +00001093 return 0;
bart417cf3e2011-10-22 09:21:24 +00001094]])], [
bart36dd85a2009-04-26 07:11:48 +00001095ac_have_pthread_create_glibc_2_0=yes
1096AC_MSG_RESULT([yes])
1097AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1098 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1099], [
1100ac_have_pthread_create_glibc_2_0=no
1101AC_MSG_RESULT([no])
1102])
bart16e1c5a2009-04-26 07:38:53 +00001103CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001104
1105AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001106 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001107
1108
barta50aa8a2008-04-27 06:06:57 +00001109# Check for eventfd_t, eventfd() and eventfd_read()
1110AC_MSG_CHECKING([for eventfd()])
1111
bart417cf3e2011-10-22 09:21:24 +00001112AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001113#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001114]], [[
barta50aa8a2008-04-27 06:06:57 +00001115 eventfd_t ev;
1116 int fd;
1117
1118 fd = eventfd(5, 0);
1119 eventfd_read(fd, &ev);
1120 return 0;
bart417cf3e2011-10-22 09:21:24 +00001121]])], [
barta50aa8a2008-04-27 06:06:57 +00001122AC_MSG_RESULT([yes])
1123AC_DEFINE([HAVE_EVENTFD], 1,
1124 [Define to 1 if you have the `eventfd' function.])
1125AC_DEFINE([HAVE_EVENTFD_READ], 1,
1126 [Define to 1 if you have the `eventfd_read' function.])
1127], [
1128AC_MSG_RESULT([no])
1129])
1130
1131
njn7fd6d382009-01-22 21:56:32 +00001132#----------------------------------------------------------------------------
1133# Checking for supported compiler flags.
1134#----------------------------------------------------------------------------
1135
sewardj535c50f2005-06-04 23:14:53 +00001136# does this compiler support -m32 ?
1137AC_MSG_CHECKING([if gcc accepts -m32])
1138
1139safe_CFLAGS=$CFLAGS
1140CFLAGS="-m32"
1141
bart417cf3e2011-10-22 09:21:24 +00001142AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001143 return 0;
bart417cf3e2011-10-22 09:21:24 +00001144]])], [
sewardj535c50f2005-06-04 23:14:53 +00001145FLAG_M32="-m32"
1146AC_MSG_RESULT([yes])
1147], [
1148FLAG_M32=""
1149AC_MSG_RESULT([no])
1150])
1151CFLAGS=$safe_CFLAGS
1152
1153AC_SUBST(FLAG_M32)
1154
1155
sewardj01262142006-01-04 01:20:28 +00001156# does this compiler support -m64 ?
1157AC_MSG_CHECKING([if gcc accepts -m64])
1158
1159safe_CFLAGS=$CFLAGS
1160CFLAGS="-m64"
1161
bart417cf3e2011-10-22 09:21:24 +00001162AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001163 return 0;
bart417cf3e2011-10-22 09:21:24 +00001164]])], [
sewardj01262142006-01-04 01:20:28 +00001165FLAG_M64="-m64"
1166AC_MSG_RESULT([yes])
1167], [
1168FLAG_M64=""
1169AC_MSG_RESULT([no])
1170])
1171CFLAGS=$safe_CFLAGS
1172
1173AC_SUBST(FLAG_M64)
1174
1175
sewardj67f1fcc2005-07-03 10:41:02 +00001176# does this compiler support -mmmx ?
1177AC_MSG_CHECKING([if gcc accepts -mmmx])
1178
1179safe_CFLAGS=$CFLAGS
1180CFLAGS="-mmmx"
1181
bart417cf3e2011-10-22 09:21:24 +00001182AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001183 return 0;
bart417cf3e2011-10-22 09:21:24 +00001184]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001185FLAG_MMMX="-mmmx"
1186AC_MSG_RESULT([yes])
1187], [
1188FLAG_MMMX=""
1189AC_MSG_RESULT([no])
1190])
1191CFLAGS=$safe_CFLAGS
1192
1193AC_SUBST(FLAG_MMMX)
1194
1195
1196# does this compiler support -msse ?
1197AC_MSG_CHECKING([if gcc accepts -msse])
1198
1199safe_CFLAGS=$CFLAGS
1200CFLAGS="-msse"
1201
bart417cf3e2011-10-22 09:21:24 +00001202AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001203 return 0;
bart417cf3e2011-10-22 09:21:24 +00001204]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001205FLAG_MSSE="-msse"
1206AC_MSG_RESULT([yes])
1207], [
1208FLAG_MSSE=""
1209AC_MSG_RESULT([no])
1210])
1211CFLAGS=$safe_CFLAGS
1212
1213AC_SUBST(FLAG_MSSE)
1214
1215
sewardj5b754b42002-06-03 22:53:35 +00001216# does this compiler support -mpreferred-stack-boundary=2 ?
1217AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1218
daywalker3664f562003-10-17 13:43:46 +00001219safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001220CFLAGS="-mpreferred-stack-boundary=2"
1221
bart417cf3e2011-10-22 09:21:24 +00001222AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001223 return 0;
bart417cf3e2011-10-22 09:21:24 +00001224]])], [
sewardj5b754b42002-06-03 22:53:35 +00001225PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001226AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001227], [
1228PREFERRED_STACK_BOUNDARY=""
1229AC_MSG_RESULT([no])
1230])
daywalker3664f562003-10-17 13:43:46 +00001231CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001232
1233AC_SUBST(PREFERRED_STACK_BOUNDARY)
1234
sewardj535c50f2005-06-04 23:14:53 +00001235
sewardjb5f6f512005-03-10 23:59:00 +00001236# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001237AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001238
1239safe_CFLAGS=$CFLAGS
1240CFLAGS="-Wno-pointer-sign"
1241
bart417cf3e2011-10-22 09:21:24 +00001242AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001243 return 0;
bart417cf3e2011-10-22 09:21:24 +00001244]])], [
sewardjb5f6f512005-03-10 23:59:00 +00001245no_pointer_sign=yes
1246AC_MSG_RESULT([yes])
1247], [
1248no_pointer_sign=no
1249AC_MSG_RESULT([no])
1250])
1251CFLAGS=$safe_CFLAGS
1252
1253if test x$no_pointer_sign = xyes; then
1254 CFLAGS="$CFLAGS -Wno-pointer-sign"
1255fi
1256
sewardj535c50f2005-06-04 23:14:53 +00001257
barte026bd22009-07-04 12:17:07 +00001258# does this compiler support -Wno-empty-body ?
1259
1260AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1261
1262safe_CFLAGS=$CFLAGS
1263CFLAGS="-Wno-empty-body"
1264
bart417cf3e2011-10-22 09:21:24 +00001265AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001266 return 0;
bart417cf3e2011-10-22 09:21:24 +00001267]])], [
barte026bd22009-07-04 12:17:07 +00001268AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1269AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001270], [
barte026bd22009-07-04 12:17:07 +00001271AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1272AC_MSG_RESULT([no])
1273])
1274CFLAGS=$safe_CFLAGS
1275
1276
bart9d865fa2008-06-23 12:11:49 +00001277# does this compiler support -Wno-format-zero-length ?
1278
1279AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1280
1281safe_CFLAGS=$CFLAGS
1282CFLAGS="-Wno-format-zero-length"
1283
bart417cf3e2011-10-22 09:21:24 +00001284AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001285 return 0;
bart417cf3e2011-10-22 09:21:24 +00001286]])], [
bart9d865fa2008-06-23 12:11:49 +00001287AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1288AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001289], [
bart9d865fa2008-06-23 12:11:49 +00001290AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1291AC_MSG_RESULT([no])
1292])
1293CFLAGS=$safe_CFLAGS
1294
1295
bart8e216312011-05-15 17:05:36 +00001296# does this compiler support -Wno-nonnull ?
1297
1298AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1299
1300safe_CFLAGS=$CFLAGS
1301CFLAGS="-Wno-nonnull"
1302
bart417cf3e2011-10-22 09:21:24 +00001303AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001304 return 0;
bart417cf3e2011-10-22 09:21:24 +00001305]])], [
bart8e216312011-05-15 17:05:36 +00001306AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1307AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001308], [
bart8e216312011-05-15 17:05:36 +00001309AC_SUBST([FLAG_W_NO_NONNULL], [])
1310AC_MSG_RESULT([no])
1311])
1312CFLAGS=$safe_CFLAGS
1313
1314
1315# does this compiler support -Wno-overflow ?
1316
1317AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1318
1319safe_CFLAGS=$CFLAGS
1320CFLAGS="-Wno-overflow"
1321
bart417cf3e2011-10-22 09:21:24 +00001322AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001323 return 0;
bart417cf3e2011-10-22 09:21:24 +00001324]])], [
bart8e216312011-05-15 17:05:36 +00001325AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1326AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001327], [
bart8e216312011-05-15 17:05:36 +00001328AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1329AC_MSG_RESULT([no])
1330])
1331CFLAGS=$safe_CFLAGS
1332
1333
bartbf9b85c2009-08-12 12:55:56 +00001334# does this compiler support -Wno-uninitialized ?
1335
1336AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1337
1338safe_CFLAGS=$CFLAGS
1339CFLAGS="-Wno-uninitialized"
1340
bart417cf3e2011-10-22 09:21:24 +00001341AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001342 return 0;
bart417cf3e2011-10-22 09:21:24 +00001343]])], [
bartbf9b85c2009-08-12 12:55:56 +00001344AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1345AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001346], [
bartbf9b85c2009-08-12 12:55:56 +00001347AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1348AC_MSG_RESULT([no])
1349])
1350CFLAGS=$safe_CFLAGS
1351
1352
bart56730cd2008-05-11 06:41:46 +00001353# does this compiler support -Wextra or the older -W ?
1354
1355AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1356
1357safe_CFLAGS=$CFLAGS
1358CFLAGS="-Wextra"
1359
bart417cf3e2011-10-22 09:21:24 +00001360AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001361 return 0;
bart417cf3e2011-10-22 09:21:24 +00001362]])], [
bart56730cd2008-05-11 06:41:46 +00001363AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1364AC_MSG_RESULT([-Wextra])
1365], [
1366 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001367 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001368 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001369 ]])], [
bart56730cd2008-05-11 06:41:46 +00001370 AC_SUBST([FLAG_W_EXTRA], [-W])
1371 AC_MSG_RESULT([-W])
1372 ], [
1373 AC_SUBST([FLAG_W_EXTRA], [])
1374 AC_MSG_RESULT([not supported])
1375 ])
1376])
1377CFLAGS=$safe_CFLAGS
1378
1379
sewardja72c26d2007-05-01 13:44:08 +00001380# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001381AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001382
1383safe_CFLAGS=$CFLAGS
1384CFLAGS="-fno-stack-protector"
1385
bart417cf3e2011-10-22 09:21:24 +00001386AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001387 return 0;
bart417cf3e2011-10-22 09:21:24 +00001388]])], [
sewardja72c26d2007-05-01 13:44:08 +00001389no_stack_protector=yes
1390FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1391AC_MSG_RESULT([yes])
1392], [
1393no_stack_protector=no
1394FLAG_FNO_STACK_PROTECTOR=""
1395AC_MSG_RESULT([no])
1396])
1397CFLAGS=$safe_CFLAGS
1398
1399AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1400
1401if test x$no_stack_protector = xyes; then
1402 CFLAGS="$CFLAGS -fno-stack-protector"
1403fi
1404
1405
bart56730cd2008-05-11 06:41:46 +00001406# does this compiler support --param inline-unit-growth=... ?
1407
1408AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1409
1410safe_CFLAGS=$CFLAGS
1411CFLAGS="--param inline-unit-growth=900"
1412
bart417cf3e2011-10-22 09:21:24 +00001413AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001414 return 0;
bart417cf3e2011-10-22 09:21:24 +00001415]])], [
bart56730cd2008-05-11 06:41:46 +00001416AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1417 ["--param inline-unit-growth=900"])
1418AC_MSG_RESULT([yes])
1419], [
1420AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1421AC_MSG_RESULT([no])
1422])
1423CFLAGS=$safe_CFLAGS
1424
1425
sewardjd3645802010-06-13 22:13:58 +00001426# does the linker support -Wl,--build-id=none ? Note, it's
1427# important that we test indirectly via whichever C compiler
1428# is selected, rather than testing /usr/bin/ld or whatever
1429# directly.
bart699fbac2010-06-08 18:23:59 +00001430
sewardjd3645802010-06-13 22:13:58 +00001431AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001432
1433safe_CFLAGS=$CFLAGS
1434CFLAGS="-Wl,--build-id=none"
1435
bart8508c752010-06-10 06:26:21 +00001436AC_LINK_IFELSE(
1437[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001438[
1439 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1440 AC_MSG_RESULT([yes])
1441], [
1442 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1443 AC_MSG_RESULT([no])
1444])
1445CFLAGS=$safe_CFLAGS
1446
1447
sewardj00f1e622006-03-12 16:47:10 +00001448# does the ppc assembler support "mtocrf" et al?
1449AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1450
bart417cf3e2011-10-22 09:21:24 +00001451AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001452__asm__ __volatile__("mtocrf 4,0");
1453__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001454]])], [
sewardj00f1e622006-03-12 16:47:10 +00001455ac_have_as_ppc_mftocrf=yes
1456AC_MSG_RESULT([yes])
1457], [
1458ac_have_as_ppc_mftocrf=no
1459AC_MSG_RESULT([no])
1460])
1461if test x$ac_have_as_ppc_mftocrf = xyes ; then
1462 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1463fi
1464
1465
sewardjb5b87402011-03-07 16:05:35 +00001466CFLAGS=$safe_CFLAGS
1467
sewardjf0aabf82007-03-22 00:24:21 +00001468# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001469# Note, this doesn't generate a C-level symbol. It generates a
1470# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001471AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1472
bart417cf3e2011-10-22 09:21:24 +00001473AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001474 do { long long int x;
1475 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1476 while (0)
bart417cf3e2011-10-22 09:21:24 +00001477]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001478ac_have_as_sse3=yes
1479AC_MSG_RESULT([yes])
1480], [
1481ac_have_as_sse3=no
1482AC_MSG_RESULT([no])
1483])
sewardjfa18a262007-03-22 12:13:13 +00001484
1485AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001486
1487
sewardj6d6da5b2008-02-09 12:07:40 +00001488# Ditto for SSSE3 instructions (note extra S)
1489# Note, this doesn't generate a C-level symbol. It generates a
1490# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1491AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1492
florianc443b962011-10-28 21:37:19 +00001493save_CFLAGS="$CFLAGS"
1494CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001495AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001496 do { long long int x;
1497 __asm__ __volatile__(
1498 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1499 while (0)
bart417cf3e2011-10-22 09:21:24 +00001500]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001501ac_have_as_ssse3=yes
1502AC_MSG_RESULT([yes])
1503], [
1504ac_have_as_ssse3=no
1505AC_MSG_RESULT([no])
1506])
florianc443b962011-10-28 21:37:19 +00001507CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001508
1509AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1510
1511
sewardj27d176a2011-01-17 11:15:48 +00001512# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1513# Note, this doesn't generate a C-level symbol. It generates a
1514# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001515AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001516AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001517 do {
1518 __asm__ __volatile__(
1519 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1520 while (0)
bart417cf3e2011-10-22 09:21:24 +00001521]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001522ac_have_as_pclmulqdq=yes
1523AC_MSG_RESULT([yes])
1524], [
1525ac_have_as_pclmulqdq=no
1526AC_MSG_RESULT([no])
1527])
1528
1529AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1530
1531
sewardj27d176a2011-01-17 11:15:48 +00001532# does the x86/amd64 assembler understand the LZCNT instruction?
1533# Note, this doesn't generate a C-level symbol. It generates a
1534# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001535AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1536
bart417cf3e2011-10-22 09:21:24 +00001537AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00001538 do {
1539 __asm__ __volatile__("lzcnt %rax,%rax");
1540 } while (0)
bart417cf3e2011-10-22 09:21:24 +00001541]])], [
bart55e438b2010-09-14 10:53:57 +00001542 ac_have_as_lzcnt=yes
1543 AC_MSG_RESULT([yes])
1544], [
1545 ac_have_as_lzcnt=no
1546 AC_MSG_RESULT([no])
1547])
1548
1549AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1550
sewardj27d176a2011-01-17 11:15:48 +00001551
1552# does the x86/amd64 assembler understand SSE 4.2 instructions?
1553# Note, this doesn't generate a C-level symbol. It generates a
1554# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1555AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1556
bart417cf3e2011-10-22 09:21:24 +00001557AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00001558 do { long long int x;
1559 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00001560 "crc32q %%r15,%%r15" : : : "r15" );
1561 __asm__ __volatile__(
1562 "pblendvb (%rcx), %xmm11"); }
sewardj27d176a2011-01-17 11:15:48 +00001563 while (0)
bart417cf3e2011-10-22 09:21:24 +00001564]])], [
sewardj27d176a2011-01-17 11:15:48 +00001565ac_have_as_sse42=yes
1566AC_MSG_RESULT([yes])
1567], [
1568ac_have_as_sse42=no
1569AC_MSG_RESULT([no])
1570])
1571
1572AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1573
1574
sewardje089f012010-10-13 21:47:29 +00001575# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1576# when building the tool executables. I think we should get rid of it.
1577#
sewardjb5f6f512005-03-10 23:59:00 +00001578# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00001579AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1580 [[return foo;]])],
1581 [vg_cv_linktime_tls=yes],
1582 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00001583# Native compilation: check whether running a program using TLS succeeds.
1584# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1585# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00001586# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00001587AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1588 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1589 [vg_cv_tls=$enableval],
1590 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1591 [[return foo;]])],
1592 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00001593 [vg_cv_tls=no],
1594 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00001595
1596if test "$vg_cv_tls" = yes; then
1597AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1598fi
sewardj5b754b42002-06-03 22:53:35 +00001599
sewardj535c50f2005-06-04 23:14:53 +00001600
njn7fd6d382009-01-22 21:56:32 +00001601#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001602# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001603#----------------------------------------------------------------------------
1604
sewardjde4a1d02002-03-22 01:27:54 +00001605AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001606AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001607 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001608 endian.h \
1609 mqueue.h \
1610 sys/endian.h \
1611 sys/epoll.h \
1612 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001613 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001614 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001615 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001616 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001617 sys/syscall.h \
1618 sys/time.h \
1619 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001620 ])
sewardjde4a1d02002-03-22 01:27:54 +00001621
bart818f17e2011-09-17 06:24:49 +00001622# Verify whether the <linux/futex.h> header is usable.
1623AC_MSG_CHECKING([if <linux/futex.h> is usable])
1624
bart417cf3e2011-10-22 09:21:24 +00001625AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00001626#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00001627]], [[
bart818f17e2011-09-17 06:24:49 +00001628 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00001629]])], [
bart78bfc712011-12-08 16:14:59 +00001630ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00001631AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1632 [Define to 1 if you have a usable <linux/futex.h> header file.])
1633AC_MSG_RESULT([yes])
1634], [
bart78bfc712011-12-08 16:14:59 +00001635ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00001636AC_MSG_RESULT([no])
1637])
1638
njn7fd6d382009-01-22 21:56:32 +00001639#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001640# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001641#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001642AC_TYPE_UID_T
1643AC_TYPE_OFF_T
1644AC_TYPE_SIZE_T
1645AC_HEADER_TIME
1646
sewardj535c50f2005-06-04 23:14:53 +00001647
njn7fd6d382009-01-22 21:56:32 +00001648#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001649# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001650#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001651AC_FUNC_MEMCMP
1652AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00001653
bart26288e42011-04-03 16:46:01 +00001654AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001655AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001656
bartf5ceec82008-04-26 07:45:10 +00001657AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001658 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001659 epoll_create \
1660 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001661 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001662 mallinfo \
1663 memchr \
1664 memset \
1665 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001666 mremap \
bartf5ceec82008-04-26 07:45:10 +00001667 ppoll \
bart6d45e922009-01-20 13:45:38 +00001668 pthread_barrier_init \
1669 pthread_condattr_setclock \
1670 pthread_mutex_timedlock \
1671 pthread_rwlock_timedrdlock \
1672 pthread_rwlock_timedwrlock \
1673 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001674 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001675 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001676 semtimedop \
1677 signalfd \
njn6cc22472009-03-16 03:46:48 +00001678 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001679 strchr \
1680 strdup \
1681 strpbrk \
1682 strrchr \
1683 strstr \
barta72a27b2010-04-29 06:22:17 +00001684 syscall \
bartf5ceec82008-04-26 07:45:10 +00001685 utimensat \
tom9e4b6362012-02-10 09:39:37 +00001686 process_vm_readv \
1687 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00001688 ])
sewardjde4a1d02002-03-22 01:27:54 +00001689
bart623eec32008-07-29 17:54:49 +00001690# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1691# libraries with any shared object and/or executable. This is NOT what we
1692# want for e.g. vgpreload_core-x86-linux.so
1693LIBS=""
sewardj80637752006-03-02 13:48:21 +00001694
bart6d45e922009-01-20 13:45:38 +00001695AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1696 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001697AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1698 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001699AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1700 [test x$ac_cv_func_pthread_spin_lock = xyes])
1701
njn7fd6d382009-01-22 21:56:32 +00001702
1703#----------------------------------------------------------------------------
1704# MPI checks
1705#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001706# Do we have a useable MPI setup on the primary and/or secondary targets?
1707# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001708# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001709# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001710# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001711MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001712
sewardje9fa5062006-03-12 18:29:18 +00001713mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001714if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001715 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1716 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001717 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001718elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001719 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1720 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001721 mflag_primary=$FLAG_M64
1722fi
1723
sewardj03d86f22006-10-17 00:57:24 +00001724mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001725if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1726 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001727 mflag_secondary=$FLAG_M32
sewardj03d86f22006-10-17 00:57:24 +00001728fi
1729
1730
sewardj0ad46092006-03-02 17:09:16 +00001731AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001732 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001733 MPI_CC=$withval
1734)
sewardj03d86f22006-10-17 00:57:24 +00001735AC_SUBST(MPI_CC)
1736
1737## See if MPI_CC works for the primary target
1738##
1739AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001740saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001741saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001742CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +00001743CFLAGS=$mflag_primary
bart417cf3e2011-10-22 09:21:24 +00001744AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00001745#include <mpi.h>
1746#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001747]], [[
sewardjde4f3842006-03-09 02:41:41 +00001748 int r = MPI_Init(NULL,NULL);
1749 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1750 return r;
bart417cf3e2011-10-22 09:21:24 +00001751]])], [
sewardj03d86f22006-10-17 00:57:24 +00001752ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001753AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001754], [
sewardj03d86f22006-10-17 00:57:24 +00001755ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001756AC_MSG_RESULT([no])
1757])
sewardj0ad46092006-03-02 17:09:16 +00001758CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001759CFLAGS=$saved_CFLAGS
sewardj03d86f22006-10-17 00:57:24 +00001760AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001761
sewardj03d86f22006-10-17 00:57:24 +00001762## See if MPI_CC works for the secondary target. Complication: what if
1763## there is no secondary target? We need this to then fail.
1764## Kludge this by making MPI_CC something which will surely fail in
1765## such a case.
1766##
1767AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1768saved_CC=$CC
1769saved_CFLAGS=$CFLAGS
njn7fd6d382009-01-22 21:56:32 +00001770if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001771 CC="$MPI_CC this will surely fail"
1772else
1773 CC=$MPI_CC
1774fi
1775CFLAGS=$mflag_secondary
bart417cf3e2011-10-22 09:21:24 +00001776AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00001777#include <mpi.h>
1778#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001779]], [[
sewardj03d86f22006-10-17 00:57:24 +00001780 int r = MPI_Init(NULL,NULL);
1781 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1782 return r;
bart417cf3e2011-10-22 09:21:24 +00001783]])], [
sewardj03d86f22006-10-17 00:57:24 +00001784ac_have_mpi2_sec=yes
1785AC_MSG_RESULT([yes, $MPI_CC])
1786], [
1787ac_have_mpi2_sec=no
1788AC_MSG_RESULT([no])
1789])
1790CC=$saved_CC
1791CFLAGS=$saved_CFLAGS
1792AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001793
1794
njn7fd6d382009-01-22 21:56:32 +00001795#----------------------------------------------------------------------------
1796# Other library checks
1797#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00001798# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00001799# tests are present because Drd has some regression tests that use
1800# these packages. All regression test programs all compiled only
1801# for the primary target. And so it is important that the configure
1802# checks that follow, use the correct -m32 or -m64 flag for the
1803# primary target (called $mflag_primary). Otherwise, we can end up
1804# in a situation (eg) where, on amd64-linux, the test for Boost checks
1805# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1806# only build (meaning, the primary target is x86-linux), the build
1807# of the regtest programs that use Boost fails, because they are
1808# build as 32-bit (IN THIS EXAMPLE).
1809#
1810# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1811# NEEDED BY THE REGRESSION TEST PROGRAMS.
1812
1813
sewardj493c4ef2008-12-13 16:45:19 +00001814# Check whether the boost library 1.35 or later has been installed.
1815# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1816
1817AC_MSG_CHECKING([for boost])
1818
1819AC_LANG(C++)
1820safe_CXXFLAGS=$CXXFLAGS
1821CXXFLAGS="-lboost_thread-mt $mflag_primary"
1822
bart128fc522011-03-12 10:36:35 +00001823AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001824#include <boost/thread.hpp>
1825static void thread_func(void)
1826{ }
1827int main(int argc, char** argv)
1828{
1829 boost::thread t(thread_func);
1830 return 0;
1831}
bart128fc522011-03-12 10:36:35 +00001832])],
sewardj493c4ef2008-12-13 16:45:19 +00001833[
1834ac_have_boost_1_35=yes
1835AC_SUBST([BOOST_CFLAGS], [])
1836AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1837AC_MSG_RESULT([yes])
1838], [
1839ac_have_boost_1_35=no
1840AC_MSG_RESULT([no])
1841])
1842
1843CXXFLAGS=$safe_CXXFLAGS
1844AC_LANG(C)
1845
1846AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1847
1848
1849# does this compiler support -fopenmp, does it have the include file
1850# <omp.h> and does it have libgomp ?
1851
1852AC_MSG_CHECKING([for OpenMP])
1853
1854safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001855CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001856
bart128fc522011-03-12 10:36:35 +00001857AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001858#include <omp.h>
1859int main(int argc, char** argv)
1860{
1861 omp_set_dynamic(0);
1862 return 0;
1863}
bart128fc522011-03-12 10:36:35 +00001864])],
sewardj493c4ef2008-12-13 16:45:19 +00001865[
1866ac_have_openmp=yes
1867AC_MSG_RESULT([yes])
1868], [
1869ac_have_openmp=no
1870AC_MSG_RESULT([no])
1871])
1872CFLAGS=$safe_CFLAGS
1873
1874AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1875
1876
bart78bfc712011-12-08 16:14:59 +00001877# does this compiler have built-in functions for atomic memory access for the
1878# primary target ?
1879AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00001880
1881safe_CFLAGS=$CFLAGS
1882CFLAGS="$mflag_primary"
1883
bart417cf3e2011-10-22 09:21:24 +00001884AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00001885 int variable = 1;
1886 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1887 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001888]])], [
bartb4ff7822011-12-10 19:48:04 +00001889 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00001890 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00001891 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch() for the primary target])
bart417cf3e2011-10-22 09:21:24 +00001892], [
bartb4ff7822011-12-10 19:48:04 +00001893 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00001894 AC_MSG_RESULT([no])
1895])
1896
1897CFLAGS=$safe_CFLAGS
1898
bartb4ff7822011-12-10 19:48:04 +00001899AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
1900 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00001901
bart78bfc712011-12-08 16:14:59 +00001902
1903# does this compiler have built-in functions for atomic memory access for the
1904# secondary target ?
1905
1906if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1907
1908AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
1909
1910safe_CFLAGS=$CFLAGS
1911CFLAGS="$mflag_secondary"
1912
1913AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1914 int variable = 1;
1915 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
1916]])], [
1917 ac_have_builtin_atomic_secondary=yes
1918 AC_MSG_RESULT([yes])
1919], [
1920 ac_have_builtin_atomic_secondary=no
1921 AC_MSG_RESULT([no])
1922])
1923
1924CFLAGS=$safe_CFLAGS
1925
1926fi
1927
1928AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
1929 [test x$ac_have_builtin_atomic_secondary = xyes])
1930
bart1e856ea2011-12-17 12:53:23 +00001931# does this compiler have built-in functions for atomic memory access on
1932# 64-bit integers for all targets ?
1933
1934AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
1935
1936AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1937 #include <stdint.h>
1938]], [[
1939 uint64_t variable = 1;
1940 return __sync_add_and_fetch(&variable, 1)
1941]])], [
1942 ac_have_builtin_atomic64_primary=yes
1943], [
1944 ac_have_builtin_atomic64_primary=no
1945])
1946
1947if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1948
1949safe_CFLAGS=$CFLAGS
1950CFLAGS="$mflag_secondary"
1951
1952AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1953 #include <stdint.h>
1954]], [[
1955 uint64_t variable = 1;
1956 return __sync_add_and_fetch(&variable, 1)
1957]])], [
1958 ac_have_builtin_atomic64_secondary=yes
1959], [
1960 ac_have_builtin_atomic64_secondary=no
1961])
1962
1963CFLAGS=$safe_CFLAGS
1964
1965fi
1966
1967if test x$ac_have_builtin_atomic64_primary = xyes && \
1968 test x$VGCONF_PLATFORM_SEC_CAPS = x \
1969 -o x$ac_have_builtin_atomic64_secondary = xyes; then
1970 AC_MSG_RESULT([yes])
1971 ac_have_builtin_atomic64=yes
1972else
1973 AC_MSG_RESULT([no])
1974 ac_have_builtin_atomic64=no
1975fi
1976
1977AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
1978 [test x$ac_have_builtin_atomic64 = xyes])
1979
bart78bfc712011-12-08 16:14:59 +00001980
barte8740422011-03-24 20:27:54 +00001981# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00001982AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00001983
1984safe_CXXFLAGS=$CXXFLAGS
1985CXXFLAGS="$mflag_primary"
1986
1987AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00001988AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00001989 int variable = 1;
1990 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1991 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001992]])], [
barte8740422011-03-24 20:27:54 +00001993 ac_have_builtin_atomic_cxx=yes
1994 AC_MSG_RESULT([yes])
1995 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
bart417cf3e2011-10-22 09:21:24 +00001996], [
barte8740422011-03-24 20:27:54 +00001997 ac_have_builtin_atomic_cxx=no
1998 AC_MSG_RESULT([no])
1999])
2000AC_LANG_POP(C++)
2001
2002CXXFLAGS=$safe_CXXFLAGS
2003
2004AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002005
bart78bfc712011-12-08 16:14:59 +00002006
2007if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002008 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002009 ac_enable_linux_ticket_lock_primary=yes
2010fi
2011AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2012 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2013
2014if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2015 -a x$ac_have_usable_linux_futex_h = xyes \
2016 -a x$ac_have_builtin_atomic_secondary = xyes; then
2017 ac_enable_linux_ticket_lock_secondary=yes
2018fi
2019AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2020 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2021
2022
bartf68af882011-12-10 19:42:05 +00002023# does libstdc++ support annotating shared pointers ?
2024AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2025
2026safe_CXXFLAGS=$CFLAGS
2027CXXFLAGS="-std=c++0x"
2028
2029AC_LANG_PUSH(C++)
2030AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2031 #include <memory>
2032]], [[
2033 std::shared_ptr<int> p
2034]])], [
2035 ac_have_shared_ptr=yes
2036], [
2037 ac_have_shared_ptr=no
2038])
2039if test x$ac_have_shared_ptr = xyes; then
2040 # If compilation of the program below fails because of a syntax error
2041 # triggered by substituting one of the annotation macros then that
2042 # means that libstdc++ supports these macros.
2043 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2044 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2045 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2046 #include <memory>
2047 ]], [[
2048 std::shared_ptr<int> p
2049 ]])], [
2050 ac_have_shared_pointer_annotation=no
2051 AC_MSG_RESULT([no])
2052 ], [
2053 ac_have_shared_pointer_annotation=yes
2054 AC_MSG_RESULT([yes])
2055 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2056 [Define to 1 if libstd++ supports annotating shared pointers])
2057 ])
2058else
2059 ac_have_shared_pointer_annotation=no
2060 AC_MSG_RESULT([no])
2061fi
2062AC_LANG_POP(C++)
2063
2064CXXFLAGS=$safe_CXXFLAGS
2065
2066AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2067 [test x$ac_have_shared_pointer_annotation = xyes])
2068
2069
njn7fd6d382009-01-22 21:56:32 +00002070#----------------------------------------------------------------------------
2071# Ok. We're done checking.
2072#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002073
njn8b68b642009-06-24 00:37:09 +00002074# Nb: VEX/Makefile is generated from Makefile.vex.in.
2075AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002076 Makefile
njn8b68b642009-06-24 00:37:09 +00002077 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002078 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002079 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002080 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002081 docs/Makefile
2082 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002083 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002084 perf/Makefile
2085 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002086 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002087 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002088 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002089 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002090 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002091 memcheck/Makefile
2092 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002093 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002094 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002095 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002096 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002097 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002098 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002099 memcheck/tests/ppc32/Makefile
2100 memcheck/tests/ppc64/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002101 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002102 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002103 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002104 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002105 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002106 callgrind/Makefile
2107 callgrind/callgrind_annotate
2108 callgrind/callgrind_control
2109 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002110 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002111 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002112 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002113 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002114 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002115 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002116 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002117 none/Makefile
2118 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002119 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002120 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002121 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002122 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002123 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002124 none/tests/s390x/Makefile
njn0458a122009-02-13 06:23:46 +00002125 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002126 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002127 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002128 exp-sgcheck/Makefile
2129 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002130 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002131 drd/scripts/download-and-build-splash2
2132 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002133 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002134 exp-bbv/tests/Makefile
2135 exp-bbv/tests/x86/Makefile
2136 exp-bbv/tests/x86-linux/Makefile
2137 exp-bbv/tests/amd64-linux/Makefile
2138 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002139 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002140 exp-dhat/Makefile
2141 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002142])
sewardjd3645802010-06-13 22:13:58 +00002143AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2144 [chmod +x coregrind/link_tool_exe_linux])
2145AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2146 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002147AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002148
2149cat<<EOF
2150
njn311303f2009-02-06 03:46:50 +00002151 Maximum build arch: ${ARCH_MAX}
2152 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002153 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002154 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002155 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2156 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002157 Platform variant: ${VGCONF_PLATVARIANT}
2158 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002159 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002160
gobry3b777892002-04-04 09:18:39 +00002161EOF