blob: 623bdc32101c7ba74419eb812a9b3d297aa25e87 [file] [log] [blame]
sewardj01262142006-01-04 01:20:28 +00001
2##------------------------------------------------------------##
3#
4# The multiple-architecture stuff in this file is pretty
5# cryptic. Read docs/internals/multiple-architectures.txt
6# for at least a partial explanation of what is going on.
7#
8##------------------------------------------------------------##
9
sewardjde4a1d02002-03-22 01:27:54 +000010# Process this file with autoconf to produce a configure script.
sewardj96e6aa62011-10-25 09:20:05 +000011AC_INIT([Valgrind],[3.8.0.SVN],[valgrind-users@lists.sourceforge.net])
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
bart417cf3e2011-10-22 09:21:24 +000013AC_CONFIG_HEADERS([config.h])
bart3a2dac02008-03-18 17:40:38 +000014AM_INIT_AUTOMAKE([foreign])
sewardjde4a1d02002-03-22 01:27:54 +000015
gobryb0ed4672002-03-27 20:58:58 +000016AM_MAINTAINER_MODE
17
njn7fd6d382009-01-22 21:56:32 +000018#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +000019# Checks for various programs.
20#----------------------------------------------------------------------------
bartaca399a2010-08-15 18:54:15 +000021CFLAGS="-Wno-long-long $CFLAGS"
gobrye721a522002-03-22 13:38:30 +000022
sewardjde4a1d02002-03-22 01:27:54 +000023AC_PROG_LN_S
24AC_PROG_CC
bart0affa492008-03-18 17:53:09 +000025AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000026AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000027AC_PROG_CXX
njn629a5ec2009-07-14 01:29:39 +000028# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
29# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
30# base (eg. most likely as Darwin-specific tests) we'll need one of the
31# following:
njn0cd26892009-07-12 23:07:13 +000032# - put AC_PROG_OBJC in a Darwin-specific part of this file
33# - Use AC_PROG_OBJC here and up the minimum autoconf version
34# - Use the following, which is apparently equivalent:
35# m4_ifdef([AC_PROG_OBJC],
36# [AC_PROG_OBJC],
37# [AC_CHECK_TOOL([OBJC], [gcc])
38# AC_SUBST([OBJC])
39# AC_SUBST([OBJCFLAGS])
40# ])
sewardjde4a1d02002-03-22 01:27:54 +000041AC_PROG_RANLIB
bart07de2c92010-05-29 06:44:28 +000042# provide a very basic definition for AC_PROG_SED if it's not provided by
43# autoconf (as e.g. in autoconf 2.59).
44m4_ifndef([AC_PROG_SED],
45 [AC_DEFUN([AC_PROG_SED],
46 [AC_ARG_VAR([SED])
47 AC_CHECK_PROGS([SED],[gsed sed])])])
bart12e91122010-05-15 08:37:24 +000048AC_PROG_SED
sewardjde4a1d02002-03-22 01:27:54 +000049
bartcddeaf52008-05-25 15:58:11 +000050# If no AR variable was specified, look up the name of the archiver. Otherwise
51# do not touch the AR variable.
52if test "x$AR" = "x"; then
bart07de2c92010-05-29 06:44:28 +000053 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
bartcddeaf52008-05-25 15:58:11 +000054fi
55AC_ARG_VAR([AR],[Archiver command])
56
gobrye721a522002-03-22 13:38:30 +000057# Check for the compiler support
58if test "${GCC}" != "yes" ; then
59 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
60fi
61
sewardj2f685952002-12-22 19:32:23 +000062# figure out where perl lives
63AC_PATH_PROG(PERL, perl)
64
njn9315df32003-04-16 20:50:50 +000065# figure out where gdb lives
sewardjf8722ca2008-11-17 00:20:45 +000066AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
njnfe408942004-11-23 17:52:24 +000067AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000068
daywalker48ccca52002-04-15 00:31:58 +000069# some older automake's don't have it so try something on our own
70ifdef([AM_PROG_AS],[AM_PROG_AS],
71[
gobry1be19852002-03-26 20:44:55 +000072AS="${CC}"
73AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000074
gobry1be19852002-03-26 20:44:55 +000075ASFLAGS=""
76AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000077])
gobry3b777892002-04-04 09:18:39 +000078
gobry3b777892002-04-04 09:18:39 +000079
njn0d2e58f2009-02-25 04:57:56 +000080# Check if 'diff' supports -u (universal diffs) and use it if possible.
81
82AC_MSG_CHECKING([for diff -u])
83AC_SUBST(DIFF)
84
sewardj6e9de462011-06-28 07:25:29 +000085# Comparing two identical files results in 0.
njn31f665e2009-02-26 21:25:50 +000086tmpfile="tmp-xxx-yyy-zzz"
87touch $tmpfile;
88if diff -u $tmpfile $tmpfile ; then
njn0d2e58f2009-02-25 04:57:56 +000089 AC_MSG_RESULT([yes])
90 DIFF="diff -u"
91else
92 AC_MSG_RESULT([no])
93 DIFF="diff"
94fi
njn31f665e2009-02-26 21:25:50 +000095rm $tmpfile
njn0d2e58f2009-02-25 04:57:56 +000096
97
sewardj535c50f2005-06-04 23:14:53 +000098# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +000099AC_MSG_CHECKING([for a supported version of gcc])
100
bart85037442011-11-22 14:41:31 +0000101# Obtain the compiler version.
sewardja8ca2c52011-09-29 18:18:37 +0000102#
bart85037442011-11-22 14:41:31 +0000103# A few examples of how the ${CC} --version output looks like:
104#
105# Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
106# Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
107# openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
108# Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
bartc5214062012-01-11 11:34:23 +0000109# MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
bart85037442011-11-22 14:41:31 +0000110# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
111# OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
112# Clang: clang version 2.9 (tags/RELEASE_29/final)
sewardja8ca2c52011-09-29 18:18:37 +0000113#
bartc5214062012-01-11 11:34:23 +0000114[
115 gcc_version=`${CC} -dumpversion 2>/dev/null`
116 if test "x$gcc_version" = x; then
117 gcc_version=`${CC} --version \
118 | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p' \
119 -e 's/[^ ]*clang version \([0-9.]*\).*$/\1/p'`
120 fi
121]
gobrye721a522002-03-22 13:38:30 +0000122
sewardj3ab7b662011-09-29 17:30:13 +0000123is_clang="notclang"
124if test "x`${CC} --version | head -n 1 | $SED 's/\(clang\) version.*/\1/'`" = "xclang" ; then
125 is_clang="clang"
126fi
127
128case "${is_clang}-${gcc_version}" in
129 notclang-3.*)
130 AC_MSG_RESULT([ok (${gcc_version})])
131 ;;
132 notclang-4.*)
133 AC_MSG_RESULT([ok (${gcc_version})])
134 ;;
135 clang-2.9)
136 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000137 ;;
gobrye721a522002-03-22 13:38:30 +0000138 *)
sewardj3ab7b662011-09-29 17:30:13 +0000139 AC_MSG_RESULT([no (${gcc_version})])
140 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000141 ;;
142esac
143
njn7fd6d382009-01-22 21:56:32 +0000144#----------------------------------------------------------------------------
145# Arch/OS/platform tests.
146#----------------------------------------------------------------------------
147# We create a number of arch/OS/platform-related variables. We prefix them
148# all with "VGCONF_" which indicates that they are defined at
149# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
150# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000151
sewardjde4a1d02002-03-22 01:27:54 +0000152AC_CANONICAL_HOST
153
154AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000155
njn7fd6d382009-01-22 21:56:32 +0000156# ARCH_MAX reflects the most that this CPU can do: for example if it
157# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
158# Ditto for amd64. It is used for more configuration below, but is not used
159# outside this file.
gobrye721a522002-03-22 13:38:30 +0000160case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000161 i?86)
162 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000163 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000164 ;;
165
njnfe408942004-11-23 17:52:24 +0000166 x86_64)
167 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000168 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000169 ;;
170
sewardj2c48c7b2005-11-29 13:05:56 +0000171 powerpc64)
172 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000173 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000174 ;;
175
176 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000177 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000178 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000179 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000180 ;;
181
sewardjb5b87402011-03-07 16:05:35 +0000182 s390x)
183 AC_MSG_RESULT([ok (${host_cpu})])
184 ARCH_MAX="s390x"
185 ;;
186
sewardj59570ff2010-01-01 11:59:33 +0000187 armv7*)
188 AC_MSG_RESULT([ok (${host_cpu})])
189 ARCH_MAX="arm"
190 ;;
191
sewardjde4a1d02002-03-22 01:27:54 +0000192 *)
193 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000194 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000195 ;;
196esac
197
njn7fd6d382009-01-22 21:56:32 +0000198#----------------------------------------------------------------------------
199
sewardj86e992f2006-01-28 18:39:09 +0000200# Sometimes it's convenient to subvert the bi-arch build system and
201# just have a single build even though the underlying platform is
202# capable of both. Hence handle --enable-only64bit and
203# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000204# [Actually, if either of these options are used, I think both get built,
205# but only one gets installed. So if you use an in-place build, both can be
206# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000207
208# Check if a 64-bit only build has been requested
209AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
210 [AC_ARG_ENABLE(only64bit,
211 [ --enable-only64bit do a 64-bit only build],
212 [vg_cv_only64bit=$enableval],
213 [vg_cv_only64bit=no])])
214
215# Check if a 32-bit only build has been requested
216AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
217 [AC_ARG_ENABLE(only32bit,
218 [ --enable-only32bit do a 32-bit only build],
219 [vg_cv_only32bit=$enableval],
220 [vg_cv_only32bit=no])])
221
222# Stay sane
223if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
224 AC_MSG_ERROR(
225 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
226fi
227
njn7fd6d382009-01-22 21:56:32 +0000228#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000229
njn311303f2009-02-06 03:46:50 +0000230# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
231# compilation of many C files via -VGO_$(VGCONF_OS) and
232# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000233AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000234AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000235
njnf76d27a2009-05-28 01:53:07 +0000236DEFAULT_SUPP=""
237
gobrye721a522002-03-22 13:38:30 +0000238case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000239 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000240 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000241 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000242
243 # Ok, this is linux. Check the kernel version
244 AC_MSG_CHECKING([for the kernel version])
245
246 kernel=`uname -r`
247
248 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000249 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000250 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
251 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x or Linux 3.x])
mueller8c68e042004-01-03 15:21:14 +0000252 ;;
253
254 2.4.*)
255 AC_MSG_RESULT([2.4 family (${kernel})])
256 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
257 ;;
258
mueller8c68e042004-01-03 15:21:14 +0000259 *)
260 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000261 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000262 ;;
263 esac
264
265 ;;
266
njnf76d27a2009-05-28 01:53:07 +0000267 *darwin*)
268 AC_MSG_RESULT([ok (${host_os})])
269 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000270 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
271 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
272 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
njnf76d27a2009-05-28 01:53:07 +0000273
274 AC_MSG_CHECKING([for the kernel version])
275 kernel=`uname -r`
276
277 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
278 # has only one relevant version, the OS version. The `uname` check
279 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000280 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
281 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000282 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000283 #
284 # XXX: `uname -r` won't do the right thing for cross-compiles, but
285 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000286 #
287 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
288 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
289 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
290 # time support for 10.5 (the 9.* pattern just below), I'll leave it
291 # in for now, just in case anybody wants to give it a try. But I'm
292 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000293 case "${kernel}" in
294 9.*)
295 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000296 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000297 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000298 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000299 ;;
njnea2d6fd2010-07-01 00:20:20 +0000300 10.*)
301 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
302 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
303 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
304 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
305 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000306 11.*)
307 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
308 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
309 # FIXME: change these to xx11.supp
310 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
311 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
312 ;;
313 *)
njnf76d27a2009-05-28 01:53:07 +0000314 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000315 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000316 ;;
317 esac
318 ;;
319
sewardjde4a1d02002-03-22 01:27:54 +0000320 *)
321 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000322 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000323 ;;
324esac
325
njn7fd6d382009-01-22 21:56:32 +0000326#----------------------------------------------------------------------------
327
tomd6398392006-06-07 17:44:36 +0000328# If we are building on a 64 bit platform test to see if the system
329# supports building 32 bit programs and disable 32 bit support if it
330# does not support building 32 bit programs
331
njn7fd6d382009-01-22 21:56:32 +0000332case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000333 amd64-linux|ppc64-linux)
334 AC_MSG_CHECKING([for 32 bit build support])
335 safe_CFLAGS=$CFLAGS
336 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000337 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000338 return 0;
bart417cf3e2011-10-22 09:21:24 +0000339 ]])], [
tomd6398392006-06-07 17:44:36 +0000340 AC_MSG_RESULT([yes])
341 ], [
342 vg_cv_only64bit="yes"
343 AC_MSG_RESULT([no])
344 ])
345 CFLAGS=$safe_CFLAGS;;
346esac
347
348if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
349 AC_MSG_ERROR(
350 [--enable-only32bit was specified but system does not support 32 bit builds])
351fi
nethercote888ecb72004-08-23 14:54:40 +0000352
njn7fd6d382009-01-22 21:56:32 +0000353#----------------------------------------------------------------------------
354
njn311303f2009-02-06 03:46:50 +0000355# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
356# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
357# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
358# above) will be "amd64" since that reflects the most that this cpu can do,
359# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
360# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000361# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
362# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
363AC_SUBST(VGCONF_ARCH_PRI)
364
njn3f8a6e92009-06-02 00:20:47 +0000365# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
366# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
367# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
368# It is empty if there is no secondary target.
369AC_SUBST(VGCONF_ARCH_SEC)
370
njn311303f2009-02-06 03:46:50 +0000371# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
372# The entire system, including regression and performance tests, will be
373# built for this target. The "_CAPS" indicates that the name is in capital
374# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000375# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000376# convention and cannot contain '-' characters. This is in contrast to
377# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000378AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
379
380# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
381# Valgrind and tools will also be built for this target, but not the
382# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000383#
njn7fd6d382009-01-22 21:56:32 +0000384# By default, the primary arch is the same as the "max" arch, as commented
385# above (at the definition of ARCH_MAX). We may choose to downgrade it in
386# the big case statement just below here, in the case where we're building
387# on a 64 bit machine but have been requested only to do a 32 bit build.
388AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
389
sewardj01262142006-01-04 01:20:28 +0000390AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000391
njnea2d6fd2010-07-01 00:20:20 +0000392# NB. The load address for a given platform may be specified in more
393# than one place, in some cases, depending on whether we're doing a biarch,
394# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
395# Be careful to give consistent values in all subcases. Also, all four
396# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
397# even if it is to "0xUNSET".
398#
njn7fd6d382009-01-22 21:56:32 +0000399case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000400 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000401 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000402 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000403 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
404 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000405 valt_load_address_pri_norml="0x38000000"
406 valt_load_address_pri_inner="0x28000000"
407 valt_load_address_sec_norml="0xUNSET"
408 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000409 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000410 ;;
411 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000412 valt_load_address_sec_norml="0xUNSET"
413 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000414 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000415 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000416 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000417 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
418 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000419 valt_load_address_pri_norml="0x38000000"
420 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000421 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000422 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000423 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000424 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
425 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000426 valt_load_address_pri_norml="0x38000000"
427 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000428 else
njn7fd6d382009-01-22 21:56:32 +0000429 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000430 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000431 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
432 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000433 valt_load_address_pri_norml="0x38000000"
434 valt_load_address_pri_inner="0x28000000"
435 valt_load_address_sec_norml="0x38000000"
436 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000437 fi
njn377c43f2009-05-19 07:39:22 +0000438 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000439 ;;
440 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000441 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000442 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000443 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
444 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000445 valt_load_address_pri_norml="0x38000000"
446 valt_load_address_pri_inner="0x28000000"
447 valt_load_address_sec_norml="0xUNSET"
448 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000449 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000450 ;;
451 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000452 valt_load_address_sec_norml="0xUNSET"
453 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000454 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000455 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000456 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000457 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
458 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000459 valt_load_address_pri_norml="0x38000000"
460 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000461 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000462 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000463 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000464 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
465 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000466 valt_load_address_pri_norml="0x38000000"
467 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000468 else
njn7fd6d382009-01-22 21:56:32 +0000469 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000470 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000471 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
472 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000473 valt_load_address_pri_norml="0x38000000"
474 valt_load_address_pri_inner="0x28000000"
475 valt_load_address_sec_norml="0x38000000"
476 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000477 fi
njn377c43f2009-05-19 07:39:22 +0000478 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000479 ;;
njncc58cea2010-07-05 07:21:22 +0000480 # Darwin gets identified as 32-bit even when it supports 64-bit.
481 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
482 # all Macs support both 32-bit and 64-bit, so we just build both. If
483 # someone has a really old 32-bit only machine they can (hopefully?)
484 # build with --enable-only32bit. See bug 243362.
485 x86-darwin|amd64-darwin)
486 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000487 valt_load_address_sec_norml="0xUNSET"
488 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000489 if test x$vg_cv_only64bit = xyes; then
490 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000491 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000492 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
493 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000494 valt_load_address_pri_norml="0x138000000"
495 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000496 elif test x$vg_cv_only32bit = xyes; then
497 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000498 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000499 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
500 VGCONF_PLATFORM_SEC_CAPS=""
501 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000502 valt_load_address_pri_norml="0x38000000"
503 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000504 else
505 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000506 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000507 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
508 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000509 valt_load_address_pri_norml="0x138000000"
510 valt_load_address_pri_inner="0x128000000"
511 valt_load_address_sec_norml="0x38000000"
512 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000513 fi
njnf76d27a2009-05-28 01:53:07 +0000514 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
515 ;;
sewardj59570ff2010-01-01 11:59:33 +0000516 arm-linux)
517 VGCONF_ARCH_PRI="arm"
518 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
519 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000520 valt_load_address_pri_norml="0x38000000"
521 valt_load_address_pri_inner="0x28000000"
522 valt_load_address_sec_norml="0xUNSET"
523 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000524 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
525 ;;
sewardjb5b87402011-03-07 16:05:35 +0000526 s390x-linux)
527 VGCONF_ARCH_PRI="s390x"
528 VGCONF_ARCH_SEC=""
529 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
530 VGCONF_PLATFORM_SEC_CAPS=""
531 # we want to have the generated code close to the dispatcher
532 valt_load_address_pri_norml="0x401000000"
533 valt_load_address_pri_inner="0x410000000"
534 valt_load_address_sec_norml="0xUNSET"
535 valt_load_address_sec_inner="0xUNSET"
536 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
537 ;;
nethercote888ecb72004-08-23 14:54:40 +0000538 *)
njn7fd6d382009-01-22 21:56:32 +0000539 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000540 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000541 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
542 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000543 valt_load_address_pri_norml="0xUNSET"
544 valt_load_address_pri_inner="0xUNSET"
545 valt_load_address_sec_norml="0xUNSET"
546 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000547 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000548 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000549 ;;
550esac
sewardjde4a1d02002-03-22 01:27:54 +0000551
njn7fd6d382009-01-22 21:56:32 +0000552#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000553
njn7fd6d382009-01-22 21:56:32 +0000554# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
555# defined.
556AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
557 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000558 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
559 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
560 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000561AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000562 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
563 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000564AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
565 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000566 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000567AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000568 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000569AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
570 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000571AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
572 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000573
njn7fd6d382009-01-22 21:56:32 +0000574# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
575# become defined.
576AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
577 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
578 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
579AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
580 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
581AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
582 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
583 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
584AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
585 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000586AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
587 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000588AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
589 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
590 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000591
njnf76d27a2009-05-28 01:53:07 +0000592AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
593 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
594 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
595AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
596 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
597
598
sewardj72a2d802010-07-29 05:24:20 +0000599# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000600# Relies on the assumption that the primary and secondary targets are
601# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000602AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
603 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
604 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
605 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000606 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000607 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
608 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000609AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
610 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
611 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000612
613
njn7fd6d382009-01-22 21:56:32 +0000614# Sometimes, in the Makefile.am files, it's useful to know whether or not
615# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000616AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000617 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000618
tomb637bad2005-11-08 12:28:35 +0000619
njn7fd6d382009-01-22 21:56:32 +0000620#----------------------------------------------------------------------------
621# Inner Valgrind?
622#----------------------------------------------------------------------------
623
njnd74b0ef2009-01-20 06:06:52 +0000624# Check if this should be built as an inner Valgrind, to be run within
625# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000626AC_SUBST(VALT_LOAD_ADDRESS_PRI)
627AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000628AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
629 [AC_ARG_ENABLE(inner,
630 [ --enable-inner enables self-hosting],
631 [vg_cv_inner=$enableval],
632 [vg_cv_inner=no])])
633if test "$vg_cv_inner" = yes; then
634 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000635 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
636 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000637else
njnea2d6fd2010-07-01 00:20:20 +0000638 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
639 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000640fi
641
642
njn7fd6d382009-01-22 21:56:32 +0000643#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000644# Extra fine-tuning of installation directories
645#----------------------------------------------------------------------------
646AC_ARG_WITH(tmpdir,
647 [ --with-tmpdir=PATH Specify path for temporary files],
648 tmpdir="$withval",
649 tmpdir="/tmp")
650AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
651
sewardj0ba37c92011-07-12 11:46:24 +0000652
sewardjcb495c82011-07-11 20:42:34 +0000653#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000654# Libc and suppressions
655#----------------------------------------------------------------------------
656# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000657AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000658
bart12e91122010-05-15 08:37:24 +0000659AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000660
bart12e91122010-05-15 08:37:24 +0000661if test x$ac_cv_header_features_h = xyes; then
662 rm -f conftest.$ac_ext
663 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000664#include <features.h>
bart12e91122010-05-15 08:37:24 +0000665#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
666glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000667#endif
bart12e91122010-05-15 08:37:24 +0000668_ACEOF
669 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
670fi
bartb7c3f082010-05-13 06:32:36 +0000671
njnf76d27a2009-05-28 01:53:07 +0000672# not really a version check
673AC_EGREP_CPP([DARWIN_LIBC], [
674#include <sys/cdefs.h>
675#if defined(__DARWIN_VERS_1050)
676 DARWIN_LIBC
677#endif
678],
679GLIBC_VERSION="darwin")
680
sewardjcb495c82011-07-11 20:42:34 +0000681# not really a version check
682AC_EGREP_CPP([BIONIC_LIBC], [
683#if defined(__ANDROID__)
684 BIONIC_LIBC
685#endif
686],
687GLIBC_VERSION="bionic")
688
689
dirk07596a22008-04-25 11:33:30 +0000690AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000691
dirk07596a22008-04-25 11:33:30 +0000692case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000693 2.2)
694 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000695 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000696 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
697 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000698 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000699 ;;
700
sewardj08c7f012002-10-07 23:56:55 +0000701 2.3)
702 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000703 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000704 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000705 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000706 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000707 ;;
708
njn781dba52005-06-30 04:06:38 +0000709 2.4)
710 AC_MSG_RESULT(2.4 family)
711 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000712 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000713 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000714 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000715 ;;
716
dirkaece45c2006-10-12 08:17:49 +0000717 2.5)
718 AC_MSG_RESULT(2.5 family)
719 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000720 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000721 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000722 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000723 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000724 2.6)
725 AC_MSG_RESULT(2.6 family)
726 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000727 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000728 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000729 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000730 ;;
731 2.7)
732 AC_MSG_RESULT(2.7 family)
733 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000734 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000735 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000736 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000737 ;;
dirk07596a22008-04-25 11:33:30 +0000738 2.8)
739 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000740 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000741 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
742 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
743 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
744 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000745 2.9)
746 AC_MSG_RESULT(2.9 family)
747 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
748 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
749 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
750 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
751 ;;
sewardj5d425e82009-02-01 19:01:11 +0000752 2.10)
753 AC_MSG_RESULT(2.10 family)
754 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
755 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
756 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
757 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
758 ;;
bart0fac7ff2009-11-15 19:11:19 +0000759 2.11)
760 AC_MSG_RESULT(2.11 family)
761 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
762 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
763 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
764 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000765 ;;
766 2.12)
767 AC_MSG_RESULT(2.12 family)
768 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
769 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
770 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
771 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000772 ;;
tomebd619b2011-02-10 09:09:09 +0000773 2.13)
774 AC_MSG_RESULT(2.13 family)
775 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
776 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
777 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
778 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
779 ;;
tomcc077412011-06-07 21:52:26 +0000780 2.14)
781 AC_MSG_RESULT(2.14 family)
782 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
783 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
784 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
785 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
786 ;;
dirke75fdeb2011-12-29 08:24:55 +0000787 2.15)
788 AC_MSG_RESULT(2.15 family)
789 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
790 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
791 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
792 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
793 ;;
njnf76d27a2009-05-28 01:53:07 +0000794 darwin)
795 AC_MSG_RESULT(Darwin)
796 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
797 # DEFAULT_SUPP set by kernel version check above.
798 ;;
sewardjcb495c82011-07-11 20:42:34 +0000799 bionic)
800 AC_MSG_RESULT(Bionic)
801 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
802 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
803 ;;
dirkaece45c2006-10-12 08:17:49 +0000804
sewardjde4a1d02002-03-22 01:27:54 +0000805 *)
bart12e91122010-05-15 08:37:24 +0000806 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
dirke75fdeb2011-12-29 08:24:55 +0000807 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.15])
njnf76d27a2009-05-28 01:53:07 +0000808 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000809 ;;
810esac
811
dirk07596a22008-04-25 11:33:30 +0000812AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000813
sewardj414f3582008-07-18 20:46:00 +0000814
815# Add default suppressions for the X client libraries. Make no
816# attempt to detect whether such libraries are installed on the
817# build machine (or even if any X facilities are present); just
818# add the suppressions antidisirregardless.
819DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
820DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000821
sewardjd2f95a02011-05-11 16:04:28 +0000822# Add glibc and X11 suppressions for exp-sgcheck
823DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000824
sewardj2e10a682003-04-07 19:36:41 +0000825
njn7fd6d382009-01-22 21:56:32 +0000826#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000827# Platform variants?
828#----------------------------------------------------------------------------
829
830# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
831# But there are times where we need a bit more control. The motivating
832# and currently only case is Android: this is almost identical to arm-linux,
833# but not quite. So this introduces the concept of platform variant tags,
834# which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
835# with the main -DVGP_<arch>_<os> definition.
836#
837# In almost all cases, the <variant> bit is "vanilla". But for Android
838# it is "android" instead.
839#
840# Consequently (eg), plain arm-linux would build with
841#
842# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
843#
844# whilst an Android build would have
845#
846# -DVGP_arm_linux -DVGPV_arm_linux_android
847#
848# The setup of the platform variant is pushed relatively far down this
849# file in order that we can inspect any of the variables set above.
850
851# In the normal case ..
852VGCONF_PLATVARIANT="vanilla"
853
854# Android on ARM ?
855if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
856 -a "$GLIBC_VERSION" = "bionic";
857then
858 VGCONF_PLATVARIANT="android"
859fi
860
861AC_SUBST(VGCONF_PLATVARIANT)
862
863
864# FIXME: do we also want to define automake variables
865# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
866# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
867# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
868# do that. Problem is that we can't do and-ing in Makefile.am's, but
869# that's what we'd need to do to use this, since what we'd want to write
870# is something like
871#
872# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
873#
sewardj0ba37c92011-07-12 11:46:24 +0000874# Hmm. Can't think of a nice clean solution to this.
875
876AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
877 test x$VGCONF_PLATVARIANT = xvanilla)
878AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
879 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000880
881
882#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000883# Checking for various library functions and other definitions
884#----------------------------------------------------------------------------
885
bart59e2f182008-04-28 16:22:53 +0000886# Check for CLOCK_MONOTONIC
887
888AC_MSG_CHECKING([for CLOCK_MONOTONIC])
889
bart417cf3e2011-10-22 09:21:24 +0000890AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +0000891#include <time.h>
bart417cf3e2011-10-22 09:21:24 +0000892]], [[
bart59e2f182008-04-28 16:22:53 +0000893 struct timespec t;
894 clock_gettime(CLOCK_MONOTONIC, &t);
895 return 0;
bart417cf3e2011-10-22 09:21:24 +0000896]])], [
bart59e2f182008-04-28 16:22:53 +0000897AC_MSG_RESULT([yes])
898AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
899 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
900], [
901AC_MSG_RESULT([no])
902])
903
bartfea06922008-05-03 09:12:15 +0000904
sewardj0c09bf02011-07-11 22:11:58 +0000905# Check for PTHREAD_RWLOCK_T
906
907AC_MSG_CHECKING([for pthread_rwlock_t])
908
bart417cf3e2011-10-22 09:21:24 +0000909AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +0000910#define _GNU_SOURCE
911#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000912]], [[
sewardj0c09bf02011-07-11 22:11:58 +0000913 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +0000914]])], [
sewardj0c09bf02011-07-11 22:11:58 +0000915AC_MSG_RESULT([yes])
916AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
917 [Define to 1 if you have the `pthread_rwlock_t' type.])
918], [
919AC_MSG_RESULT([no])
920])
921
922
bartfea06922008-05-03 09:12:15 +0000923# Check for PTHREAD_MUTEX_ADAPTIVE_NP
924
925AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
926
bart417cf3e2011-10-22 09:21:24 +0000927AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000928#define _GNU_SOURCE
929#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000930]], [[
bartfea06922008-05-03 09:12:15 +0000931 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000932]])], [
bartfea06922008-05-03 09:12:15 +0000933AC_MSG_RESULT([yes])
934AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
935 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
936], [
937AC_MSG_RESULT([no])
938])
939
940
941# Check for PTHREAD_MUTEX_ERRORCHECK_NP
942
943AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
944
bart417cf3e2011-10-22 09:21:24 +0000945AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000946#define _GNU_SOURCE
947#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000948]], [[
bartfea06922008-05-03 09:12:15 +0000949 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +0000950]])], [
bartfea06922008-05-03 09:12:15 +0000951AC_MSG_RESULT([yes])
952AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
953 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
954], [
955AC_MSG_RESULT([no])
956])
957
958
959# Check for PTHREAD_MUTEX_RECURSIVE_NP
960
961AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
962
bart417cf3e2011-10-22 09:21:24 +0000963AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000964#define _GNU_SOURCE
965#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000966]], [[
bartfea06922008-05-03 09:12:15 +0000967 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000968]])], [
bartfea06922008-05-03 09:12:15 +0000969AC_MSG_RESULT([yes])
970AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
971 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
972], [
973AC_MSG_RESULT([no])
974])
975
976
977# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
978
979AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
980
bart417cf3e2011-10-22 09:21:24 +0000981AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000982#define _GNU_SOURCE
983#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000984]], [[
bartfea06922008-05-03 09:12:15 +0000985 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
986 return 0;
bart417cf3e2011-10-22 09:21:24 +0000987]])], [
bartfea06922008-05-03 09:12:15 +0000988AC_MSG_RESULT([yes])
989AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
990 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
991], [
992AC_MSG_RESULT([no])
993])
994
995
bart5e389f12008-04-05 12:53:15 +0000996# Check whether pthread_mutex_t has a member called __m_kind.
997
bartb11355c2010-04-29 16:37:26 +0000998AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
999 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1000 1,
1001 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1002 ],
1003 [],
1004 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001005
1006
1007# Check whether pthread_mutex_t has a member called __data.__kind.
1008
bartb11355c2010-04-29 16:37:26 +00001009AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1010 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1011 1,
1012 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1013 ],
1014 [],
1015 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001016
1017
bart62c370e2008-05-12 18:50:51 +00001018# does this compiler support -maltivec and does it have the include file
1019# <altivec.h> ?
1020
1021AC_MSG_CHECKING([for Altivec])
1022
1023safe_CFLAGS=$CFLAGS
1024CFLAGS="-maltivec"
1025
bart417cf3e2011-10-22 09:21:24 +00001026AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001027#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001028]], [[
bart62c370e2008-05-12 18:50:51 +00001029 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001030]])], [
bart62c370e2008-05-12 18:50:51 +00001031ac_have_altivec=yes
1032AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001033AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001034 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001035], [
1036ac_have_altivec=no
1037AC_MSG_RESULT([no])
1038])
1039CFLAGS=$safe_CFLAGS
1040
sewardj0e342a02010-09-03 23:49:33 +00001041AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001042
1043
sewardjf34eb492011-04-15 11:57:05 +00001044# Check that both: the compiler supports -mvsx and that the assembler
1045# understands VSX instructions. If either of those doesn't work,
1046# conclude that we can't do VSX. NOTE: basically this is a kludge
1047# in that it conflates two things that should be separate -- whether
1048# the compiler understands the flag vs whether the assembler
1049# understands the opcodes. This really ought to be cleaned up
1050# and done properly, like it is for x86/x86_64.
1051
1052AC_MSG_CHECKING([for VSX])
1053
1054safe_CFLAGS=$CFLAGS
1055CFLAGS="-mvsx"
1056
bart417cf3e2011-10-22 09:21:24 +00001057AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001058#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001059]], [[
sewardjf34eb492011-04-15 11:57:05 +00001060 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001061 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001062]])], [
sewardjf34eb492011-04-15 11:57:05 +00001063ac_have_vsx=yes
1064AC_MSG_RESULT([yes])
1065], [
1066ac_have_vsx=no
1067AC_MSG_RESULT([no])
1068])
1069CFLAGS=$safe_CFLAGS
1070
1071AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1072
sewardjb0ccb4d2012-04-02 10:22:05 +00001073AC_MSG_CHECKING([that assembler knows DFP])
1074
1075AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1076]], [[
1077 __asm__ __volatile__("dadd 1, 2, 3");
1078]])], [
1079ac_asm_have_dfp=yes
1080AC_MSG_RESULT([yes])
1081], [
1082ac_asm_have_dfp=no
1083AC_MSG_RESULT([no])
1084])
1085
1086AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1087safe_CFLAGS=$CFLAGS
1088CFLAGS="-mhard-dfp"
1089AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1090]], [[
1091 __asm__ __volatile__("dadd 1, 2, 3");
1092]])], [
1093ac_gcc_have_dfp=yes
1094AC_MSG_RESULT([yes])
1095], [
1096ac_gcc_have_dfp=no
1097AC_MSG_RESULT([no])
1098])
1099
1100-----
1101CFLAGS=$safe_CFLAGS
1102
1103AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001104
bart36dd85a2009-04-26 07:11:48 +00001105# Check for pthread_create@GLIBC2.0
1106AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1107
bart16e1c5a2009-04-26 07:38:53 +00001108safe_CFLAGS=$CFLAGS
1109CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001110AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001111extern int pthread_create_glibc_2_0(void*, const void*,
1112 void *(*)(void*), void*);
1113__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001114]], [[
bart276ed3a2009-05-10 15:41:45 +00001115#ifdef __powerpc__
1116/*
1117 * Apparently on PowerPC linking this program succeeds and generates an
1118 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1119 */
1120#error This test does not work properly on PowerPC.
1121#else
bart16e1c5a2009-04-26 07:38:53 +00001122 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001123#endif
bart16e1c5a2009-04-26 07:38:53 +00001124 return 0;
bart417cf3e2011-10-22 09:21:24 +00001125]])], [
bart36dd85a2009-04-26 07:11:48 +00001126ac_have_pthread_create_glibc_2_0=yes
1127AC_MSG_RESULT([yes])
1128AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1129 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1130], [
1131ac_have_pthread_create_glibc_2_0=no
1132AC_MSG_RESULT([no])
1133])
bart16e1c5a2009-04-26 07:38:53 +00001134CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001135
1136AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001137 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001138
1139
barta50aa8a2008-04-27 06:06:57 +00001140# Check for eventfd_t, eventfd() and eventfd_read()
1141AC_MSG_CHECKING([for eventfd()])
1142
bart417cf3e2011-10-22 09:21:24 +00001143AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001144#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001145]], [[
barta50aa8a2008-04-27 06:06:57 +00001146 eventfd_t ev;
1147 int fd;
1148
1149 fd = eventfd(5, 0);
1150 eventfd_read(fd, &ev);
1151 return 0;
bart417cf3e2011-10-22 09:21:24 +00001152]])], [
barta50aa8a2008-04-27 06:06:57 +00001153AC_MSG_RESULT([yes])
1154AC_DEFINE([HAVE_EVENTFD], 1,
1155 [Define to 1 if you have the `eventfd' function.])
1156AC_DEFINE([HAVE_EVENTFD_READ], 1,
1157 [Define to 1 if you have the `eventfd_read' function.])
1158], [
1159AC_MSG_RESULT([no])
1160])
1161
1162
njn7fd6d382009-01-22 21:56:32 +00001163#----------------------------------------------------------------------------
1164# Checking for supported compiler flags.
1165#----------------------------------------------------------------------------
1166
sewardj535c50f2005-06-04 23:14:53 +00001167# does this compiler support -m32 ?
1168AC_MSG_CHECKING([if gcc accepts -m32])
1169
1170safe_CFLAGS=$CFLAGS
1171CFLAGS="-m32"
1172
bart417cf3e2011-10-22 09:21:24 +00001173AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001174 return 0;
bart417cf3e2011-10-22 09:21:24 +00001175]])], [
sewardj535c50f2005-06-04 23:14:53 +00001176FLAG_M32="-m32"
1177AC_MSG_RESULT([yes])
1178], [
1179FLAG_M32=""
1180AC_MSG_RESULT([no])
1181])
1182CFLAGS=$safe_CFLAGS
1183
1184AC_SUBST(FLAG_M32)
1185
1186
sewardj01262142006-01-04 01:20:28 +00001187# does this compiler support -m64 ?
1188AC_MSG_CHECKING([if gcc accepts -m64])
1189
1190safe_CFLAGS=$CFLAGS
1191CFLAGS="-m64"
1192
bart417cf3e2011-10-22 09:21:24 +00001193AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001194 return 0;
bart417cf3e2011-10-22 09:21:24 +00001195]])], [
sewardj01262142006-01-04 01:20:28 +00001196FLAG_M64="-m64"
1197AC_MSG_RESULT([yes])
1198], [
1199FLAG_M64=""
1200AC_MSG_RESULT([no])
1201])
1202CFLAGS=$safe_CFLAGS
1203
1204AC_SUBST(FLAG_M64)
1205
1206
sewardj67f1fcc2005-07-03 10:41:02 +00001207# does this compiler support -mmmx ?
1208AC_MSG_CHECKING([if gcc accepts -mmmx])
1209
1210safe_CFLAGS=$CFLAGS
1211CFLAGS="-mmmx"
1212
bart417cf3e2011-10-22 09:21:24 +00001213AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001214 return 0;
bart417cf3e2011-10-22 09:21:24 +00001215]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001216FLAG_MMMX="-mmmx"
1217AC_MSG_RESULT([yes])
1218], [
1219FLAG_MMMX=""
1220AC_MSG_RESULT([no])
1221])
1222CFLAGS=$safe_CFLAGS
1223
1224AC_SUBST(FLAG_MMMX)
1225
1226
1227# does this compiler support -msse ?
1228AC_MSG_CHECKING([if gcc accepts -msse])
1229
1230safe_CFLAGS=$CFLAGS
1231CFLAGS="-msse"
1232
bart417cf3e2011-10-22 09:21:24 +00001233AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001234 return 0;
bart417cf3e2011-10-22 09:21:24 +00001235]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001236FLAG_MSSE="-msse"
1237AC_MSG_RESULT([yes])
1238], [
1239FLAG_MSSE=""
1240AC_MSG_RESULT([no])
1241])
1242CFLAGS=$safe_CFLAGS
1243
1244AC_SUBST(FLAG_MSSE)
1245
1246
sewardj5b754b42002-06-03 22:53:35 +00001247# does this compiler support -mpreferred-stack-boundary=2 ?
1248AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1249
daywalker3664f562003-10-17 13:43:46 +00001250safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001251CFLAGS="-mpreferred-stack-boundary=2"
1252
bart417cf3e2011-10-22 09:21:24 +00001253AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001254 return 0;
bart417cf3e2011-10-22 09:21:24 +00001255]])], [
sewardj5b754b42002-06-03 22:53:35 +00001256PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001257AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001258], [
1259PREFERRED_STACK_BOUNDARY=""
1260AC_MSG_RESULT([no])
1261])
daywalker3664f562003-10-17 13:43:46 +00001262CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001263
1264AC_SUBST(PREFERRED_STACK_BOUNDARY)
1265
sewardj535c50f2005-06-04 23:14:53 +00001266
sewardjb5f6f512005-03-10 23:59:00 +00001267# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001268AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001269
1270safe_CFLAGS=$CFLAGS
1271CFLAGS="-Wno-pointer-sign"
1272
bart417cf3e2011-10-22 09:21:24 +00001273AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001274 return 0;
bart417cf3e2011-10-22 09:21:24 +00001275]])], [
sewardjb5f6f512005-03-10 23:59:00 +00001276no_pointer_sign=yes
1277AC_MSG_RESULT([yes])
1278], [
1279no_pointer_sign=no
1280AC_MSG_RESULT([no])
1281])
1282CFLAGS=$safe_CFLAGS
1283
1284if test x$no_pointer_sign = xyes; then
1285 CFLAGS="$CFLAGS -Wno-pointer-sign"
1286fi
1287
sewardj535c50f2005-06-04 23:14:53 +00001288
barte026bd22009-07-04 12:17:07 +00001289# does this compiler support -Wno-empty-body ?
1290
1291AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1292
1293safe_CFLAGS=$CFLAGS
1294CFLAGS="-Wno-empty-body"
1295
bart417cf3e2011-10-22 09:21:24 +00001296AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001297 return 0;
bart417cf3e2011-10-22 09:21:24 +00001298]])], [
barte026bd22009-07-04 12:17:07 +00001299AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1300AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001301], [
barte026bd22009-07-04 12:17:07 +00001302AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1303AC_MSG_RESULT([no])
1304])
1305CFLAGS=$safe_CFLAGS
1306
1307
bart9d865fa2008-06-23 12:11:49 +00001308# does this compiler support -Wno-format-zero-length ?
1309
1310AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1311
1312safe_CFLAGS=$CFLAGS
1313CFLAGS="-Wno-format-zero-length"
1314
bart417cf3e2011-10-22 09:21:24 +00001315AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001316 return 0;
bart417cf3e2011-10-22 09:21:24 +00001317]])], [
bart9d865fa2008-06-23 12:11:49 +00001318AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1319AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001320], [
bart9d865fa2008-06-23 12:11:49 +00001321AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1322AC_MSG_RESULT([no])
1323])
1324CFLAGS=$safe_CFLAGS
1325
1326
bart8e216312011-05-15 17:05:36 +00001327# does this compiler support -Wno-nonnull ?
1328
1329AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1330
1331safe_CFLAGS=$CFLAGS
1332CFLAGS="-Wno-nonnull"
1333
bart417cf3e2011-10-22 09:21:24 +00001334AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001335 return 0;
bart417cf3e2011-10-22 09:21:24 +00001336]])], [
bart8e216312011-05-15 17:05:36 +00001337AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1338AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001339], [
bart8e216312011-05-15 17:05:36 +00001340AC_SUBST([FLAG_W_NO_NONNULL], [])
1341AC_MSG_RESULT([no])
1342])
1343CFLAGS=$safe_CFLAGS
1344
1345
1346# does this compiler support -Wno-overflow ?
1347
1348AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1349
1350safe_CFLAGS=$CFLAGS
1351CFLAGS="-Wno-overflow"
1352
bart417cf3e2011-10-22 09:21:24 +00001353AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001354 return 0;
bart417cf3e2011-10-22 09:21:24 +00001355]])], [
bart8e216312011-05-15 17:05:36 +00001356AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1357AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001358], [
bart8e216312011-05-15 17:05:36 +00001359AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1360AC_MSG_RESULT([no])
1361])
1362CFLAGS=$safe_CFLAGS
1363
1364
bartbf9b85c2009-08-12 12:55:56 +00001365# does this compiler support -Wno-uninitialized ?
1366
1367AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1368
1369safe_CFLAGS=$CFLAGS
1370CFLAGS="-Wno-uninitialized"
1371
bart417cf3e2011-10-22 09:21:24 +00001372AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001373 return 0;
bart417cf3e2011-10-22 09:21:24 +00001374]])], [
bartbf9b85c2009-08-12 12:55:56 +00001375AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1376AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001377], [
bartbf9b85c2009-08-12 12:55:56 +00001378AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1379AC_MSG_RESULT([no])
1380])
1381CFLAGS=$safe_CFLAGS
1382
1383
bart56730cd2008-05-11 06:41:46 +00001384# does this compiler support -Wextra or the older -W ?
1385
1386AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1387
1388safe_CFLAGS=$CFLAGS
1389CFLAGS="-Wextra"
1390
bart417cf3e2011-10-22 09:21:24 +00001391AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001392 return 0;
bart417cf3e2011-10-22 09:21:24 +00001393]])], [
bart56730cd2008-05-11 06:41:46 +00001394AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1395AC_MSG_RESULT([-Wextra])
1396], [
1397 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001398 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001399 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001400 ]])], [
bart56730cd2008-05-11 06:41:46 +00001401 AC_SUBST([FLAG_W_EXTRA], [-W])
1402 AC_MSG_RESULT([-W])
1403 ], [
1404 AC_SUBST([FLAG_W_EXTRA], [])
1405 AC_MSG_RESULT([not supported])
1406 ])
1407])
1408CFLAGS=$safe_CFLAGS
1409
1410
sewardja72c26d2007-05-01 13:44:08 +00001411# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001412AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001413
1414safe_CFLAGS=$CFLAGS
1415CFLAGS="-fno-stack-protector"
1416
bart417cf3e2011-10-22 09:21:24 +00001417AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001418 return 0;
bart417cf3e2011-10-22 09:21:24 +00001419]])], [
sewardja72c26d2007-05-01 13:44:08 +00001420no_stack_protector=yes
1421FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1422AC_MSG_RESULT([yes])
1423], [
1424no_stack_protector=no
1425FLAG_FNO_STACK_PROTECTOR=""
1426AC_MSG_RESULT([no])
1427])
1428CFLAGS=$safe_CFLAGS
1429
1430AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1431
1432if test x$no_stack_protector = xyes; then
1433 CFLAGS="$CFLAGS -fno-stack-protector"
1434fi
1435
1436
bart56730cd2008-05-11 06:41:46 +00001437# does this compiler support --param inline-unit-growth=... ?
1438
1439AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1440
1441safe_CFLAGS=$CFLAGS
1442CFLAGS="--param inline-unit-growth=900"
1443
bart417cf3e2011-10-22 09:21:24 +00001444AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001445 return 0;
bart417cf3e2011-10-22 09:21:24 +00001446]])], [
bart56730cd2008-05-11 06:41:46 +00001447AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1448 ["--param inline-unit-growth=900"])
1449AC_MSG_RESULT([yes])
1450], [
1451AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1452AC_MSG_RESULT([no])
1453])
1454CFLAGS=$safe_CFLAGS
1455
1456
sewardjd3645802010-06-13 22:13:58 +00001457# does the linker support -Wl,--build-id=none ? Note, it's
1458# important that we test indirectly via whichever C compiler
1459# is selected, rather than testing /usr/bin/ld or whatever
1460# directly.
bart699fbac2010-06-08 18:23:59 +00001461
sewardjd3645802010-06-13 22:13:58 +00001462AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001463
1464safe_CFLAGS=$CFLAGS
1465CFLAGS="-Wl,--build-id=none"
1466
bart8508c752010-06-10 06:26:21 +00001467AC_LINK_IFELSE(
1468[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001469[
1470 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1471 AC_MSG_RESULT([yes])
1472], [
1473 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1474 AC_MSG_RESULT([no])
1475])
1476CFLAGS=$safe_CFLAGS
1477
1478
sewardj00f1e622006-03-12 16:47:10 +00001479# does the ppc assembler support "mtocrf" et al?
1480AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1481
bart417cf3e2011-10-22 09:21:24 +00001482AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001483__asm__ __volatile__("mtocrf 4,0");
1484__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001485]])], [
sewardj00f1e622006-03-12 16:47:10 +00001486ac_have_as_ppc_mftocrf=yes
1487AC_MSG_RESULT([yes])
1488], [
1489ac_have_as_ppc_mftocrf=no
1490AC_MSG_RESULT([no])
1491])
1492if test x$ac_have_as_ppc_mftocrf = xyes ; then
1493 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1494fi
1495
1496
sewardjb5b87402011-03-07 16:05:35 +00001497CFLAGS=$safe_CFLAGS
1498
sewardjf0aabf82007-03-22 00:24:21 +00001499# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001500# Note, this doesn't generate a C-level symbol. It generates a
1501# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001502AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1503
bart417cf3e2011-10-22 09:21:24 +00001504AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001505 do { long long int x;
1506 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1507 while (0)
bart417cf3e2011-10-22 09:21:24 +00001508]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001509ac_have_as_sse3=yes
1510AC_MSG_RESULT([yes])
1511], [
1512ac_have_as_sse3=no
1513AC_MSG_RESULT([no])
1514])
sewardjfa18a262007-03-22 12:13:13 +00001515
1516AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001517
1518
sewardj6d6da5b2008-02-09 12:07:40 +00001519# Ditto for SSSE3 instructions (note extra S)
1520# Note, this doesn't generate a C-level symbol. It generates a
1521# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1522AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1523
florianc443b962011-10-28 21:37:19 +00001524save_CFLAGS="$CFLAGS"
1525CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001526AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001527 do { long long int x;
1528 __asm__ __volatile__(
1529 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1530 while (0)
bart417cf3e2011-10-22 09:21:24 +00001531]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001532ac_have_as_ssse3=yes
1533AC_MSG_RESULT([yes])
1534], [
1535ac_have_as_ssse3=no
1536AC_MSG_RESULT([no])
1537])
florianc443b962011-10-28 21:37:19 +00001538CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001539
1540AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1541
1542
sewardj27d176a2011-01-17 11:15:48 +00001543# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1544# Note, this doesn't generate a C-level symbol. It generates a
1545# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001546AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001547AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001548 do {
1549 __asm__ __volatile__(
1550 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1551 while (0)
bart417cf3e2011-10-22 09:21:24 +00001552]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001553ac_have_as_pclmulqdq=yes
1554AC_MSG_RESULT([yes])
1555], [
1556ac_have_as_pclmulqdq=no
1557AC_MSG_RESULT([no])
1558])
1559
1560AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1561
1562
sewardj27d176a2011-01-17 11:15:48 +00001563# does the x86/amd64 assembler understand the LZCNT instruction?
1564# Note, this doesn't generate a C-level symbol. It generates a
1565# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001566AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1567
bart417cf3e2011-10-22 09:21:24 +00001568AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00001569 do {
1570 __asm__ __volatile__("lzcnt %rax,%rax");
1571 } while (0)
bart417cf3e2011-10-22 09:21:24 +00001572]])], [
bart55e438b2010-09-14 10:53:57 +00001573 ac_have_as_lzcnt=yes
1574 AC_MSG_RESULT([yes])
1575], [
1576 ac_have_as_lzcnt=no
1577 AC_MSG_RESULT([no])
1578])
1579
1580AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1581
sewardj27d176a2011-01-17 11:15:48 +00001582
1583# does the x86/amd64 assembler understand SSE 4.2 instructions?
1584# Note, this doesn't generate a C-level symbol. It generates a
1585# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1586AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1587
bart417cf3e2011-10-22 09:21:24 +00001588AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00001589 do { long long int x;
1590 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00001591 "crc32q %%r15,%%r15" : : : "r15" );
1592 __asm__ __volatile__(
1593 "pblendvb (%rcx), %xmm11"); }
sewardj27d176a2011-01-17 11:15:48 +00001594 while (0)
bart417cf3e2011-10-22 09:21:24 +00001595]])], [
sewardj27d176a2011-01-17 11:15:48 +00001596ac_have_as_sse42=yes
1597AC_MSG_RESULT([yes])
1598], [
1599ac_have_as_sse42=no
1600AC_MSG_RESULT([no])
1601])
1602
1603AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1604
1605
sewardje089f012010-10-13 21:47:29 +00001606# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1607# when building the tool executables. I think we should get rid of it.
1608#
sewardjb5f6f512005-03-10 23:59:00 +00001609# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00001610AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1611 [[return foo;]])],
1612 [vg_cv_linktime_tls=yes],
1613 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00001614# Native compilation: check whether running a program using TLS succeeds.
1615# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1616# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00001617# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00001618AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1619 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1620 [vg_cv_tls=$enableval],
1621 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1622 [[return foo;]])],
1623 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00001624 [vg_cv_tls=no],
1625 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00001626
1627if test "$vg_cv_tls" = yes; then
1628AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1629fi
sewardj5b754b42002-06-03 22:53:35 +00001630
sewardj535c50f2005-06-04 23:14:53 +00001631
njn7fd6d382009-01-22 21:56:32 +00001632#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001633# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001634#----------------------------------------------------------------------------
1635
sewardjde4a1d02002-03-22 01:27:54 +00001636AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001637AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001638 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001639 endian.h \
1640 mqueue.h \
1641 sys/endian.h \
1642 sys/epoll.h \
1643 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001644 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001645 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001646 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001647 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001648 sys/syscall.h \
1649 sys/time.h \
1650 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001651 ])
sewardjde4a1d02002-03-22 01:27:54 +00001652
bart818f17e2011-09-17 06:24:49 +00001653# Verify whether the <linux/futex.h> header is usable.
1654AC_MSG_CHECKING([if <linux/futex.h> is usable])
1655
bart417cf3e2011-10-22 09:21:24 +00001656AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00001657#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00001658]], [[
bart818f17e2011-09-17 06:24:49 +00001659 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00001660]])], [
bart78bfc712011-12-08 16:14:59 +00001661ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00001662AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1663 [Define to 1 if you have a usable <linux/futex.h> header file.])
1664AC_MSG_RESULT([yes])
1665], [
bart78bfc712011-12-08 16:14:59 +00001666ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00001667AC_MSG_RESULT([no])
1668])
1669
njn7fd6d382009-01-22 21:56:32 +00001670#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001671# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001672#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001673AC_TYPE_UID_T
1674AC_TYPE_OFF_T
1675AC_TYPE_SIZE_T
1676AC_HEADER_TIME
1677
sewardj535c50f2005-06-04 23:14:53 +00001678
njn7fd6d382009-01-22 21:56:32 +00001679#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001680# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001681#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001682AC_FUNC_MEMCMP
1683AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00001684
bart26288e42011-04-03 16:46:01 +00001685AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001686AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001687
bartf5ceec82008-04-26 07:45:10 +00001688AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001689 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001690 epoll_create \
1691 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001692 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001693 mallinfo \
1694 memchr \
1695 memset \
1696 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001697 mremap \
bartf5ceec82008-04-26 07:45:10 +00001698 ppoll \
bart6d45e922009-01-20 13:45:38 +00001699 pthread_barrier_init \
1700 pthread_condattr_setclock \
1701 pthread_mutex_timedlock \
1702 pthread_rwlock_timedrdlock \
1703 pthread_rwlock_timedwrlock \
1704 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001705 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001706 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001707 semtimedop \
1708 signalfd \
njn6cc22472009-03-16 03:46:48 +00001709 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001710 strchr \
1711 strdup \
1712 strpbrk \
1713 strrchr \
1714 strstr \
barta72a27b2010-04-29 06:22:17 +00001715 syscall \
bartf5ceec82008-04-26 07:45:10 +00001716 utimensat \
tom9e4b6362012-02-10 09:39:37 +00001717 process_vm_readv \
1718 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00001719 ])
sewardjde4a1d02002-03-22 01:27:54 +00001720
bart623eec32008-07-29 17:54:49 +00001721# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1722# libraries with any shared object and/or executable. This is NOT what we
1723# want for e.g. vgpreload_core-x86-linux.so
1724LIBS=""
sewardj80637752006-03-02 13:48:21 +00001725
bart6d45e922009-01-20 13:45:38 +00001726AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1727 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001728AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1729 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001730AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1731 [test x$ac_cv_func_pthread_spin_lock = xyes])
1732
njn7fd6d382009-01-22 21:56:32 +00001733
1734#----------------------------------------------------------------------------
1735# MPI checks
1736#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001737# Do we have a useable MPI setup on the primary and/or secondary targets?
1738# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001739# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001740# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001741# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001742MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001743
sewardje9fa5062006-03-12 18:29:18 +00001744mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001745if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001746 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1747 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001748 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001749elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001750 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1751 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001752 mflag_primary=$FLAG_M64
1753fi
1754
sewardj03d86f22006-10-17 00:57:24 +00001755mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001756if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1757 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001758 mflag_secondary=$FLAG_M32
sewardj03d86f22006-10-17 00:57:24 +00001759fi
1760
1761
sewardj0ad46092006-03-02 17:09:16 +00001762AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001763 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001764 MPI_CC=$withval
1765)
sewardj03d86f22006-10-17 00:57:24 +00001766AC_SUBST(MPI_CC)
1767
1768## See if MPI_CC works for the primary target
1769##
1770AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001771saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001772saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001773CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +00001774CFLAGS=$mflag_primary
bart417cf3e2011-10-22 09:21:24 +00001775AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00001776#include <mpi.h>
1777#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001778]], [[
sewardjde4f3842006-03-09 02:41:41 +00001779 int r = MPI_Init(NULL,NULL);
1780 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1781 return r;
bart417cf3e2011-10-22 09:21:24 +00001782]])], [
sewardj03d86f22006-10-17 00:57:24 +00001783ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001784AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001785], [
sewardj03d86f22006-10-17 00:57:24 +00001786ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001787AC_MSG_RESULT([no])
1788])
sewardj0ad46092006-03-02 17:09:16 +00001789CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001790CFLAGS=$saved_CFLAGS
sewardj03d86f22006-10-17 00:57:24 +00001791AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001792
sewardj03d86f22006-10-17 00:57:24 +00001793## See if MPI_CC works for the secondary target. Complication: what if
1794## there is no secondary target? We need this to then fail.
1795## Kludge this by making MPI_CC something which will surely fail in
1796## such a case.
1797##
1798AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1799saved_CC=$CC
1800saved_CFLAGS=$CFLAGS
njn7fd6d382009-01-22 21:56:32 +00001801if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001802 CC="$MPI_CC this will surely fail"
1803else
1804 CC=$MPI_CC
1805fi
1806CFLAGS=$mflag_secondary
bart417cf3e2011-10-22 09:21:24 +00001807AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00001808#include <mpi.h>
1809#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001810]], [[
sewardj03d86f22006-10-17 00:57:24 +00001811 int r = MPI_Init(NULL,NULL);
1812 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1813 return r;
bart417cf3e2011-10-22 09:21:24 +00001814]])], [
sewardj03d86f22006-10-17 00:57:24 +00001815ac_have_mpi2_sec=yes
1816AC_MSG_RESULT([yes, $MPI_CC])
1817], [
1818ac_have_mpi2_sec=no
1819AC_MSG_RESULT([no])
1820])
1821CC=$saved_CC
1822CFLAGS=$saved_CFLAGS
1823AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001824
1825
njn7fd6d382009-01-22 21:56:32 +00001826#----------------------------------------------------------------------------
1827# Other library checks
1828#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00001829# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00001830# tests are present because Drd has some regression tests that use
1831# these packages. All regression test programs all compiled only
1832# for the primary target. And so it is important that the configure
1833# checks that follow, use the correct -m32 or -m64 flag for the
1834# primary target (called $mflag_primary). Otherwise, we can end up
1835# in a situation (eg) where, on amd64-linux, the test for Boost checks
1836# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1837# only build (meaning, the primary target is x86-linux), the build
1838# of the regtest programs that use Boost fails, because they are
1839# build as 32-bit (IN THIS EXAMPLE).
1840#
1841# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1842# NEEDED BY THE REGRESSION TEST PROGRAMS.
1843
1844
sewardj493c4ef2008-12-13 16:45:19 +00001845# Check whether the boost library 1.35 or later has been installed.
1846# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1847
1848AC_MSG_CHECKING([for boost])
1849
1850AC_LANG(C++)
1851safe_CXXFLAGS=$CXXFLAGS
1852CXXFLAGS="-lboost_thread-mt $mflag_primary"
1853
bart128fc522011-03-12 10:36:35 +00001854AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001855#include <boost/thread.hpp>
1856static void thread_func(void)
1857{ }
1858int main(int argc, char** argv)
1859{
1860 boost::thread t(thread_func);
1861 return 0;
1862}
bart128fc522011-03-12 10:36:35 +00001863])],
sewardj493c4ef2008-12-13 16:45:19 +00001864[
1865ac_have_boost_1_35=yes
1866AC_SUBST([BOOST_CFLAGS], [])
1867AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1868AC_MSG_RESULT([yes])
1869], [
1870ac_have_boost_1_35=no
1871AC_MSG_RESULT([no])
1872])
1873
1874CXXFLAGS=$safe_CXXFLAGS
1875AC_LANG(C)
1876
1877AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1878
1879
1880# does this compiler support -fopenmp, does it have the include file
1881# <omp.h> and does it have libgomp ?
1882
1883AC_MSG_CHECKING([for OpenMP])
1884
1885safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001886CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001887
bart128fc522011-03-12 10:36:35 +00001888AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001889#include <omp.h>
1890int main(int argc, char** argv)
1891{
1892 omp_set_dynamic(0);
1893 return 0;
1894}
bart128fc522011-03-12 10:36:35 +00001895])],
sewardj493c4ef2008-12-13 16:45:19 +00001896[
1897ac_have_openmp=yes
1898AC_MSG_RESULT([yes])
1899], [
1900ac_have_openmp=no
1901AC_MSG_RESULT([no])
1902])
1903CFLAGS=$safe_CFLAGS
1904
1905AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1906
1907
bart78bfc712011-12-08 16:14:59 +00001908# does this compiler have built-in functions for atomic memory access for the
1909# primary target ?
1910AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00001911
1912safe_CFLAGS=$CFLAGS
1913CFLAGS="$mflag_primary"
1914
bart417cf3e2011-10-22 09:21:24 +00001915AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00001916 int variable = 1;
1917 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1918 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001919]])], [
bartb4ff7822011-12-10 19:48:04 +00001920 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00001921 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00001922 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 +00001923], [
bartb4ff7822011-12-10 19:48:04 +00001924 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00001925 AC_MSG_RESULT([no])
1926])
1927
1928CFLAGS=$safe_CFLAGS
1929
bartb4ff7822011-12-10 19:48:04 +00001930AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
1931 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00001932
bart78bfc712011-12-08 16:14:59 +00001933
1934# does this compiler have built-in functions for atomic memory access for the
1935# secondary target ?
1936
1937if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1938
1939AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
1940
1941safe_CFLAGS=$CFLAGS
1942CFLAGS="$mflag_secondary"
1943
1944AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1945 int variable = 1;
1946 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
1947]])], [
1948 ac_have_builtin_atomic_secondary=yes
1949 AC_MSG_RESULT([yes])
1950], [
1951 ac_have_builtin_atomic_secondary=no
1952 AC_MSG_RESULT([no])
1953])
1954
1955CFLAGS=$safe_CFLAGS
1956
1957fi
1958
1959AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
1960 [test x$ac_have_builtin_atomic_secondary = xyes])
1961
bart1e856ea2011-12-17 12:53:23 +00001962# does this compiler have built-in functions for atomic memory access on
1963# 64-bit integers for all targets ?
1964
1965AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
1966
1967AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1968 #include <stdint.h>
1969]], [[
1970 uint64_t variable = 1;
1971 return __sync_add_and_fetch(&variable, 1)
1972]])], [
1973 ac_have_builtin_atomic64_primary=yes
1974], [
1975 ac_have_builtin_atomic64_primary=no
1976])
1977
1978if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
1979
1980safe_CFLAGS=$CFLAGS
1981CFLAGS="$mflag_secondary"
1982
1983AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1984 #include <stdint.h>
1985]], [[
1986 uint64_t variable = 1;
1987 return __sync_add_and_fetch(&variable, 1)
1988]])], [
1989 ac_have_builtin_atomic64_secondary=yes
1990], [
1991 ac_have_builtin_atomic64_secondary=no
1992])
1993
1994CFLAGS=$safe_CFLAGS
1995
1996fi
1997
1998if test x$ac_have_builtin_atomic64_primary = xyes && \
1999 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2000 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2001 AC_MSG_RESULT([yes])
2002 ac_have_builtin_atomic64=yes
2003else
2004 AC_MSG_RESULT([no])
2005 ac_have_builtin_atomic64=no
2006fi
2007
2008AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2009 [test x$ac_have_builtin_atomic64 = xyes])
2010
bart78bfc712011-12-08 16:14:59 +00002011
barte8740422011-03-24 20:27:54 +00002012# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002013AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002014
2015safe_CXXFLAGS=$CXXFLAGS
2016CXXFLAGS="$mflag_primary"
2017
2018AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002019AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002020 int variable = 1;
2021 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2022 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002023]])], [
barte8740422011-03-24 20:27:54 +00002024 ac_have_builtin_atomic_cxx=yes
2025 AC_MSG_RESULT([yes])
2026 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 +00002027], [
barte8740422011-03-24 20:27:54 +00002028 ac_have_builtin_atomic_cxx=no
2029 AC_MSG_RESULT([no])
2030])
2031AC_LANG_POP(C++)
2032
2033CXXFLAGS=$safe_CXXFLAGS
2034
2035AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002036
bart78bfc712011-12-08 16:14:59 +00002037
2038if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002039 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002040 ac_enable_linux_ticket_lock_primary=yes
2041fi
2042AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2043 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2044
2045if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2046 -a x$ac_have_usable_linux_futex_h = xyes \
2047 -a x$ac_have_builtin_atomic_secondary = xyes; then
2048 ac_enable_linux_ticket_lock_secondary=yes
2049fi
2050AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2051 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2052
2053
bartf68af882011-12-10 19:42:05 +00002054# does libstdc++ support annotating shared pointers ?
2055AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2056
2057safe_CXXFLAGS=$CFLAGS
2058CXXFLAGS="-std=c++0x"
2059
2060AC_LANG_PUSH(C++)
2061AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2062 #include <memory>
2063]], [[
2064 std::shared_ptr<int> p
2065]])], [
2066 ac_have_shared_ptr=yes
2067], [
2068 ac_have_shared_ptr=no
2069])
2070if test x$ac_have_shared_ptr = xyes; then
2071 # If compilation of the program below fails because of a syntax error
2072 # triggered by substituting one of the annotation macros then that
2073 # means that libstdc++ supports these macros.
2074 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2075 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2076 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2077 #include <memory>
2078 ]], [[
2079 std::shared_ptr<int> p
2080 ]])], [
2081 ac_have_shared_pointer_annotation=no
2082 AC_MSG_RESULT([no])
2083 ], [
2084 ac_have_shared_pointer_annotation=yes
2085 AC_MSG_RESULT([yes])
2086 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2087 [Define to 1 if libstd++ supports annotating shared pointers])
2088 ])
2089else
2090 ac_have_shared_pointer_annotation=no
2091 AC_MSG_RESULT([no])
2092fi
2093AC_LANG_POP(C++)
2094
2095CXXFLAGS=$safe_CXXFLAGS
2096
2097AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2098 [test x$ac_have_shared_pointer_annotation = xyes])
2099
2100
njn7fd6d382009-01-22 21:56:32 +00002101#----------------------------------------------------------------------------
2102# Ok. We're done checking.
2103#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002104
njn8b68b642009-06-24 00:37:09 +00002105# Nb: VEX/Makefile is generated from Makefile.vex.in.
2106AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002107 Makefile
njn8b68b642009-06-24 00:37:09 +00002108 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002109 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002110 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002111 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002112 docs/Makefile
2113 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002114 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002115 perf/Makefile
2116 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002117 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002118 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002119 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002120 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002121 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002122 memcheck/Makefile
2123 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002124 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002125 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002126 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002127 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002128 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002129 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002130 memcheck/tests/ppc32/Makefile
2131 memcheck/tests/ppc64/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002132 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002133 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002134 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002135 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002136 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002137 callgrind/Makefile
2138 callgrind/callgrind_annotate
2139 callgrind/callgrind_control
2140 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002141 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002142 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002143 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002144 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002145 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002146 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002147 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002148 none/Makefile
2149 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002150 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002151 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002152 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002153 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002154 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002155 none/tests/s390x/Makefile
njn0458a122009-02-13 06:23:46 +00002156 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002157 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002158 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002159 exp-sgcheck/Makefile
2160 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002161 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002162 drd/scripts/download-and-build-splash2
2163 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002164 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002165 exp-bbv/tests/Makefile
2166 exp-bbv/tests/x86/Makefile
2167 exp-bbv/tests/x86-linux/Makefile
2168 exp-bbv/tests/amd64-linux/Makefile
2169 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002170 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002171 exp-dhat/Makefile
2172 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002173])
sewardjd3645802010-06-13 22:13:58 +00002174AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2175 [chmod +x coregrind/link_tool_exe_linux])
2176AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2177 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002178AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002179
2180cat<<EOF
2181
njn311303f2009-02-06 03:46:50 +00002182 Maximum build arch: ${ARCH_MAX}
2183 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002184 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002185 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002186 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2187 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002188 Platform variant: ${VGCONF_PLATVARIANT}
2189 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002190 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002191
gobry3b777892002-04-04 09:18:39 +00002192EOF