blob: ab7572f3866e83b865e92aa3051e22359051ee43 [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
109# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
110# 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)
111# Clang: clang version 2.9 (tags/RELEASE_29/final)
sewardja8ca2c52011-09-29 18:18:37 +0000112#
113[gcc_version=`${CC} --version \
bart85037442011-11-22 14:41:31 +0000114 | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p' \
115 -e 's/[^ ]*clang version \([0-9.]*\).*$/\1/p'`]
gobrye721a522002-03-22 13:38:30 +0000116
sewardj3ab7b662011-09-29 17:30:13 +0000117is_clang="notclang"
118if test "x`${CC} --version | head -n 1 | $SED 's/\(clang\) version.*/\1/'`" = "xclang" ; then
119 is_clang="clang"
120fi
121
122case "${is_clang}-${gcc_version}" in
123 notclang-3.*)
124 AC_MSG_RESULT([ok (${gcc_version})])
125 ;;
126 notclang-4.*)
127 AC_MSG_RESULT([ok (${gcc_version})])
128 ;;
129 clang-2.9)
130 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000131 ;;
gobrye721a522002-03-22 13:38:30 +0000132 *)
sewardj3ab7b662011-09-29 17:30:13 +0000133 AC_MSG_RESULT([no (${gcc_version})])
134 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000135 ;;
136esac
137
njn7fd6d382009-01-22 21:56:32 +0000138#----------------------------------------------------------------------------
139# Arch/OS/platform tests.
140#----------------------------------------------------------------------------
141# We create a number of arch/OS/platform-related variables. We prefix them
142# all with "VGCONF_" which indicates that they are defined at
143# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
144# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000145
sewardjde4a1d02002-03-22 01:27:54 +0000146AC_CANONICAL_HOST
147
148AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000149
njn7fd6d382009-01-22 21:56:32 +0000150# ARCH_MAX reflects the most that this CPU can do: for example if it
151# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
152# Ditto for amd64. It is used for more configuration below, but is not used
153# outside this file.
gobrye721a522002-03-22 13:38:30 +0000154case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000155 i?86)
156 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000157 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000158 ;;
159
njnfe408942004-11-23 17:52:24 +0000160 x86_64)
161 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000162 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000163 ;;
164
sewardj2c48c7b2005-11-29 13:05:56 +0000165 powerpc64)
166 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000167 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000168 ;;
169
170 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000171 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000172 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000173 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000174 ;;
175
sewardjb5b87402011-03-07 16:05:35 +0000176 s390x)
177 AC_MSG_RESULT([ok (${host_cpu})])
178 ARCH_MAX="s390x"
179 ;;
180
sewardj59570ff2010-01-01 11:59:33 +0000181 armv7*)
182 AC_MSG_RESULT([ok (${host_cpu})])
183 ARCH_MAX="arm"
184 ;;
185
sewardjde4a1d02002-03-22 01:27:54 +0000186 *)
187 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000188 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000189 ;;
190esac
191
njn7fd6d382009-01-22 21:56:32 +0000192#----------------------------------------------------------------------------
193
sewardj86e992f2006-01-28 18:39:09 +0000194# Sometimes it's convenient to subvert the bi-arch build system and
195# just have a single build even though the underlying platform is
196# capable of both. Hence handle --enable-only64bit and
197# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000198# [Actually, if either of these options are used, I think both get built,
199# but only one gets installed. So if you use an in-place build, both can be
200# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000201
202# Check if a 64-bit only build has been requested
203AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
204 [AC_ARG_ENABLE(only64bit,
205 [ --enable-only64bit do a 64-bit only build],
206 [vg_cv_only64bit=$enableval],
207 [vg_cv_only64bit=no])])
208
209# Check if a 32-bit only build has been requested
210AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
211 [AC_ARG_ENABLE(only32bit,
212 [ --enable-only32bit do a 32-bit only build],
213 [vg_cv_only32bit=$enableval],
214 [vg_cv_only32bit=no])])
215
216# Stay sane
217if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
218 AC_MSG_ERROR(
219 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
220fi
221
njn7fd6d382009-01-22 21:56:32 +0000222#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000223
njn311303f2009-02-06 03:46:50 +0000224# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
225# compilation of many C files via -VGO_$(VGCONF_OS) and
226# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000227AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000228AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000229
njnf76d27a2009-05-28 01:53:07 +0000230DEFAULT_SUPP=""
231
gobrye721a522002-03-22 13:38:30 +0000232case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000233 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000234 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000235 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000236
237 # Ok, this is linux. Check the kernel version
238 AC_MSG_CHECKING([for the kernel version])
239
240 kernel=`uname -r`
241
242 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000243 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000244 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
245 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 +0000246 ;;
247
248 2.4.*)
249 AC_MSG_RESULT([2.4 family (${kernel})])
250 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
251 ;;
252
mueller8c68e042004-01-03 15:21:14 +0000253 *)
254 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000255 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000256 ;;
257 esac
258
259 ;;
260
njnf76d27a2009-05-28 01:53:07 +0000261 *darwin*)
262 AC_MSG_RESULT([ok (${host_os})])
263 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000264 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
265 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
266 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
njnf76d27a2009-05-28 01:53:07 +0000267
268 AC_MSG_CHECKING([for the kernel version])
269 kernel=`uname -r`
270
271 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
272 # has only one relevant version, the OS version. The `uname` check
273 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000274 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
275 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000276 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000277 #
278 # XXX: `uname -r` won't do the right thing for cross-compiles, but
279 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000280 #
281 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
282 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
283 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
284 # time support for 10.5 (the 9.* pattern just below), I'll leave it
285 # in for now, just in case anybody wants to give it a try. But I'm
286 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000287 case "${kernel}" in
288 9.*)
289 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000290 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000291 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000292 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000293 ;;
njnea2d6fd2010-07-01 00:20:20 +0000294 10.*)
295 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
296 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
297 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
298 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
299 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000300 11.*)
301 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
302 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
303 # FIXME: change these to xx11.supp
304 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
305 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
306 ;;
307 *)
njnf76d27a2009-05-28 01:53:07 +0000308 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000309 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000310 ;;
311 esac
312 ;;
313
sewardjde4a1d02002-03-22 01:27:54 +0000314 *)
315 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000316 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000317 ;;
318esac
319
njn7fd6d382009-01-22 21:56:32 +0000320#----------------------------------------------------------------------------
321
tomd6398392006-06-07 17:44:36 +0000322# If we are building on a 64 bit platform test to see if the system
323# supports building 32 bit programs and disable 32 bit support if it
324# does not support building 32 bit programs
325
njn7fd6d382009-01-22 21:56:32 +0000326case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000327 amd64-linux|ppc64-linux)
328 AC_MSG_CHECKING([for 32 bit build support])
329 safe_CFLAGS=$CFLAGS
330 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000331 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000332 return 0;
bart417cf3e2011-10-22 09:21:24 +0000333 ]])], [
tomd6398392006-06-07 17:44:36 +0000334 AC_MSG_RESULT([yes])
335 ], [
336 vg_cv_only64bit="yes"
337 AC_MSG_RESULT([no])
338 ])
339 CFLAGS=$safe_CFLAGS;;
340esac
341
342if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
343 AC_MSG_ERROR(
344 [--enable-only32bit was specified but system does not support 32 bit builds])
345fi
nethercote888ecb72004-08-23 14:54:40 +0000346
njn7fd6d382009-01-22 21:56:32 +0000347#----------------------------------------------------------------------------
348
njn311303f2009-02-06 03:46:50 +0000349# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
350# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
351# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
352# above) will be "amd64" since that reflects the most that this cpu can do,
353# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
354# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000355# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
356# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
357AC_SUBST(VGCONF_ARCH_PRI)
358
njn3f8a6e92009-06-02 00:20:47 +0000359# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
360# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
361# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
362# It is empty if there is no secondary target.
363AC_SUBST(VGCONF_ARCH_SEC)
364
njn311303f2009-02-06 03:46:50 +0000365# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
366# The entire system, including regression and performance tests, will be
367# built for this target. The "_CAPS" indicates that the name is in capital
368# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000369# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000370# convention and cannot contain '-' characters. This is in contrast to
371# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000372AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
373
374# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
375# Valgrind and tools will also be built for this target, but not the
376# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000377#
njn7fd6d382009-01-22 21:56:32 +0000378# By default, the primary arch is the same as the "max" arch, as commented
379# above (at the definition of ARCH_MAX). We may choose to downgrade it in
380# the big case statement just below here, in the case where we're building
381# on a 64 bit machine but have been requested only to do a 32 bit build.
382AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
383
sewardj01262142006-01-04 01:20:28 +0000384AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000385
njnea2d6fd2010-07-01 00:20:20 +0000386# NB. The load address for a given platform may be specified in more
387# than one place, in some cases, depending on whether we're doing a biarch,
388# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
389# Be careful to give consistent values in all subcases. Also, all four
390# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
391# even if it is to "0xUNSET".
392#
njn7fd6d382009-01-22 21:56:32 +0000393case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000394 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000395 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000396 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000397 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
398 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000399 valt_load_address_pri_norml="0x38000000"
400 valt_load_address_pri_inner="0x28000000"
401 valt_load_address_sec_norml="0xUNSET"
402 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000403 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000404 ;;
405 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000406 valt_load_address_sec_norml="0xUNSET"
407 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000408 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000409 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000410 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000411 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
412 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000413 valt_load_address_pri_norml="0x38000000"
414 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000415 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000416 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000417 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000418 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
419 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000420 valt_load_address_pri_norml="0x38000000"
421 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000422 else
njn7fd6d382009-01-22 21:56:32 +0000423 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000424 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000425 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
426 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000427 valt_load_address_pri_norml="0x38000000"
428 valt_load_address_pri_inner="0x28000000"
429 valt_load_address_sec_norml="0x38000000"
430 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000431 fi
njn377c43f2009-05-19 07:39:22 +0000432 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000433 ;;
434 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000435 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000436 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000437 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
438 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000439 valt_load_address_pri_norml="0x38000000"
440 valt_load_address_pri_inner="0x28000000"
441 valt_load_address_sec_norml="0xUNSET"
442 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000443 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000444 ;;
445 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000446 valt_load_address_sec_norml="0xUNSET"
447 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000448 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000449 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000450 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000451 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
452 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000453 valt_load_address_pri_norml="0x38000000"
454 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000455 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000456 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000457 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000458 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
459 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000460 valt_load_address_pri_norml="0x38000000"
461 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000462 else
njn7fd6d382009-01-22 21:56:32 +0000463 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000464 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000465 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
466 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000467 valt_load_address_pri_norml="0x38000000"
468 valt_load_address_pri_inner="0x28000000"
469 valt_load_address_sec_norml="0x38000000"
470 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000471 fi
njn377c43f2009-05-19 07:39:22 +0000472 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000473 ;;
njncc58cea2010-07-05 07:21:22 +0000474 # Darwin gets identified as 32-bit even when it supports 64-bit.
475 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
476 # all Macs support both 32-bit and 64-bit, so we just build both. If
477 # someone has a really old 32-bit only machine they can (hopefully?)
478 # build with --enable-only32bit. See bug 243362.
479 x86-darwin|amd64-darwin)
480 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000481 valt_load_address_sec_norml="0xUNSET"
482 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000483 if test x$vg_cv_only64bit = xyes; then
484 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000485 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000486 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
487 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000488 valt_load_address_pri_norml="0x138000000"
489 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000490 elif test x$vg_cv_only32bit = xyes; then
491 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000492 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000493 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
494 VGCONF_PLATFORM_SEC_CAPS=""
495 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000496 valt_load_address_pri_norml="0x38000000"
497 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000498 else
499 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000500 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000501 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
502 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000503 valt_load_address_pri_norml="0x138000000"
504 valt_load_address_pri_inner="0x128000000"
505 valt_load_address_sec_norml="0x38000000"
506 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000507 fi
njnf76d27a2009-05-28 01:53:07 +0000508 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
509 ;;
sewardj59570ff2010-01-01 11:59:33 +0000510 arm-linux)
511 VGCONF_ARCH_PRI="arm"
512 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
513 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000514 valt_load_address_pri_norml="0x38000000"
515 valt_load_address_pri_inner="0x28000000"
516 valt_load_address_sec_norml="0xUNSET"
517 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000518 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
519 ;;
sewardjb5b87402011-03-07 16:05:35 +0000520 s390x-linux)
521 VGCONF_ARCH_PRI="s390x"
522 VGCONF_ARCH_SEC=""
523 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
524 VGCONF_PLATFORM_SEC_CAPS=""
525 # we want to have the generated code close to the dispatcher
526 valt_load_address_pri_norml="0x401000000"
527 valt_load_address_pri_inner="0x410000000"
528 valt_load_address_sec_norml="0xUNSET"
529 valt_load_address_sec_inner="0xUNSET"
530 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
531 ;;
nethercote888ecb72004-08-23 14:54:40 +0000532 *)
njn7fd6d382009-01-22 21:56:32 +0000533 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000534 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000535 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
536 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000537 valt_load_address_pri_norml="0xUNSET"
538 valt_load_address_pri_inner="0xUNSET"
539 valt_load_address_sec_norml="0xUNSET"
540 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000541 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000542 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000543 ;;
544esac
sewardjde4a1d02002-03-22 01:27:54 +0000545
njn7fd6d382009-01-22 21:56:32 +0000546#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000547
njn7fd6d382009-01-22 21:56:32 +0000548# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
549# defined.
550AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
551 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000552 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
553 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
554 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000555AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000556 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
557 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000558AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
559 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000560 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000561AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000562 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000563AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
564 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000565AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
566 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000567
njn7fd6d382009-01-22 21:56:32 +0000568# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
569# become defined.
570AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
571 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
572 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
573AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
574 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
575AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
576 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
577 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
578AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
579 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000580AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
581 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000582AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
583 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
584 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000585
njnf76d27a2009-05-28 01:53:07 +0000586AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
587 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
588 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
589AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
590 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
591
592
sewardj72a2d802010-07-29 05:24:20 +0000593# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000594# Relies on the assumption that the primary and secondary targets are
595# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000596AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
597 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
598 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
599 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000600 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000601 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
602 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000603AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
604 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
605 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000606
607
njn7fd6d382009-01-22 21:56:32 +0000608# Sometimes, in the Makefile.am files, it's useful to know whether or not
609# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000610AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000611 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000612
tomb637bad2005-11-08 12:28:35 +0000613
njn7fd6d382009-01-22 21:56:32 +0000614#----------------------------------------------------------------------------
615# Inner Valgrind?
616#----------------------------------------------------------------------------
617
njnd74b0ef2009-01-20 06:06:52 +0000618# Check if this should be built as an inner Valgrind, to be run within
619# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000620AC_SUBST(VALT_LOAD_ADDRESS_PRI)
621AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000622AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
623 [AC_ARG_ENABLE(inner,
624 [ --enable-inner enables self-hosting],
625 [vg_cv_inner=$enableval],
626 [vg_cv_inner=no])])
627if test "$vg_cv_inner" = yes; then
628 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000629 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
630 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000631else
njnea2d6fd2010-07-01 00:20:20 +0000632 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
633 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000634fi
635
636
njn7fd6d382009-01-22 21:56:32 +0000637#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000638# Extra fine-tuning of installation directories
639#----------------------------------------------------------------------------
640AC_ARG_WITH(tmpdir,
641 [ --with-tmpdir=PATH Specify path for temporary files],
642 tmpdir="$withval",
643 tmpdir="/tmp")
644AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
645
sewardj0ba37c92011-07-12 11:46:24 +0000646
sewardjcb495c82011-07-11 20:42:34 +0000647#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000648# Libc and suppressions
649#----------------------------------------------------------------------------
650# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000651AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000652
bart12e91122010-05-15 08:37:24 +0000653AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000654
bart12e91122010-05-15 08:37:24 +0000655if test x$ac_cv_header_features_h = xyes; then
656 rm -f conftest.$ac_ext
657 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000658#include <features.h>
bart12e91122010-05-15 08:37:24 +0000659#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
660glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000661#endif
bart12e91122010-05-15 08:37:24 +0000662_ACEOF
663 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
664fi
bartb7c3f082010-05-13 06:32:36 +0000665
njnf76d27a2009-05-28 01:53:07 +0000666# not really a version check
667AC_EGREP_CPP([DARWIN_LIBC], [
668#include <sys/cdefs.h>
669#if defined(__DARWIN_VERS_1050)
670 DARWIN_LIBC
671#endif
672],
673GLIBC_VERSION="darwin")
674
sewardjcb495c82011-07-11 20:42:34 +0000675# not really a version check
676AC_EGREP_CPP([BIONIC_LIBC], [
677#if defined(__ANDROID__)
678 BIONIC_LIBC
679#endif
680],
681GLIBC_VERSION="bionic")
682
683
dirk07596a22008-04-25 11:33:30 +0000684AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000685
dirk07596a22008-04-25 11:33:30 +0000686case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000687 2.2)
688 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000689 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000690 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
691 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000692 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000693 ;;
694
sewardj08c7f012002-10-07 23:56:55 +0000695 2.3)
696 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000697 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000698 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000699 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000700 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000701 ;;
702
njn781dba52005-06-30 04:06:38 +0000703 2.4)
704 AC_MSG_RESULT(2.4 family)
705 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000706 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000707 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000708 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000709 ;;
710
dirkaece45c2006-10-12 08:17:49 +0000711 2.5)
712 AC_MSG_RESULT(2.5 family)
713 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000714 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000715 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000716 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000717 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000718 2.6)
719 AC_MSG_RESULT(2.6 family)
720 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000721 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000722 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000723 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000724 ;;
725 2.7)
726 AC_MSG_RESULT(2.7 family)
727 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000728 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000729 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000730 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000731 ;;
dirk07596a22008-04-25 11:33:30 +0000732 2.8)
733 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000734 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000735 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
736 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
737 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
738 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000739 2.9)
740 AC_MSG_RESULT(2.9 family)
741 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
742 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
743 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
744 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
745 ;;
sewardj5d425e82009-02-01 19:01:11 +0000746 2.10)
747 AC_MSG_RESULT(2.10 family)
748 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
749 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
750 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
751 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
752 ;;
bart0fac7ff2009-11-15 19:11:19 +0000753 2.11)
754 AC_MSG_RESULT(2.11 family)
755 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
756 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
757 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
758 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000759 ;;
760 2.12)
761 AC_MSG_RESULT(2.12 family)
762 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
763 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
764 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
765 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000766 ;;
tomebd619b2011-02-10 09:09:09 +0000767 2.13)
768 AC_MSG_RESULT(2.13 family)
769 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
770 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
771 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
772 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
773 ;;
tomcc077412011-06-07 21:52:26 +0000774 2.14)
775 AC_MSG_RESULT(2.14 family)
776 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
777 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
778 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
779 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
780 ;;
dirke75fdeb2011-12-29 08:24:55 +0000781 2.15)
782 AC_MSG_RESULT(2.15 family)
783 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
784 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
785 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
786 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
787 ;;
njnf76d27a2009-05-28 01:53:07 +0000788 darwin)
789 AC_MSG_RESULT(Darwin)
790 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
791 # DEFAULT_SUPP set by kernel version check above.
792 ;;
sewardjcb495c82011-07-11 20:42:34 +0000793 bionic)
794 AC_MSG_RESULT(Bionic)
795 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
796 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
797 ;;
dirkaece45c2006-10-12 08:17:49 +0000798
sewardjde4a1d02002-03-22 01:27:54 +0000799 *)
bart12e91122010-05-15 08:37:24 +0000800 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
dirke75fdeb2011-12-29 08:24:55 +0000801 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.15])
njnf76d27a2009-05-28 01:53:07 +0000802 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000803 ;;
804esac
805
dirk07596a22008-04-25 11:33:30 +0000806AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000807
sewardj414f3582008-07-18 20:46:00 +0000808
809# Add default suppressions for the X client libraries. Make no
810# attempt to detect whether such libraries are installed on the
811# build machine (or even if any X facilities are present); just
812# add the suppressions antidisirregardless.
813DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
814DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000815
sewardjd2f95a02011-05-11 16:04:28 +0000816# Add glibc and X11 suppressions for exp-sgcheck
817DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000818
sewardj2e10a682003-04-07 19:36:41 +0000819
njn7fd6d382009-01-22 21:56:32 +0000820#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000821# Platform variants?
822#----------------------------------------------------------------------------
823
824# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
825# But there are times where we need a bit more control. The motivating
826# and currently only case is Android: this is almost identical to arm-linux,
827# but not quite. So this introduces the concept of platform variant tags,
828# which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
829# with the main -DVGP_<arch>_<os> definition.
830#
831# In almost all cases, the <variant> bit is "vanilla". But for Android
832# it is "android" instead.
833#
834# Consequently (eg), plain arm-linux would build with
835#
836# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
837#
838# whilst an Android build would have
839#
840# -DVGP_arm_linux -DVGPV_arm_linux_android
841#
842# The setup of the platform variant is pushed relatively far down this
843# file in order that we can inspect any of the variables set above.
844
845# In the normal case ..
846VGCONF_PLATVARIANT="vanilla"
847
848# Android on ARM ?
849if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
850 -a "$GLIBC_VERSION" = "bionic";
851then
852 VGCONF_PLATVARIANT="android"
853fi
854
855AC_SUBST(VGCONF_PLATVARIANT)
856
857
858# FIXME: do we also want to define automake variables
859# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
860# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
861# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
862# do that. Problem is that we can't do and-ing in Makefile.am's, but
863# that's what we'd need to do to use this, since what we'd want to write
864# is something like
865#
866# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
867#
sewardj0ba37c92011-07-12 11:46:24 +0000868# Hmm. Can't think of a nice clean solution to this.
869
870AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
871 test x$VGCONF_PLATVARIANT = xvanilla)
872AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
873 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000874
875
876#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000877# Checking for various library functions and other definitions
878#----------------------------------------------------------------------------
879
bart59e2f182008-04-28 16:22:53 +0000880# Check for CLOCK_MONOTONIC
881
882AC_MSG_CHECKING([for CLOCK_MONOTONIC])
883
bart417cf3e2011-10-22 09:21:24 +0000884AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +0000885#include <time.h>
bart417cf3e2011-10-22 09:21:24 +0000886]], [[
bart59e2f182008-04-28 16:22:53 +0000887 struct timespec t;
888 clock_gettime(CLOCK_MONOTONIC, &t);
889 return 0;
bart417cf3e2011-10-22 09:21:24 +0000890]])], [
bart59e2f182008-04-28 16:22:53 +0000891AC_MSG_RESULT([yes])
892AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
893 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
894], [
895AC_MSG_RESULT([no])
896])
897
bartfea06922008-05-03 09:12:15 +0000898
sewardj0c09bf02011-07-11 22:11:58 +0000899# Check for PTHREAD_RWLOCK_T
900
901AC_MSG_CHECKING([for pthread_rwlock_t])
902
bart417cf3e2011-10-22 09:21:24 +0000903AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +0000904#define _GNU_SOURCE
905#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000906]], [[
sewardj0c09bf02011-07-11 22:11:58 +0000907 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +0000908]])], [
sewardj0c09bf02011-07-11 22:11:58 +0000909AC_MSG_RESULT([yes])
910AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
911 [Define to 1 if you have the `pthread_rwlock_t' type.])
912], [
913AC_MSG_RESULT([no])
914])
915
916
bartfea06922008-05-03 09:12:15 +0000917# Check for PTHREAD_MUTEX_ADAPTIVE_NP
918
919AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
920
bart417cf3e2011-10-22 09:21:24 +0000921AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000922#define _GNU_SOURCE
923#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000924]], [[
bartfea06922008-05-03 09:12:15 +0000925 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000926]])], [
bartfea06922008-05-03 09:12:15 +0000927AC_MSG_RESULT([yes])
928AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
929 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
930], [
931AC_MSG_RESULT([no])
932])
933
934
935# Check for PTHREAD_MUTEX_ERRORCHECK_NP
936
937AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
938
bart417cf3e2011-10-22 09:21:24 +0000939AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000940#define _GNU_SOURCE
941#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000942]], [[
bartfea06922008-05-03 09:12:15 +0000943 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +0000944]])], [
bartfea06922008-05-03 09:12:15 +0000945AC_MSG_RESULT([yes])
946AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
947 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
948], [
949AC_MSG_RESULT([no])
950])
951
952
953# Check for PTHREAD_MUTEX_RECURSIVE_NP
954
955AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
956
bart417cf3e2011-10-22 09:21:24 +0000957AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000958#define _GNU_SOURCE
959#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000960]], [[
bartfea06922008-05-03 09:12:15 +0000961 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000962]])], [
bartfea06922008-05-03 09:12:15 +0000963AC_MSG_RESULT([yes])
964AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
965 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
966], [
967AC_MSG_RESULT([no])
968])
969
970
971# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
972
973AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
974
bart417cf3e2011-10-22 09:21:24 +0000975AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000976#define _GNU_SOURCE
977#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000978]], [[
bartfea06922008-05-03 09:12:15 +0000979 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
980 return 0;
bart417cf3e2011-10-22 09:21:24 +0000981]])], [
bartfea06922008-05-03 09:12:15 +0000982AC_MSG_RESULT([yes])
983AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
984 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
985], [
986AC_MSG_RESULT([no])
987])
988
989
bart5e389f12008-04-05 12:53:15 +0000990# Check whether pthread_mutex_t has a member called __m_kind.
991
bartb11355c2010-04-29 16:37:26 +0000992AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
993 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
994 1,
995 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
996 ],
997 [],
998 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +0000999
1000
1001# Check whether pthread_mutex_t has a member called __data.__kind.
1002
bartb11355c2010-04-29 16:37:26 +00001003AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1004 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1005 1,
1006 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1007 ],
1008 [],
1009 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001010
1011
bart62c370e2008-05-12 18:50:51 +00001012# does this compiler support -maltivec and does it have the include file
1013# <altivec.h> ?
1014
1015AC_MSG_CHECKING([for Altivec])
1016
1017safe_CFLAGS=$CFLAGS
1018CFLAGS="-maltivec"
1019
bart417cf3e2011-10-22 09:21:24 +00001020AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001021#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001022]], [[
bart62c370e2008-05-12 18:50:51 +00001023 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001024]])], [
bart62c370e2008-05-12 18:50:51 +00001025ac_have_altivec=yes
1026AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001027AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001028 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001029], [
1030ac_have_altivec=no
1031AC_MSG_RESULT([no])
1032])
1033CFLAGS=$safe_CFLAGS
1034
sewardj0e342a02010-09-03 23:49:33 +00001035AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001036
1037
sewardjf34eb492011-04-15 11:57:05 +00001038# Check that both: the compiler supports -mvsx and that the assembler
1039# understands VSX instructions. If either of those doesn't work,
1040# conclude that we can't do VSX. NOTE: basically this is a kludge
1041# in that it conflates two things that should be separate -- whether
1042# the compiler understands the flag vs whether the assembler
1043# understands the opcodes. This really ought to be cleaned up
1044# and done properly, like it is for x86/x86_64.
1045
1046AC_MSG_CHECKING([for VSX])
1047
1048safe_CFLAGS=$CFLAGS
1049CFLAGS="-mvsx"
1050
bart417cf3e2011-10-22 09:21:24 +00001051AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001052#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001053]], [[
sewardjf34eb492011-04-15 11:57:05 +00001054 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001055 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001056]])], [
sewardjf34eb492011-04-15 11:57:05 +00001057ac_have_vsx=yes
1058AC_MSG_RESULT([yes])
1059], [
1060ac_have_vsx=no
1061AC_MSG_RESULT([no])
1062])
1063CFLAGS=$safe_CFLAGS
1064
1065AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1066
1067
bart36dd85a2009-04-26 07:11:48 +00001068# Check for pthread_create@GLIBC2.0
1069AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1070
bart16e1c5a2009-04-26 07:38:53 +00001071safe_CFLAGS=$CFLAGS
1072CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001073AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001074extern int pthread_create_glibc_2_0(void*, const void*,
1075 void *(*)(void*), void*);
1076__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001077]], [[
bart276ed3a2009-05-10 15:41:45 +00001078#ifdef __powerpc__
1079/*
1080 * Apparently on PowerPC linking this program succeeds and generates an
1081 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1082 */
1083#error This test does not work properly on PowerPC.
1084#else
bart16e1c5a2009-04-26 07:38:53 +00001085 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001086#endif
bart16e1c5a2009-04-26 07:38:53 +00001087 return 0;
bart417cf3e2011-10-22 09:21:24 +00001088]])], [
bart36dd85a2009-04-26 07:11:48 +00001089ac_have_pthread_create_glibc_2_0=yes
1090AC_MSG_RESULT([yes])
1091AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1092 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1093], [
1094ac_have_pthread_create_glibc_2_0=no
1095AC_MSG_RESULT([no])
1096])
bart16e1c5a2009-04-26 07:38:53 +00001097CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001098
1099AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001100 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001101
1102
barta50aa8a2008-04-27 06:06:57 +00001103# Check for eventfd_t, eventfd() and eventfd_read()
1104AC_MSG_CHECKING([for eventfd()])
1105
bart417cf3e2011-10-22 09:21:24 +00001106AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001107#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001108]], [[
barta50aa8a2008-04-27 06:06:57 +00001109 eventfd_t ev;
1110 int fd;
1111
1112 fd = eventfd(5, 0);
1113 eventfd_read(fd, &ev);
1114 return 0;
bart417cf3e2011-10-22 09:21:24 +00001115]])], [
barta50aa8a2008-04-27 06:06:57 +00001116AC_MSG_RESULT([yes])
1117AC_DEFINE([HAVE_EVENTFD], 1,
1118 [Define to 1 if you have the `eventfd' function.])
1119AC_DEFINE([HAVE_EVENTFD_READ], 1,
1120 [Define to 1 if you have the `eventfd_read' function.])
1121], [
1122AC_MSG_RESULT([no])
1123])
1124
1125
njn7fd6d382009-01-22 21:56:32 +00001126#----------------------------------------------------------------------------
1127# Checking for supported compiler flags.
1128#----------------------------------------------------------------------------
1129
sewardj535c50f2005-06-04 23:14:53 +00001130# does this compiler support -m32 ?
1131AC_MSG_CHECKING([if gcc accepts -m32])
1132
1133safe_CFLAGS=$CFLAGS
1134CFLAGS="-m32"
1135
bart417cf3e2011-10-22 09:21:24 +00001136AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001137 return 0;
bart417cf3e2011-10-22 09:21:24 +00001138]])], [
sewardj535c50f2005-06-04 23:14:53 +00001139FLAG_M32="-m32"
1140AC_MSG_RESULT([yes])
1141], [
1142FLAG_M32=""
1143AC_MSG_RESULT([no])
1144])
1145CFLAGS=$safe_CFLAGS
1146
1147AC_SUBST(FLAG_M32)
1148
1149
sewardj01262142006-01-04 01:20:28 +00001150# does this compiler support -m64 ?
1151AC_MSG_CHECKING([if gcc accepts -m64])
1152
1153safe_CFLAGS=$CFLAGS
1154CFLAGS="-m64"
1155
bart417cf3e2011-10-22 09:21:24 +00001156AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001157 return 0;
bart417cf3e2011-10-22 09:21:24 +00001158]])], [
sewardj01262142006-01-04 01:20:28 +00001159FLAG_M64="-m64"
1160AC_MSG_RESULT([yes])
1161], [
1162FLAG_M64=""
1163AC_MSG_RESULT([no])
1164])
1165CFLAGS=$safe_CFLAGS
1166
1167AC_SUBST(FLAG_M64)
1168
1169
sewardj67f1fcc2005-07-03 10:41:02 +00001170# does this compiler support -mmmx ?
1171AC_MSG_CHECKING([if gcc accepts -mmmx])
1172
1173safe_CFLAGS=$CFLAGS
1174CFLAGS="-mmmx"
1175
bart417cf3e2011-10-22 09:21:24 +00001176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001177 return 0;
bart417cf3e2011-10-22 09:21:24 +00001178]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001179FLAG_MMMX="-mmmx"
1180AC_MSG_RESULT([yes])
1181], [
1182FLAG_MMMX=""
1183AC_MSG_RESULT([no])
1184])
1185CFLAGS=$safe_CFLAGS
1186
1187AC_SUBST(FLAG_MMMX)
1188
1189
1190# does this compiler support -msse ?
1191AC_MSG_CHECKING([if gcc accepts -msse])
1192
1193safe_CFLAGS=$CFLAGS
1194CFLAGS="-msse"
1195
bart417cf3e2011-10-22 09:21:24 +00001196AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001197 return 0;
bart417cf3e2011-10-22 09:21:24 +00001198]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001199FLAG_MSSE="-msse"
1200AC_MSG_RESULT([yes])
1201], [
1202FLAG_MSSE=""
1203AC_MSG_RESULT([no])
1204])
1205CFLAGS=$safe_CFLAGS
1206
1207AC_SUBST(FLAG_MSSE)
1208
1209
sewardj5b754b42002-06-03 22:53:35 +00001210# does this compiler support -mpreferred-stack-boundary=2 ?
1211AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1212
daywalker3664f562003-10-17 13:43:46 +00001213safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001214CFLAGS="-mpreferred-stack-boundary=2"
1215
bart417cf3e2011-10-22 09:21:24 +00001216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001217 return 0;
bart417cf3e2011-10-22 09:21:24 +00001218]])], [
sewardj5b754b42002-06-03 22:53:35 +00001219PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001220AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001221], [
1222PREFERRED_STACK_BOUNDARY=""
1223AC_MSG_RESULT([no])
1224])
daywalker3664f562003-10-17 13:43:46 +00001225CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001226
1227AC_SUBST(PREFERRED_STACK_BOUNDARY)
1228
sewardj535c50f2005-06-04 23:14:53 +00001229
sewardjb5f6f512005-03-10 23:59:00 +00001230# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001231AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001232
1233safe_CFLAGS=$CFLAGS
1234CFLAGS="-Wno-pointer-sign"
1235
bart417cf3e2011-10-22 09:21:24 +00001236AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001237 return 0;
bart417cf3e2011-10-22 09:21:24 +00001238]])], [
sewardjb5f6f512005-03-10 23:59:00 +00001239no_pointer_sign=yes
1240AC_MSG_RESULT([yes])
1241], [
1242no_pointer_sign=no
1243AC_MSG_RESULT([no])
1244])
1245CFLAGS=$safe_CFLAGS
1246
1247if test x$no_pointer_sign = xyes; then
1248 CFLAGS="$CFLAGS -Wno-pointer-sign"
1249fi
1250
sewardj535c50f2005-06-04 23:14:53 +00001251
barte026bd22009-07-04 12:17:07 +00001252# does this compiler support -Wno-empty-body ?
1253
1254AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1255
1256safe_CFLAGS=$CFLAGS
1257CFLAGS="-Wno-empty-body"
1258
bart417cf3e2011-10-22 09:21:24 +00001259AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001260 return 0;
bart417cf3e2011-10-22 09:21:24 +00001261]])], [
barte026bd22009-07-04 12:17:07 +00001262AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1263AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001264], [
barte026bd22009-07-04 12:17:07 +00001265AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1266AC_MSG_RESULT([no])
1267])
1268CFLAGS=$safe_CFLAGS
1269
1270
bart9d865fa2008-06-23 12:11:49 +00001271# does this compiler support -Wno-format-zero-length ?
1272
1273AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1274
1275safe_CFLAGS=$CFLAGS
1276CFLAGS="-Wno-format-zero-length"
1277
bart417cf3e2011-10-22 09:21:24 +00001278AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001279 return 0;
bart417cf3e2011-10-22 09:21:24 +00001280]])], [
bart9d865fa2008-06-23 12:11:49 +00001281AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1282AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001283], [
bart9d865fa2008-06-23 12:11:49 +00001284AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1285AC_MSG_RESULT([no])
1286])
1287CFLAGS=$safe_CFLAGS
1288
1289
bart8e216312011-05-15 17:05:36 +00001290# does this compiler support -Wno-nonnull ?
1291
1292AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1293
1294safe_CFLAGS=$CFLAGS
1295CFLAGS="-Wno-nonnull"
1296
bart417cf3e2011-10-22 09:21:24 +00001297AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001298 return 0;
bart417cf3e2011-10-22 09:21:24 +00001299]])], [
bart8e216312011-05-15 17:05:36 +00001300AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1301AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001302], [
bart8e216312011-05-15 17:05:36 +00001303AC_SUBST([FLAG_W_NO_NONNULL], [])
1304AC_MSG_RESULT([no])
1305])
1306CFLAGS=$safe_CFLAGS
1307
1308
1309# does this compiler support -Wno-overflow ?
1310
1311AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1312
1313safe_CFLAGS=$CFLAGS
1314CFLAGS="-Wno-overflow"
1315
bart417cf3e2011-10-22 09:21:24 +00001316AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001317 return 0;
bart417cf3e2011-10-22 09:21:24 +00001318]])], [
bart8e216312011-05-15 17:05:36 +00001319AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1320AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001321], [
bart8e216312011-05-15 17:05:36 +00001322AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1323AC_MSG_RESULT([no])
1324])
1325CFLAGS=$safe_CFLAGS
1326
1327
bartbf9b85c2009-08-12 12:55:56 +00001328# does this compiler support -Wno-uninitialized ?
1329
1330AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1331
1332safe_CFLAGS=$CFLAGS
1333CFLAGS="-Wno-uninitialized"
1334
bart417cf3e2011-10-22 09:21:24 +00001335AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001336 return 0;
bart417cf3e2011-10-22 09:21:24 +00001337]])], [
bartbf9b85c2009-08-12 12:55:56 +00001338AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1339AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001340], [
bartbf9b85c2009-08-12 12:55:56 +00001341AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1342AC_MSG_RESULT([no])
1343])
1344CFLAGS=$safe_CFLAGS
1345
1346
bart56730cd2008-05-11 06:41:46 +00001347# does this compiler support -Wextra or the older -W ?
1348
1349AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1350
1351safe_CFLAGS=$CFLAGS
1352CFLAGS="-Wextra"
1353
bart417cf3e2011-10-22 09:21:24 +00001354AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001355 return 0;
bart417cf3e2011-10-22 09:21:24 +00001356]])], [
bart56730cd2008-05-11 06:41:46 +00001357AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1358AC_MSG_RESULT([-Wextra])
1359], [
1360 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001362 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001363 ]])], [
bart56730cd2008-05-11 06:41:46 +00001364 AC_SUBST([FLAG_W_EXTRA], [-W])
1365 AC_MSG_RESULT([-W])
1366 ], [
1367 AC_SUBST([FLAG_W_EXTRA], [])
1368 AC_MSG_RESULT([not supported])
1369 ])
1370])
1371CFLAGS=$safe_CFLAGS
1372
1373
sewardja72c26d2007-05-01 13:44:08 +00001374# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001375AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001376
1377safe_CFLAGS=$CFLAGS
1378CFLAGS="-fno-stack-protector"
1379
bart417cf3e2011-10-22 09:21:24 +00001380AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001381 return 0;
bart417cf3e2011-10-22 09:21:24 +00001382]])], [
sewardja72c26d2007-05-01 13:44:08 +00001383no_stack_protector=yes
1384FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1385AC_MSG_RESULT([yes])
1386], [
1387no_stack_protector=no
1388FLAG_FNO_STACK_PROTECTOR=""
1389AC_MSG_RESULT([no])
1390])
1391CFLAGS=$safe_CFLAGS
1392
1393AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1394
1395if test x$no_stack_protector = xyes; then
1396 CFLAGS="$CFLAGS -fno-stack-protector"
1397fi
1398
1399
bart56730cd2008-05-11 06:41:46 +00001400# does this compiler support --param inline-unit-growth=... ?
1401
1402AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1403
1404safe_CFLAGS=$CFLAGS
1405CFLAGS="--param inline-unit-growth=900"
1406
bart417cf3e2011-10-22 09:21:24 +00001407AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001408 return 0;
bart417cf3e2011-10-22 09:21:24 +00001409]])], [
bart56730cd2008-05-11 06:41:46 +00001410AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1411 ["--param inline-unit-growth=900"])
1412AC_MSG_RESULT([yes])
1413], [
1414AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1415AC_MSG_RESULT([no])
1416])
1417CFLAGS=$safe_CFLAGS
1418
1419
sewardjd3645802010-06-13 22:13:58 +00001420# does the linker support -Wl,--build-id=none ? Note, it's
1421# important that we test indirectly via whichever C compiler
1422# is selected, rather than testing /usr/bin/ld or whatever
1423# directly.
bart699fbac2010-06-08 18:23:59 +00001424
sewardjd3645802010-06-13 22:13:58 +00001425AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001426
1427safe_CFLAGS=$CFLAGS
1428CFLAGS="-Wl,--build-id=none"
1429
bart8508c752010-06-10 06:26:21 +00001430AC_LINK_IFELSE(
1431[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001432[
1433 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1434 AC_MSG_RESULT([yes])
1435], [
1436 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1437 AC_MSG_RESULT([no])
1438])
1439CFLAGS=$safe_CFLAGS
1440
1441
sewardj00f1e622006-03-12 16:47:10 +00001442# does the ppc assembler support "mtocrf" et al?
1443AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1444
bart417cf3e2011-10-22 09:21:24 +00001445AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001446__asm__ __volatile__("mtocrf 4,0");
1447__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001448]])], [
sewardj00f1e622006-03-12 16:47:10 +00001449ac_have_as_ppc_mftocrf=yes
1450AC_MSG_RESULT([yes])
1451], [
1452ac_have_as_ppc_mftocrf=no
1453AC_MSG_RESULT([no])
1454])
1455if test x$ac_have_as_ppc_mftocrf = xyes ; then
1456 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1457fi
1458
1459
sewardjb5b87402011-03-07 16:05:35 +00001460CFLAGS=$safe_CFLAGS
1461
sewardjf0aabf82007-03-22 00:24:21 +00001462# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001463# Note, this doesn't generate a C-level symbol. It generates a
1464# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001465AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1466
bart417cf3e2011-10-22 09:21:24 +00001467AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001468 do { long long int x;
1469 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1470 while (0)
bart417cf3e2011-10-22 09:21:24 +00001471]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001472ac_have_as_sse3=yes
1473AC_MSG_RESULT([yes])
1474], [
1475ac_have_as_sse3=no
1476AC_MSG_RESULT([no])
1477])
sewardjfa18a262007-03-22 12:13:13 +00001478
1479AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001480
1481
sewardj6d6da5b2008-02-09 12:07:40 +00001482# Ditto for SSSE3 instructions (note extra S)
1483# Note, this doesn't generate a C-level symbol. It generates a
1484# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1485AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1486
florianc443b962011-10-28 21:37:19 +00001487save_CFLAGS="$CFLAGS"
1488CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001489AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001490 do { long long int x;
1491 __asm__ __volatile__(
1492 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1493 while (0)
bart417cf3e2011-10-22 09:21:24 +00001494]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001495ac_have_as_ssse3=yes
1496AC_MSG_RESULT([yes])
1497], [
1498ac_have_as_ssse3=no
1499AC_MSG_RESULT([no])
1500])
florianc443b962011-10-28 21:37:19 +00001501CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001502
1503AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1504
1505
sewardj27d176a2011-01-17 11:15:48 +00001506# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1507# Note, this doesn't generate a C-level symbol. It generates a
1508# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001509AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001510AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001511 do {
1512 __asm__ __volatile__(
1513 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1514 while (0)
bart417cf3e2011-10-22 09:21:24 +00001515]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001516ac_have_as_pclmulqdq=yes
1517AC_MSG_RESULT([yes])
1518], [
1519ac_have_as_pclmulqdq=no
1520AC_MSG_RESULT([no])
1521])
1522
1523AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1524
1525
sewardj27d176a2011-01-17 11:15:48 +00001526# does the x86/amd64 assembler understand the LZCNT instruction?
1527# Note, this doesn't generate a C-level symbol. It generates a
1528# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001529AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1530
bart417cf3e2011-10-22 09:21:24 +00001531AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00001532 do {
1533 __asm__ __volatile__("lzcnt %rax,%rax");
1534 } while (0)
bart417cf3e2011-10-22 09:21:24 +00001535]])], [
bart55e438b2010-09-14 10:53:57 +00001536 ac_have_as_lzcnt=yes
1537 AC_MSG_RESULT([yes])
1538], [
1539 ac_have_as_lzcnt=no
1540 AC_MSG_RESULT([no])
1541])
1542
1543AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1544
sewardj27d176a2011-01-17 11:15:48 +00001545
1546# does the x86/amd64 assembler understand SSE 4.2 instructions?
1547# Note, this doesn't generate a C-level symbol. It generates a
1548# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1549AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1550
bart417cf3e2011-10-22 09:21:24 +00001551AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00001552 do { long long int x;
1553 __asm__ __volatile__(
1554 "crc32q %%r15,%%r15" : : : "r15" ); }
1555 while (0)
bart417cf3e2011-10-22 09:21:24 +00001556]])], [
sewardj27d176a2011-01-17 11:15:48 +00001557ac_have_as_sse42=yes
1558AC_MSG_RESULT([yes])
1559], [
1560ac_have_as_sse42=no
1561AC_MSG_RESULT([no])
1562])
1563
1564AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1565
1566
sewardje089f012010-10-13 21:47:29 +00001567# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1568# when building the tool executables. I think we should get rid of it.
1569#
sewardjb5f6f512005-03-10 23:59:00 +00001570# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00001571AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1572 [[return foo;]])],
1573 [vg_cv_linktime_tls=yes],
1574 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00001575# Native compilation: check whether running a program using TLS succeeds.
1576# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1577# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00001578# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00001579AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1580 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1581 [vg_cv_tls=$enableval],
1582 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1583 [[return foo;]])],
1584 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00001585 [vg_cv_tls=no],
1586 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00001587
1588if test "$vg_cv_tls" = yes; then
1589AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1590fi
sewardj5b754b42002-06-03 22:53:35 +00001591
sewardj535c50f2005-06-04 23:14:53 +00001592
njn7fd6d382009-01-22 21:56:32 +00001593#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001594# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001595#----------------------------------------------------------------------------
1596
sewardjde4a1d02002-03-22 01:27:54 +00001597AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001598AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001599 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001600 endian.h \
1601 mqueue.h \
1602 sys/endian.h \
1603 sys/epoll.h \
1604 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001605 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001606 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001607 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001608 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001609 sys/syscall.h \
1610 sys/time.h \
1611 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001612 ])
sewardjde4a1d02002-03-22 01:27:54 +00001613
bart818f17e2011-09-17 06:24:49 +00001614# Verify whether the <linux/futex.h> header is usable.
1615AC_MSG_CHECKING([if <linux/futex.h> is usable])
1616
bart417cf3e2011-10-22 09:21:24 +00001617AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00001618#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00001619]], [[
bart818f17e2011-09-17 06:24:49 +00001620 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00001621]])], [
bart78bfc712011-12-08 16:14:59 +00001622ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00001623AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1624 [Define to 1 if you have a usable <linux/futex.h> header file.])
1625AC_MSG_RESULT([yes])
1626], [
bart78bfc712011-12-08 16:14:59 +00001627ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00001628AC_MSG_RESULT([no])
1629])
1630
njn7fd6d382009-01-22 21:56:32 +00001631#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001632# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001633#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001634AC_TYPE_UID_T
1635AC_TYPE_OFF_T
1636AC_TYPE_SIZE_T
1637AC_HEADER_TIME
1638
sewardj535c50f2005-06-04 23:14:53 +00001639
njn7fd6d382009-01-22 21:56:32 +00001640#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001641# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001642#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001643AC_FUNC_MEMCMP
1644AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00001645
bart26288e42011-04-03 16:46:01 +00001646AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001647AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001648
bartf5ceec82008-04-26 07:45:10 +00001649AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001650 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001651 epoll_create \
1652 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001653 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001654 mallinfo \
1655 memchr \
1656 memset \
1657 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001658 mremap \
bartf5ceec82008-04-26 07:45:10 +00001659 ppoll \
bart6d45e922009-01-20 13:45:38 +00001660 pthread_barrier_init \
1661 pthread_condattr_setclock \
1662 pthread_mutex_timedlock \
1663 pthread_rwlock_timedrdlock \
1664 pthread_rwlock_timedwrlock \
1665 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001666 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001667 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001668 semtimedop \
1669 signalfd \
njn6cc22472009-03-16 03:46:48 +00001670 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001671 strchr \
1672 strdup \
1673 strpbrk \
1674 strrchr \
1675 strstr \
barta72a27b2010-04-29 06:22:17 +00001676 syscall \
bartf5ceec82008-04-26 07:45:10 +00001677 utimensat \
1678 ])
sewardjde4a1d02002-03-22 01:27:54 +00001679
bart623eec32008-07-29 17:54:49 +00001680# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1681# libraries with any shared object and/or executable. This is NOT what we
1682# want for e.g. vgpreload_core-x86-linux.so
1683LIBS=""
sewardj80637752006-03-02 13:48:21 +00001684
bart6d45e922009-01-20 13:45:38 +00001685AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1686 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001687AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1688 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001689AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1690 [test x$ac_cv_func_pthread_spin_lock = xyes])
1691
njn7fd6d382009-01-22 21:56:32 +00001692
1693#----------------------------------------------------------------------------
1694# MPI checks
1695#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001696# Do we have a useable MPI setup on the primary and/or secondary targets?
1697# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001698# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001699# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001700# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001701MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001702
sewardje9fa5062006-03-12 18:29:18 +00001703mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001704if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001705 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1706 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001707 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001708elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001709 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1710 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001711 mflag_primary=$FLAG_M64
1712fi
1713
sewardj03d86f22006-10-17 00:57:24 +00001714mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001715if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1716 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001717 mflag_secondary=$FLAG_M32
sewardj03d86f22006-10-17 00:57:24 +00001718fi
1719
1720
sewardj0ad46092006-03-02 17:09:16 +00001721AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001722 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001723 MPI_CC=$withval
1724)
sewardj03d86f22006-10-17 00:57:24 +00001725AC_SUBST(MPI_CC)
1726
1727## See if MPI_CC works for the primary target
1728##
1729AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001730saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001731saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001732CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +00001733CFLAGS=$mflag_primary
bart417cf3e2011-10-22 09:21:24 +00001734AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00001735#include <mpi.h>
1736#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001737]], [[
sewardjde4f3842006-03-09 02:41:41 +00001738 int r = MPI_Init(NULL,NULL);
1739 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1740 return r;
bart417cf3e2011-10-22 09:21:24 +00001741]])], [
sewardj03d86f22006-10-17 00:57:24 +00001742ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001743AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001744], [
sewardj03d86f22006-10-17 00:57:24 +00001745ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001746AC_MSG_RESULT([no])
1747])
sewardj0ad46092006-03-02 17:09:16 +00001748CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001749CFLAGS=$saved_CFLAGS
sewardj03d86f22006-10-17 00:57:24 +00001750AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001751
sewardj03d86f22006-10-17 00:57:24 +00001752## See if MPI_CC works for the secondary target. Complication: what if
1753## there is no secondary target? We need this to then fail.
1754## Kludge this by making MPI_CC something which will surely fail in
1755## such a case.
1756##
1757AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1758saved_CC=$CC
1759saved_CFLAGS=$CFLAGS
njn7fd6d382009-01-22 21:56:32 +00001760if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001761 CC="$MPI_CC this will surely fail"
1762else
1763 CC=$MPI_CC
1764fi
1765CFLAGS=$mflag_secondary
bart417cf3e2011-10-22 09:21:24 +00001766AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00001767#include <mpi.h>
1768#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001769]], [[
sewardj03d86f22006-10-17 00:57:24 +00001770 int r = MPI_Init(NULL,NULL);
1771 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1772 return r;
bart417cf3e2011-10-22 09:21:24 +00001773]])], [
sewardj03d86f22006-10-17 00:57:24 +00001774ac_have_mpi2_sec=yes
1775AC_MSG_RESULT([yes, $MPI_CC])
1776], [
1777ac_have_mpi2_sec=no
1778AC_MSG_RESULT([no])
1779])
1780CC=$saved_CC
1781CFLAGS=$saved_CFLAGS
1782AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001783
1784
njn7fd6d382009-01-22 21:56:32 +00001785#----------------------------------------------------------------------------
1786# Other library checks
1787#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00001788# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00001789# tests are present because Drd has some regression tests that use
1790# these packages. All regression test programs all compiled only
1791# for the primary target. And so it is important that the configure
1792# checks that follow, use the correct -m32 or -m64 flag for the
1793# primary target (called $mflag_primary). Otherwise, we can end up
1794# in a situation (eg) where, on amd64-linux, the test for Boost checks
1795# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1796# only build (meaning, the primary target is x86-linux), the build
1797# of the regtest programs that use Boost fails, because they are
1798# build as 32-bit (IN THIS EXAMPLE).
1799#
1800# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1801# NEEDED BY THE REGRESSION TEST PROGRAMS.
1802
1803
sewardj493c4ef2008-12-13 16:45:19 +00001804# Check whether the boost library 1.35 or later has been installed.
1805# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1806
1807AC_MSG_CHECKING([for boost])
1808
1809AC_LANG(C++)
1810safe_CXXFLAGS=$CXXFLAGS
1811CXXFLAGS="-lboost_thread-mt $mflag_primary"
1812
bart128fc522011-03-12 10:36:35 +00001813AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001814#include <boost/thread.hpp>
1815static void thread_func(void)
1816{ }
1817int main(int argc, char** argv)
1818{
1819 boost::thread t(thread_func);
1820 return 0;
1821}
bart128fc522011-03-12 10:36:35 +00001822])],
sewardj493c4ef2008-12-13 16:45:19 +00001823[
1824ac_have_boost_1_35=yes
1825AC_SUBST([BOOST_CFLAGS], [])
1826AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1827AC_MSG_RESULT([yes])
1828], [
1829ac_have_boost_1_35=no
1830AC_MSG_RESULT([no])
1831])
1832
1833CXXFLAGS=$safe_CXXFLAGS
1834AC_LANG(C)
1835
1836AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1837
1838
1839# does this compiler support -fopenmp, does it have the include file
1840# <omp.h> and does it have libgomp ?
1841
1842AC_MSG_CHECKING([for OpenMP])
1843
1844safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001845CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001846
bart128fc522011-03-12 10:36:35 +00001847AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001848#include <omp.h>
1849int main(int argc, char** argv)
1850{
1851 omp_set_dynamic(0);
1852 return 0;
1853}
bart128fc522011-03-12 10:36:35 +00001854])],
sewardj493c4ef2008-12-13 16:45:19 +00001855[
1856ac_have_openmp=yes
1857AC_MSG_RESULT([yes])
1858], [
1859ac_have_openmp=no
1860AC_MSG_RESULT([no])
1861])
1862CFLAGS=$safe_CFLAGS
1863
1864AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1865
1866
bart78bfc712011-12-08 16:14:59 +00001867# does this compiler have built-in functions for atomic memory access for the
1868# primary target ?
1869AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00001870
1871safe_CFLAGS=$CFLAGS
1872CFLAGS="$mflag_primary"
1873
bart417cf3e2011-10-22 09:21:24 +00001874AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00001875 int variable = 1;
1876 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1877 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001878]])], [
bartb4ff7822011-12-10 19:48:04 +00001879 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00001880 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00001881 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 +00001882], [
bartb4ff7822011-12-10 19:48:04 +00001883 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00001884 AC_MSG_RESULT([no])
1885])
1886
1887CFLAGS=$safe_CFLAGS
1888
bartb4ff7822011-12-10 19:48:04 +00001889AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
1890 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00001891
bart78bfc712011-12-08 16:14:59 +00001892
1893# does this compiler have built-in functions for atomic memory access for the
1894# secondary target ?
1895
1896if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1897
1898AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
1899
1900safe_CFLAGS=$CFLAGS
1901CFLAGS="$mflag_secondary"
1902
1903AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1904 int variable = 1;
1905 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
1906]])], [
1907 ac_have_builtin_atomic_secondary=yes
1908 AC_MSG_RESULT([yes])
1909], [
1910 ac_have_builtin_atomic_secondary=no
1911 AC_MSG_RESULT([no])
1912])
1913
1914CFLAGS=$safe_CFLAGS
1915
1916fi
1917
1918AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
1919 [test x$ac_have_builtin_atomic_secondary = xyes])
1920
bart1e856ea2011-12-17 12:53:23 +00001921# does this compiler have built-in functions for atomic memory access on
1922# 64-bit integers for all targets ?
1923
1924AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
1925
1926AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1927 #include <stdint.h>
1928]], [[
1929 uint64_t variable = 1;
1930 return __sync_add_and_fetch(&variable, 1)
1931]])], [
1932 ac_have_builtin_atomic64_primary=yes
1933], [
1934 ac_have_builtin_atomic64_primary=no
1935])
1936
1937if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1938
1939safe_CFLAGS=$CFLAGS
1940CFLAGS="$mflag_secondary"
1941
1942AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1943 #include <stdint.h>
1944]], [[
1945 uint64_t variable = 1;
1946 return __sync_add_and_fetch(&variable, 1)
1947]])], [
1948 ac_have_builtin_atomic64_secondary=yes
1949], [
1950 ac_have_builtin_atomic64_secondary=no
1951])
1952
1953CFLAGS=$safe_CFLAGS
1954
1955fi
1956
1957if test x$ac_have_builtin_atomic64_primary = xyes && \
1958 test x$VGCONF_PLATFORM_SEC_CAPS = x \
1959 -o x$ac_have_builtin_atomic64_secondary = xyes; then
1960 AC_MSG_RESULT([yes])
1961 ac_have_builtin_atomic64=yes
1962else
1963 AC_MSG_RESULT([no])
1964 ac_have_builtin_atomic64=no
1965fi
1966
1967AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
1968 [test x$ac_have_builtin_atomic64 = xyes])
1969
bart78bfc712011-12-08 16:14:59 +00001970
barte8740422011-03-24 20:27:54 +00001971# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00001972AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00001973
1974safe_CXXFLAGS=$CXXFLAGS
1975CXXFLAGS="$mflag_primary"
1976
1977AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00001978AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00001979 int variable = 1;
1980 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1981 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001982]])], [
barte8740422011-03-24 20:27:54 +00001983 ac_have_builtin_atomic_cxx=yes
1984 AC_MSG_RESULT([yes])
1985 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 +00001986], [
barte8740422011-03-24 20:27:54 +00001987 ac_have_builtin_atomic_cxx=no
1988 AC_MSG_RESULT([no])
1989])
1990AC_LANG_POP(C++)
1991
1992CXXFLAGS=$safe_CXXFLAGS
1993
1994AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00001995
bart78bfc712011-12-08 16:14:59 +00001996
1997if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00001998 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00001999 ac_enable_linux_ticket_lock_primary=yes
2000fi
2001AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2002 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2003
2004if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2005 -a x$ac_have_usable_linux_futex_h = xyes \
2006 -a x$ac_have_builtin_atomic_secondary = xyes; then
2007 ac_enable_linux_ticket_lock_secondary=yes
2008fi
2009AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2010 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2011
2012
bartf68af882011-12-10 19:42:05 +00002013# does libstdc++ support annotating shared pointers ?
2014AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2015
2016safe_CXXFLAGS=$CFLAGS
2017CXXFLAGS="-std=c++0x"
2018
2019AC_LANG_PUSH(C++)
2020AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2021 #include <memory>
2022]], [[
2023 std::shared_ptr<int> p
2024]])], [
2025 ac_have_shared_ptr=yes
2026], [
2027 ac_have_shared_ptr=no
2028])
2029if test x$ac_have_shared_ptr = xyes; then
2030 # If compilation of the program below fails because of a syntax error
2031 # triggered by substituting one of the annotation macros then that
2032 # means that libstdc++ supports these macros.
2033 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2034 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2035 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2036 #include <memory>
2037 ]], [[
2038 std::shared_ptr<int> p
2039 ]])], [
2040 ac_have_shared_pointer_annotation=no
2041 AC_MSG_RESULT([no])
2042 ], [
2043 ac_have_shared_pointer_annotation=yes
2044 AC_MSG_RESULT([yes])
2045 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2046 [Define to 1 if libstd++ supports annotating shared pointers])
2047 ])
2048else
2049 ac_have_shared_pointer_annotation=no
2050 AC_MSG_RESULT([no])
2051fi
2052AC_LANG_POP(C++)
2053
2054CXXFLAGS=$safe_CXXFLAGS
2055
2056AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2057 [test x$ac_have_shared_pointer_annotation = xyes])
2058
2059
njn7fd6d382009-01-22 21:56:32 +00002060#----------------------------------------------------------------------------
2061# Ok. We're done checking.
2062#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002063
njn8b68b642009-06-24 00:37:09 +00002064# Nb: VEX/Makefile is generated from Makefile.vex.in.
2065AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002066 Makefile
njn8b68b642009-06-24 00:37:09 +00002067 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002068 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002069 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002070 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002071 docs/Makefile
2072 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002073 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002074 perf/Makefile
2075 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002076 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002077 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002078 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002079 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002080 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002081 memcheck/Makefile
2082 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002083 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002084 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002085 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002086 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002087 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002088 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002089 memcheck/tests/ppc32/Makefile
2090 memcheck/tests/ppc64/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002091 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002092 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002093 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002094 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002095 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002096 callgrind/Makefile
2097 callgrind/callgrind_annotate
2098 callgrind/callgrind_control
2099 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002100 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002101 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002102 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002103 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002104 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002105 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002106 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002107 none/Makefile
2108 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002109 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002110 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002111 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002112 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002113 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002114 none/tests/s390x/Makefile
njn0458a122009-02-13 06:23:46 +00002115 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002116 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002117 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002118 exp-sgcheck/Makefile
2119 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002120 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002121 drd/scripts/download-and-build-splash2
2122 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002123 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002124 exp-bbv/tests/Makefile
2125 exp-bbv/tests/x86/Makefile
2126 exp-bbv/tests/x86-linux/Makefile
2127 exp-bbv/tests/amd64-linux/Makefile
2128 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002129 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002130 exp-dhat/Makefile
2131 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002132])
sewardjd3645802010-06-13 22:13:58 +00002133AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2134 [chmod +x coregrind/link_tool_exe_linux])
2135AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2136 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002137AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002138
2139cat<<EOF
2140
njn311303f2009-02-06 03:46:50 +00002141 Maximum build arch: ${ARCH_MAX}
2142 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002143 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002144 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002145 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2146 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002147 Platform variant: ${VGCONF_PLATVARIANT}
2148 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002149 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002150
gobry3b777892002-04-04 09:18:39 +00002151EOF