blob: 13c4a9577e24a8d1f14a6ce9990bed791dabc814 [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
philippef32cbe82012-05-18 16:48:20 +0000619dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
620dnl fallback definition
621dnl The macro is courtesy of Dave Hart:
622dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
623m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
624if test -z "$$1_TRUE"; then :
625 m4_n([$2])[]dnl
626m4_ifval([$3],
627[else
628 $3
629])dnl
630fi[]dnl
631])])
tomb637bad2005-11-08 12:28:35 +0000632
njn7fd6d382009-01-22 21:56:32 +0000633#----------------------------------------------------------------------------
634# Inner Valgrind?
635#----------------------------------------------------------------------------
636
njnd74b0ef2009-01-20 06:06:52 +0000637# Check if this should be built as an inner Valgrind, to be run within
638# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000639AC_SUBST(VALT_LOAD_ADDRESS_PRI)
640AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000641AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
642 [AC_ARG_ENABLE(inner,
643 [ --enable-inner enables self-hosting],
644 [vg_cv_inner=$enableval],
645 [vg_cv_inner=no])])
646if test "$vg_cv_inner" = yes; then
647 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000648 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
649 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000650else
njnea2d6fd2010-07-01 00:20:20 +0000651 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
652 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000653fi
654
655
njn7fd6d382009-01-22 21:56:32 +0000656#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000657# Extra fine-tuning of installation directories
658#----------------------------------------------------------------------------
659AC_ARG_WITH(tmpdir,
660 [ --with-tmpdir=PATH Specify path for temporary files],
661 tmpdir="$withval",
662 tmpdir="/tmp")
663AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
664
sewardj0ba37c92011-07-12 11:46:24 +0000665
sewardjcb495c82011-07-11 20:42:34 +0000666#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000667# Libc and suppressions
668#----------------------------------------------------------------------------
669# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000670AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000671
bart12e91122010-05-15 08:37:24 +0000672AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000673
bart12e91122010-05-15 08:37:24 +0000674if test x$ac_cv_header_features_h = xyes; then
675 rm -f conftest.$ac_ext
676 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000677#include <features.h>
bart12e91122010-05-15 08:37:24 +0000678#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
679glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000680#endif
bart12e91122010-05-15 08:37:24 +0000681_ACEOF
682 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
683fi
bartb7c3f082010-05-13 06:32:36 +0000684
njnf76d27a2009-05-28 01:53:07 +0000685# not really a version check
686AC_EGREP_CPP([DARWIN_LIBC], [
687#include <sys/cdefs.h>
688#if defined(__DARWIN_VERS_1050)
689 DARWIN_LIBC
690#endif
691],
692GLIBC_VERSION="darwin")
693
sewardjcb495c82011-07-11 20:42:34 +0000694# not really a version check
695AC_EGREP_CPP([BIONIC_LIBC], [
696#if defined(__ANDROID__)
697 BIONIC_LIBC
698#endif
699],
700GLIBC_VERSION="bionic")
701
702
dirk07596a22008-04-25 11:33:30 +0000703AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000704
dirk07596a22008-04-25 11:33:30 +0000705case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000706 2.2)
707 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000708 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000709 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
710 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000711 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000712 ;;
713
sewardj08c7f012002-10-07 23:56:55 +0000714 2.3)
715 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000716 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000717 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000718 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000719 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000720 ;;
721
njn781dba52005-06-30 04:06:38 +0000722 2.4)
723 AC_MSG_RESULT(2.4 family)
724 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000725 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000726 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000727 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000728 ;;
729
dirkaece45c2006-10-12 08:17:49 +0000730 2.5)
731 AC_MSG_RESULT(2.5 family)
732 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000733 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000734 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000735 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000736 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000737 2.6)
738 AC_MSG_RESULT(2.6 family)
739 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000740 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000741 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000742 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000743 ;;
744 2.7)
745 AC_MSG_RESULT(2.7 family)
746 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000747 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000748 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000749 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000750 ;;
dirk07596a22008-04-25 11:33:30 +0000751 2.8)
752 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000753 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000754 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
755 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
756 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
757 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000758 2.9)
759 AC_MSG_RESULT(2.9 family)
760 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
761 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
762 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
763 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
764 ;;
sewardj5d425e82009-02-01 19:01:11 +0000765 2.10)
766 AC_MSG_RESULT(2.10 family)
767 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
768 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
769 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
770 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
771 ;;
bart0fac7ff2009-11-15 19:11:19 +0000772 2.11)
773 AC_MSG_RESULT(2.11 family)
774 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
775 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
776 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
777 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000778 ;;
779 2.12)
780 AC_MSG_RESULT(2.12 family)
781 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
782 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
783 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
784 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000785 ;;
tomebd619b2011-02-10 09:09:09 +0000786 2.13)
787 AC_MSG_RESULT(2.13 family)
788 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
789 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
790 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
791 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
792 ;;
tomcc077412011-06-07 21:52:26 +0000793 2.14)
794 AC_MSG_RESULT(2.14 family)
795 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
796 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
797 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
798 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
799 ;;
dirke75fdeb2011-12-29 08:24:55 +0000800 2.15)
801 AC_MSG_RESULT(2.15 family)
802 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
803 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
804 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
805 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
806 ;;
njnf76d27a2009-05-28 01:53:07 +0000807 darwin)
808 AC_MSG_RESULT(Darwin)
809 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
810 # DEFAULT_SUPP set by kernel version check above.
811 ;;
sewardjcb495c82011-07-11 20:42:34 +0000812 bionic)
813 AC_MSG_RESULT(Bionic)
814 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
815 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
816 ;;
dirkaece45c2006-10-12 08:17:49 +0000817
sewardjde4a1d02002-03-22 01:27:54 +0000818 *)
bart12e91122010-05-15 08:37:24 +0000819 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
dirke75fdeb2011-12-29 08:24:55 +0000820 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.15])
njnf76d27a2009-05-28 01:53:07 +0000821 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000822 ;;
823esac
824
dirk07596a22008-04-25 11:33:30 +0000825AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000826
sewardj414f3582008-07-18 20:46:00 +0000827
828# Add default suppressions for the X client libraries. Make no
829# attempt to detect whether such libraries are installed on the
830# build machine (or even if any X facilities are present); just
831# add the suppressions antidisirregardless.
832DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
833DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000834
sewardjd2f95a02011-05-11 16:04:28 +0000835# Add glibc and X11 suppressions for exp-sgcheck
836DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000837
sewardj2e10a682003-04-07 19:36:41 +0000838
njn7fd6d382009-01-22 21:56:32 +0000839#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000840# Platform variants?
841#----------------------------------------------------------------------------
842
843# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
844# But there are times where we need a bit more control. The motivating
845# and currently only case is Android: this is almost identical to arm-linux,
846# but not quite. So this introduces the concept of platform variant tags,
847# which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
848# with the main -DVGP_<arch>_<os> definition.
849#
850# In almost all cases, the <variant> bit is "vanilla". But for Android
851# it is "android" instead.
852#
853# Consequently (eg), plain arm-linux would build with
854#
855# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
856#
857# whilst an Android build would have
858#
859# -DVGP_arm_linux -DVGPV_arm_linux_android
860#
861# The setup of the platform variant is pushed relatively far down this
862# file in order that we can inspect any of the variables set above.
863
864# In the normal case ..
865VGCONF_PLATVARIANT="vanilla"
866
867# Android on ARM ?
868if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
869 -a "$GLIBC_VERSION" = "bionic";
870then
871 VGCONF_PLATVARIANT="android"
872fi
873
874AC_SUBST(VGCONF_PLATVARIANT)
875
876
877# FIXME: do we also want to define automake variables
878# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
879# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
880# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
881# do that. Problem is that we can't do and-ing in Makefile.am's, but
882# that's what we'd need to do to use this, since what we'd want to write
883# is something like
884#
885# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
886#
sewardj0ba37c92011-07-12 11:46:24 +0000887# Hmm. Can't think of a nice clean solution to this.
888
889AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
890 test x$VGCONF_PLATVARIANT = xvanilla)
891AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
892 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000893
894
895#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000896# Checking for various library functions and other definitions
897#----------------------------------------------------------------------------
898
bart59e2f182008-04-28 16:22:53 +0000899# Check for CLOCK_MONOTONIC
900
901AC_MSG_CHECKING([for CLOCK_MONOTONIC])
902
bart417cf3e2011-10-22 09:21:24 +0000903AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +0000904#include <time.h>
bart417cf3e2011-10-22 09:21:24 +0000905]], [[
bart59e2f182008-04-28 16:22:53 +0000906 struct timespec t;
907 clock_gettime(CLOCK_MONOTONIC, &t);
908 return 0;
bart417cf3e2011-10-22 09:21:24 +0000909]])], [
bart59e2f182008-04-28 16:22:53 +0000910AC_MSG_RESULT([yes])
911AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
912 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
913], [
914AC_MSG_RESULT([no])
915])
916
bartfea06922008-05-03 09:12:15 +0000917
sewardj0c09bf02011-07-11 22:11:58 +0000918# Check for PTHREAD_RWLOCK_T
919
920AC_MSG_CHECKING([for pthread_rwlock_t])
921
bart417cf3e2011-10-22 09:21:24 +0000922AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +0000923#define _GNU_SOURCE
924#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000925]], [[
sewardj0c09bf02011-07-11 22:11:58 +0000926 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +0000927]])], [
sewardj0c09bf02011-07-11 22:11:58 +0000928AC_MSG_RESULT([yes])
929AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
930 [Define to 1 if you have the `pthread_rwlock_t' type.])
931], [
932AC_MSG_RESULT([no])
933])
934
935
bartfea06922008-05-03 09:12:15 +0000936# Check for PTHREAD_MUTEX_ADAPTIVE_NP
937
938AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
939
bart417cf3e2011-10-22 09:21:24 +0000940AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000941#define _GNU_SOURCE
942#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000943]], [[
bartfea06922008-05-03 09:12:15 +0000944 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000945]])], [
bartfea06922008-05-03 09:12:15 +0000946AC_MSG_RESULT([yes])
947AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
948 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
949], [
950AC_MSG_RESULT([no])
951])
952
953
954# Check for PTHREAD_MUTEX_ERRORCHECK_NP
955
956AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
957
bart417cf3e2011-10-22 09:21:24 +0000958AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000959#define _GNU_SOURCE
960#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000961]], [[
bartfea06922008-05-03 09:12:15 +0000962 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +0000963]])], [
bartfea06922008-05-03 09:12:15 +0000964AC_MSG_RESULT([yes])
965AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
966 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
967], [
968AC_MSG_RESULT([no])
969])
970
971
972# Check for PTHREAD_MUTEX_RECURSIVE_NP
973
974AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
975
bart417cf3e2011-10-22 09:21:24 +0000976AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000977#define _GNU_SOURCE
978#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000979]], [[
bartfea06922008-05-03 09:12:15 +0000980 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +0000981]])], [
bartfea06922008-05-03 09:12:15 +0000982AC_MSG_RESULT([yes])
983AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
984 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
985], [
986AC_MSG_RESULT([no])
987])
988
989
990# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
991
992AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
993
bart417cf3e2011-10-22 09:21:24 +0000994AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +0000995#define _GNU_SOURCE
996#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +0000997]], [[
bartfea06922008-05-03 09:12:15 +0000998 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
999 return 0;
bart417cf3e2011-10-22 09:21:24 +00001000]])], [
bartfea06922008-05-03 09:12:15 +00001001AC_MSG_RESULT([yes])
1002AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1003 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1004], [
1005AC_MSG_RESULT([no])
1006])
1007
1008
bart5e389f12008-04-05 12:53:15 +00001009# Check whether pthread_mutex_t has a member called __m_kind.
1010
bartb11355c2010-04-29 16:37:26 +00001011AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1012 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1013 1,
1014 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1015 ],
1016 [],
1017 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001018
1019
1020# Check whether pthread_mutex_t has a member called __data.__kind.
1021
bartb11355c2010-04-29 16:37:26 +00001022AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1023 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1024 1,
1025 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1026 ],
1027 [],
1028 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001029
1030
bart62c370e2008-05-12 18:50:51 +00001031# does this compiler support -maltivec and does it have the include file
1032# <altivec.h> ?
1033
1034AC_MSG_CHECKING([for Altivec])
1035
1036safe_CFLAGS=$CFLAGS
1037CFLAGS="-maltivec"
1038
bart417cf3e2011-10-22 09:21:24 +00001039AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001040#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001041]], [[
bart62c370e2008-05-12 18:50:51 +00001042 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001043]])], [
bart62c370e2008-05-12 18:50:51 +00001044ac_have_altivec=yes
1045AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001046AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001047 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001048], [
1049ac_have_altivec=no
1050AC_MSG_RESULT([no])
1051])
1052CFLAGS=$safe_CFLAGS
1053
sewardj0e342a02010-09-03 23:49:33 +00001054AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001055
1056
sewardjf34eb492011-04-15 11:57:05 +00001057# Check that both: the compiler supports -mvsx and that the assembler
1058# understands VSX instructions. If either of those doesn't work,
1059# conclude that we can't do VSX. NOTE: basically this is a kludge
1060# in that it conflates two things that should be separate -- whether
1061# the compiler understands the flag vs whether the assembler
1062# understands the opcodes. This really ought to be cleaned up
1063# and done properly, like it is for x86/x86_64.
1064
1065AC_MSG_CHECKING([for VSX])
1066
1067safe_CFLAGS=$CFLAGS
1068CFLAGS="-mvsx"
1069
bart417cf3e2011-10-22 09:21:24 +00001070AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001071#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001072]], [[
sewardjf34eb492011-04-15 11:57:05 +00001073 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001074 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001075]])], [
sewardjf34eb492011-04-15 11:57:05 +00001076ac_have_vsx=yes
1077AC_MSG_RESULT([yes])
1078], [
1079ac_have_vsx=no
1080AC_MSG_RESULT([no])
1081])
1082CFLAGS=$safe_CFLAGS
1083
1084AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1085
sewardjb0ccb4d2012-04-02 10:22:05 +00001086AC_MSG_CHECKING([that assembler knows DFP])
1087
1088AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1089]], [[
1090 __asm__ __volatile__("dadd 1, 2, 3");
1091]])], [
1092ac_asm_have_dfp=yes
1093AC_MSG_RESULT([yes])
1094], [
1095ac_asm_have_dfp=no
1096AC_MSG_RESULT([no])
1097])
1098
1099AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1100safe_CFLAGS=$CFLAGS
1101CFLAGS="-mhard-dfp"
1102AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1103]], [[
1104 __asm__ __volatile__("dadd 1, 2, 3");
1105]])], [
1106ac_gcc_have_dfp=yes
1107AC_MSG_RESULT([yes])
1108], [
1109ac_gcc_have_dfp=no
1110AC_MSG_RESULT([no])
1111])
1112
sewardjb0ccb4d2012-04-02 10:22:05 +00001113CFLAGS=$safe_CFLAGS
1114
1115AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001116
bart36dd85a2009-04-26 07:11:48 +00001117# Check for pthread_create@GLIBC2.0
1118AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1119
bart16e1c5a2009-04-26 07:38:53 +00001120safe_CFLAGS=$CFLAGS
1121CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001122AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001123extern int pthread_create_glibc_2_0(void*, const void*,
1124 void *(*)(void*), void*);
1125__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001126]], [[
bart276ed3a2009-05-10 15:41:45 +00001127#ifdef __powerpc__
1128/*
1129 * Apparently on PowerPC linking this program succeeds and generates an
1130 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1131 */
1132#error This test does not work properly on PowerPC.
1133#else
bart16e1c5a2009-04-26 07:38:53 +00001134 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001135#endif
bart16e1c5a2009-04-26 07:38:53 +00001136 return 0;
bart417cf3e2011-10-22 09:21:24 +00001137]])], [
bart36dd85a2009-04-26 07:11:48 +00001138ac_have_pthread_create_glibc_2_0=yes
1139AC_MSG_RESULT([yes])
1140AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1141 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1142], [
1143ac_have_pthread_create_glibc_2_0=no
1144AC_MSG_RESULT([no])
1145])
bart16e1c5a2009-04-26 07:38:53 +00001146CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001147
1148AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001149 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001150
1151
barta50aa8a2008-04-27 06:06:57 +00001152# Check for eventfd_t, eventfd() and eventfd_read()
1153AC_MSG_CHECKING([for eventfd()])
1154
bart417cf3e2011-10-22 09:21:24 +00001155AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001156#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001157]], [[
barta50aa8a2008-04-27 06:06:57 +00001158 eventfd_t ev;
1159 int fd;
1160
1161 fd = eventfd(5, 0);
1162 eventfd_read(fd, &ev);
1163 return 0;
bart417cf3e2011-10-22 09:21:24 +00001164]])], [
barta50aa8a2008-04-27 06:06:57 +00001165AC_MSG_RESULT([yes])
1166AC_DEFINE([HAVE_EVENTFD], 1,
1167 [Define to 1 if you have the `eventfd' function.])
1168AC_DEFINE([HAVE_EVENTFD_READ], 1,
1169 [Define to 1 if you have the `eventfd_read' function.])
1170], [
1171AC_MSG_RESULT([no])
1172])
1173
1174
njn7fd6d382009-01-22 21:56:32 +00001175#----------------------------------------------------------------------------
1176# Checking for supported compiler flags.
1177#----------------------------------------------------------------------------
1178
sewardj535c50f2005-06-04 23:14:53 +00001179# does this compiler support -m32 ?
1180AC_MSG_CHECKING([if gcc accepts -m32])
1181
1182safe_CFLAGS=$CFLAGS
1183CFLAGS="-m32"
1184
bart417cf3e2011-10-22 09:21:24 +00001185AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001186 return 0;
bart417cf3e2011-10-22 09:21:24 +00001187]])], [
sewardj535c50f2005-06-04 23:14:53 +00001188FLAG_M32="-m32"
1189AC_MSG_RESULT([yes])
1190], [
1191FLAG_M32=""
1192AC_MSG_RESULT([no])
1193])
1194CFLAGS=$safe_CFLAGS
1195
1196AC_SUBST(FLAG_M32)
1197
1198
sewardj01262142006-01-04 01:20:28 +00001199# does this compiler support -m64 ?
1200AC_MSG_CHECKING([if gcc accepts -m64])
1201
1202safe_CFLAGS=$CFLAGS
1203CFLAGS="-m64"
1204
bart417cf3e2011-10-22 09:21:24 +00001205AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001206 return 0;
bart417cf3e2011-10-22 09:21:24 +00001207]])], [
sewardj01262142006-01-04 01:20:28 +00001208FLAG_M64="-m64"
1209AC_MSG_RESULT([yes])
1210], [
1211FLAG_M64=""
1212AC_MSG_RESULT([no])
1213])
1214CFLAGS=$safe_CFLAGS
1215
1216AC_SUBST(FLAG_M64)
1217
1218
sewardj67f1fcc2005-07-03 10:41:02 +00001219# does this compiler support -mmmx ?
1220AC_MSG_CHECKING([if gcc accepts -mmmx])
1221
1222safe_CFLAGS=$CFLAGS
1223CFLAGS="-mmmx"
1224
bart417cf3e2011-10-22 09:21:24 +00001225AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001226 return 0;
bart417cf3e2011-10-22 09:21:24 +00001227]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001228FLAG_MMMX="-mmmx"
1229AC_MSG_RESULT([yes])
1230], [
1231FLAG_MMMX=""
1232AC_MSG_RESULT([no])
1233])
1234CFLAGS=$safe_CFLAGS
1235
1236AC_SUBST(FLAG_MMMX)
1237
1238
1239# does this compiler support -msse ?
1240AC_MSG_CHECKING([if gcc accepts -msse])
1241
1242safe_CFLAGS=$CFLAGS
1243CFLAGS="-msse"
1244
bart417cf3e2011-10-22 09:21:24 +00001245AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001246 return 0;
bart417cf3e2011-10-22 09:21:24 +00001247]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001248FLAG_MSSE="-msse"
1249AC_MSG_RESULT([yes])
1250], [
1251FLAG_MSSE=""
1252AC_MSG_RESULT([no])
1253])
1254CFLAGS=$safe_CFLAGS
1255
1256AC_SUBST(FLAG_MSSE)
1257
1258
sewardj5b754b42002-06-03 22:53:35 +00001259# does this compiler support -mpreferred-stack-boundary=2 ?
1260AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1261
daywalker3664f562003-10-17 13:43:46 +00001262safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001263CFLAGS="-mpreferred-stack-boundary=2"
1264
bart417cf3e2011-10-22 09:21:24 +00001265AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001266 return 0;
bart417cf3e2011-10-22 09:21:24 +00001267]])], [
sewardj5b754b42002-06-03 22:53:35 +00001268PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001269AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001270], [
1271PREFERRED_STACK_BOUNDARY=""
1272AC_MSG_RESULT([no])
1273])
daywalker3664f562003-10-17 13:43:46 +00001274CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001275
1276AC_SUBST(PREFERRED_STACK_BOUNDARY)
1277
sewardj535c50f2005-06-04 23:14:53 +00001278
sewardjb5f6f512005-03-10 23:59:00 +00001279# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001280AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001281
1282safe_CFLAGS=$CFLAGS
1283CFLAGS="-Wno-pointer-sign"
1284
bart417cf3e2011-10-22 09:21:24 +00001285AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001286 return 0;
bart417cf3e2011-10-22 09:21:24 +00001287]])], [
sewardjb5f6f512005-03-10 23:59:00 +00001288no_pointer_sign=yes
1289AC_MSG_RESULT([yes])
1290], [
1291no_pointer_sign=no
1292AC_MSG_RESULT([no])
1293])
1294CFLAGS=$safe_CFLAGS
1295
1296if test x$no_pointer_sign = xyes; then
1297 CFLAGS="$CFLAGS -Wno-pointer-sign"
1298fi
1299
sewardj535c50f2005-06-04 23:14:53 +00001300
barte026bd22009-07-04 12:17:07 +00001301# does this compiler support -Wno-empty-body ?
1302
1303AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1304
1305safe_CFLAGS=$CFLAGS
1306CFLAGS="-Wno-empty-body"
1307
bart417cf3e2011-10-22 09:21:24 +00001308AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001309 return 0;
bart417cf3e2011-10-22 09:21:24 +00001310]])], [
barte026bd22009-07-04 12:17:07 +00001311AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1312AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001313], [
barte026bd22009-07-04 12:17:07 +00001314AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1315AC_MSG_RESULT([no])
1316])
1317CFLAGS=$safe_CFLAGS
1318
1319
bart9d865fa2008-06-23 12:11:49 +00001320# does this compiler support -Wno-format-zero-length ?
1321
1322AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1323
1324safe_CFLAGS=$CFLAGS
1325CFLAGS="-Wno-format-zero-length"
1326
bart417cf3e2011-10-22 09:21:24 +00001327AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001328 return 0;
bart417cf3e2011-10-22 09:21:24 +00001329]])], [
bart9d865fa2008-06-23 12:11:49 +00001330AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1331AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001332], [
bart9d865fa2008-06-23 12:11:49 +00001333AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1334AC_MSG_RESULT([no])
1335])
1336CFLAGS=$safe_CFLAGS
1337
1338
bart8e216312011-05-15 17:05:36 +00001339# does this compiler support -Wno-nonnull ?
1340
1341AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1342
1343safe_CFLAGS=$CFLAGS
1344CFLAGS="-Wno-nonnull"
1345
bart417cf3e2011-10-22 09:21:24 +00001346AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001347 return 0;
bart417cf3e2011-10-22 09:21:24 +00001348]])], [
bart8e216312011-05-15 17:05:36 +00001349AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1350AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001351], [
bart8e216312011-05-15 17:05:36 +00001352AC_SUBST([FLAG_W_NO_NONNULL], [])
1353AC_MSG_RESULT([no])
1354])
1355CFLAGS=$safe_CFLAGS
1356
1357
1358# does this compiler support -Wno-overflow ?
1359
1360AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1361
1362safe_CFLAGS=$CFLAGS
1363CFLAGS="-Wno-overflow"
1364
bart417cf3e2011-10-22 09:21:24 +00001365AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001366 return 0;
bart417cf3e2011-10-22 09:21:24 +00001367]])], [
bart8e216312011-05-15 17:05:36 +00001368AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1369AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001370], [
bart8e216312011-05-15 17:05:36 +00001371AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1372AC_MSG_RESULT([no])
1373])
1374CFLAGS=$safe_CFLAGS
1375
1376
bartbf9b85c2009-08-12 12:55:56 +00001377# does this compiler support -Wno-uninitialized ?
1378
1379AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1380
1381safe_CFLAGS=$CFLAGS
1382CFLAGS="-Wno-uninitialized"
1383
bart417cf3e2011-10-22 09:21:24 +00001384AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001385 return 0;
bart417cf3e2011-10-22 09:21:24 +00001386]])], [
bartbf9b85c2009-08-12 12:55:56 +00001387AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1388AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001389], [
bartbf9b85c2009-08-12 12:55:56 +00001390AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1391AC_MSG_RESULT([no])
1392])
1393CFLAGS=$safe_CFLAGS
1394
1395
bart56730cd2008-05-11 06:41:46 +00001396# does this compiler support -Wextra or the older -W ?
1397
1398AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1399
1400safe_CFLAGS=$CFLAGS
1401CFLAGS="-Wextra"
1402
bart417cf3e2011-10-22 09:21:24 +00001403AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001404 return 0;
bart417cf3e2011-10-22 09:21:24 +00001405]])], [
bart56730cd2008-05-11 06:41:46 +00001406AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1407AC_MSG_RESULT([-Wextra])
1408], [
1409 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001410 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001411 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001412 ]])], [
bart56730cd2008-05-11 06:41:46 +00001413 AC_SUBST([FLAG_W_EXTRA], [-W])
1414 AC_MSG_RESULT([-W])
1415 ], [
1416 AC_SUBST([FLAG_W_EXTRA], [])
1417 AC_MSG_RESULT([not supported])
1418 ])
1419])
1420CFLAGS=$safe_CFLAGS
1421
1422
sewardja72c26d2007-05-01 13:44:08 +00001423# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001424AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001425
1426safe_CFLAGS=$CFLAGS
1427CFLAGS="-fno-stack-protector"
1428
bart417cf3e2011-10-22 09:21:24 +00001429AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001430 return 0;
bart417cf3e2011-10-22 09:21:24 +00001431]])], [
sewardja72c26d2007-05-01 13:44:08 +00001432no_stack_protector=yes
1433FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1434AC_MSG_RESULT([yes])
1435], [
1436no_stack_protector=no
1437FLAG_FNO_STACK_PROTECTOR=""
1438AC_MSG_RESULT([no])
1439])
1440CFLAGS=$safe_CFLAGS
1441
1442AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1443
1444if test x$no_stack_protector = xyes; then
1445 CFLAGS="$CFLAGS -fno-stack-protector"
1446fi
1447
1448
bart56730cd2008-05-11 06:41:46 +00001449# does this compiler support --param inline-unit-growth=... ?
1450
1451AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1452
1453safe_CFLAGS=$CFLAGS
1454CFLAGS="--param inline-unit-growth=900"
1455
bart417cf3e2011-10-22 09:21:24 +00001456AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001457 return 0;
bart417cf3e2011-10-22 09:21:24 +00001458]])], [
bart56730cd2008-05-11 06:41:46 +00001459AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1460 ["--param inline-unit-growth=900"])
1461AC_MSG_RESULT([yes])
1462], [
1463AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1464AC_MSG_RESULT([no])
1465])
1466CFLAGS=$safe_CFLAGS
1467
1468
sewardjd9350682012-04-05 07:55:47 +00001469# does this compiler support -gdwarf-4 -fdebug-types-section ?
1470
1471AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1472
1473safe_CFLAGS=$CFLAGS
1474CFLAGS="-gdwarf-4 -fdebug-types-section"
1475
1476AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1477 return 0;
1478]])], [
1479ac_have_dwarf4=yes
1480AC_MSG_RESULT([yes])
1481], [
1482ac_have_dwarf4=no
1483AC_MSG_RESULT([no])
1484])
1485AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1486CFLAGS=$safe_CFLAGS
1487
1488
sewardjd3645802010-06-13 22:13:58 +00001489# does the linker support -Wl,--build-id=none ? Note, it's
1490# important that we test indirectly via whichever C compiler
1491# is selected, rather than testing /usr/bin/ld or whatever
1492# directly.
bart699fbac2010-06-08 18:23:59 +00001493
sewardjd3645802010-06-13 22:13:58 +00001494AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001495
1496safe_CFLAGS=$CFLAGS
1497CFLAGS="-Wl,--build-id=none"
1498
bart8508c752010-06-10 06:26:21 +00001499AC_LINK_IFELSE(
1500[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001501[
1502 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1503 AC_MSG_RESULT([yes])
1504], [
1505 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1506 AC_MSG_RESULT([no])
1507])
1508CFLAGS=$safe_CFLAGS
1509
1510
sewardj00f1e622006-03-12 16:47:10 +00001511# does the ppc assembler support "mtocrf" et al?
1512AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1513
bart417cf3e2011-10-22 09:21:24 +00001514AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001515__asm__ __volatile__("mtocrf 4,0");
1516__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001517]])], [
sewardj00f1e622006-03-12 16:47:10 +00001518ac_have_as_ppc_mftocrf=yes
1519AC_MSG_RESULT([yes])
1520], [
1521ac_have_as_ppc_mftocrf=no
1522AC_MSG_RESULT([no])
1523])
1524if test x$ac_have_as_ppc_mftocrf = xyes ; then
1525 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1526fi
1527
1528
sewardjb5b87402011-03-07 16:05:35 +00001529CFLAGS=$safe_CFLAGS
1530
sewardjf0aabf82007-03-22 00:24:21 +00001531# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001532# Note, this doesn't generate a C-level symbol. It generates a
1533# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001534AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1535
bart417cf3e2011-10-22 09:21:24 +00001536AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001537 do { long long int x;
1538 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1539 while (0)
bart417cf3e2011-10-22 09:21:24 +00001540]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001541ac_have_as_sse3=yes
1542AC_MSG_RESULT([yes])
1543], [
1544ac_have_as_sse3=no
1545AC_MSG_RESULT([no])
1546])
sewardjfa18a262007-03-22 12:13:13 +00001547
1548AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001549
1550
sewardj6d6da5b2008-02-09 12:07:40 +00001551# Ditto for SSSE3 instructions (note extra S)
1552# Note, this doesn't generate a C-level symbol. It generates a
1553# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1554AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1555
florianc443b962011-10-28 21:37:19 +00001556save_CFLAGS="$CFLAGS"
1557CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001558AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001559 do { long long int x;
1560 __asm__ __volatile__(
1561 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1562 while (0)
bart417cf3e2011-10-22 09:21:24 +00001563]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001564ac_have_as_ssse3=yes
1565AC_MSG_RESULT([yes])
1566], [
1567ac_have_as_ssse3=no
1568AC_MSG_RESULT([no])
1569])
florianc443b962011-10-28 21:37:19 +00001570CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001571
1572AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1573
1574
sewardj27d176a2011-01-17 11:15:48 +00001575# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1576# Note, this doesn't generate a C-level symbol. It generates a
1577# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001578AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001579AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001580 do {
1581 __asm__ __volatile__(
1582 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1583 while (0)
bart417cf3e2011-10-22 09:21:24 +00001584]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001585ac_have_as_pclmulqdq=yes
1586AC_MSG_RESULT([yes])
1587], [
1588ac_have_as_pclmulqdq=no
1589AC_MSG_RESULT([no])
1590])
1591
1592AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1593
1594
sewardj27d176a2011-01-17 11:15:48 +00001595# does the x86/amd64 assembler understand the LZCNT instruction?
1596# Note, this doesn't generate a C-level symbol. It generates a
1597# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001598AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1599
bart417cf3e2011-10-22 09:21:24 +00001600AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00001601 do {
1602 __asm__ __volatile__("lzcnt %rax,%rax");
1603 } while (0)
bart417cf3e2011-10-22 09:21:24 +00001604]])], [
bart55e438b2010-09-14 10:53:57 +00001605 ac_have_as_lzcnt=yes
1606 AC_MSG_RESULT([yes])
1607], [
1608 ac_have_as_lzcnt=no
1609 AC_MSG_RESULT([no])
1610])
1611
1612AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1613
sewardj27d176a2011-01-17 11:15:48 +00001614
1615# does the x86/amd64 assembler understand SSE 4.2 instructions?
1616# Note, this doesn't generate a C-level symbol. It generates a
1617# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1618AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1619
bart417cf3e2011-10-22 09:21:24 +00001620AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00001621 do { long long int x;
1622 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00001623 "crc32q %%r15,%%r15" : : : "r15" );
1624 __asm__ __volatile__(
1625 "pblendvb (%rcx), %xmm11"); }
sewardj27d176a2011-01-17 11:15:48 +00001626 while (0)
bart417cf3e2011-10-22 09:21:24 +00001627]])], [
sewardj27d176a2011-01-17 11:15:48 +00001628ac_have_as_sse42=yes
1629AC_MSG_RESULT([yes])
1630], [
1631ac_have_as_sse42=no
1632AC_MSG_RESULT([no])
1633])
1634
1635AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1636
1637
sewardje089f012010-10-13 21:47:29 +00001638# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1639# when building the tool executables. I think we should get rid of it.
1640#
sewardjb5f6f512005-03-10 23:59:00 +00001641# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00001642AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1643 [[return foo;]])],
1644 [vg_cv_linktime_tls=yes],
1645 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00001646# Native compilation: check whether running a program using TLS succeeds.
1647# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1648# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00001649# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00001650AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1651 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1652 [vg_cv_tls=$enableval],
1653 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1654 [[return foo;]])],
1655 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00001656 [vg_cv_tls=no],
1657 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00001658
1659if test "$vg_cv_tls" = yes; then
1660AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1661fi
sewardj5b754b42002-06-03 22:53:35 +00001662
sewardj535c50f2005-06-04 23:14:53 +00001663
njn7fd6d382009-01-22 21:56:32 +00001664#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001665# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001666#----------------------------------------------------------------------------
1667
sewardjde4a1d02002-03-22 01:27:54 +00001668AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001669AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001670 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001671 endian.h \
1672 mqueue.h \
1673 sys/endian.h \
1674 sys/epoll.h \
1675 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001676 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001677 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001678 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001679 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001680 sys/syscall.h \
1681 sys/time.h \
1682 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001683 ])
sewardjde4a1d02002-03-22 01:27:54 +00001684
bart818f17e2011-09-17 06:24:49 +00001685# Verify whether the <linux/futex.h> header is usable.
1686AC_MSG_CHECKING([if <linux/futex.h> is usable])
1687
bart417cf3e2011-10-22 09:21:24 +00001688AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00001689#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00001690]], [[
bart818f17e2011-09-17 06:24:49 +00001691 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00001692]])], [
bart78bfc712011-12-08 16:14:59 +00001693ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00001694AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1695 [Define to 1 if you have a usable <linux/futex.h> header file.])
1696AC_MSG_RESULT([yes])
1697], [
bart78bfc712011-12-08 16:14:59 +00001698ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00001699AC_MSG_RESULT([no])
1700])
1701
njn7fd6d382009-01-22 21:56:32 +00001702#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001703# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001704#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001705AC_TYPE_UID_T
1706AC_TYPE_OFF_T
1707AC_TYPE_SIZE_T
1708AC_HEADER_TIME
1709
sewardj535c50f2005-06-04 23:14:53 +00001710
njn7fd6d382009-01-22 21:56:32 +00001711#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001712# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001713#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001714AC_FUNC_MEMCMP
1715AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00001716
bart26288e42011-04-03 16:46:01 +00001717AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001718AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001719
bartf5ceec82008-04-26 07:45:10 +00001720AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001721 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001722 epoll_create \
1723 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001724 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001725 mallinfo \
1726 memchr \
1727 memset \
1728 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001729 mremap \
bartf5ceec82008-04-26 07:45:10 +00001730 ppoll \
bart6d45e922009-01-20 13:45:38 +00001731 pthread_barrier_init \
1732 pthread_condattr_setclock \
1733 pthread_mutex_timedlock \
1734 pthread_rwlock_timedrdlock \
1735 pthread_rwlock_timedwrlock \
1736 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001737 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001738 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001739 semtimedop \
1740 signalfd \
njn6cc22472009-03-16 03:46:48 +00001741 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001742 strchr \
1743 strdup \
1744 strpbrk \
1745 strrchr \
1746 strstr \
barta72a27b2010-04-29 06:22:17 +00001747 syscall \
bartf5ceec82008-04-26 07:45:10 +00001748 utimensat \
tom9e4b6362012-02-10 09:39:37 +00001749 process_vm_readv \
1750 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00001751 ])
sewardjde4a1d02002-03-22 01:27:54 +00001752
bart623eec32008-07-29 17:54:49 +00001753# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1754# libraries with any shared object and/or executable. This is NOT what we
1755# want for e.g. vgpreload_core-x86-linux.so
1756LIBS=""
sewardj80637752006-03-02 13:48:21 +00001757
bart6d45e922009-01-20 13:45:38 +00001758AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1759 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001760AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1761 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001762AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1763 [test x$ac_cv_func_pthread_spin_lock = xyes])
1764
njn7fd6d382009-01-22 21:56:32 +00001765
1766#----------------------------------------------------------------------------
1767# MPI checks
1768#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001769# Do we have a useable MPI setup on the primary and/or secondary targets?
1770# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001771# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001772# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001773# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001774MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001775
sewardje9fa5062006-03-12 18:29:18 +00001776mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001777if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001778 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1779 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001780 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001781elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001782 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1783 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001784 mflag_primary=$FLAG_M64
philippef7c54332012-05-17 15:32:54 +00001785elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
1786 mflag_primary="$FLAG_M32 -arch i386"
1787elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
1788 mflag_primary="$FLAG_M64 -arch x86_64"
sewardje9fa5062006-03-12 18:29:18 +00001789fi
1790
sewardj03d86f22006-10-17 00:57:24 +00001791mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001792if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1793 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001794 mflag_secondary=$FLAG_M32
philippef7c54332012-05-17 15:32:54 +00001795elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
1796 mflag_secondary="$FLAG_M32 -arch i386"
sewardj03d86f22006-10-17 00:57:24 +00001797fi
1798
1799
sewardj0ad46092006-03-02 17:09:16 +00001800AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001801 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001802 MPI_CC=$withval
1803)
sewardj03d86f22006-10-17 00:57:24 +00001804AC_SUBST(MPI_CC)
1805
philippef7c54332012-05-17 15:32:54 +00001806## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
1807## use these values in the check for a functioning mpicc.
1808##
1809## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
1810## mflag_primary/mflag_secondary are sufficient approximations of that behavior
1811AM_COND_IF([VGCONF_OS_IS_LINUX],
1812 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
1813 LDFLAGS_MPI="-fpic -shared"])
1814AM_COND_IF([VGCONF_OS_IS_DARWIN],
1815 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
1816 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
1817
1818AC_SUBST([CFLAGS_MPI])
1819AC_SUBST([LDFLAGS_MPI])
1820
1821
sewardj03d86f22006-10-17 00:57:24 +00001822## See if MPI_CC works for the primary target
1823##
1824AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001825saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001826saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001827CC=$MPI_CC
philippef7c54332012-05-17 15:32:54 +00001828CFLAGS="$CFLAGS_MPI $mflag_primary"
1829saved_LDFLAGS="$LDFLAGS"
1830LDFLAGS="$LDFLAGS_MPI $mflag_primary"
bart417cf3e2011-10-22 09:21:24 +00001831AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00001832#include <mpi.h>
1833#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001834]], [[
philippef7c54332012-05-17 15:32:54 +00001835 int ni, na, nd, comb;
sewardjde4f3842006-03-09 02:41:41 +00001836 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00001837 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
1838 r |= MPI_Finalize();
sewardjde4f3842006-03-09 02:41:41 +00001839 return r;
bart417cf3e2011-10-22 09:21:24 +00001840]])], [
sewardj03d86f22006-10-17 00:57:24 +00001841ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001842AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001843], [
sewardj03d86f22006-10-17 00:57:24 +00001844ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001845AC_MSG_RESULT([no])
1846])
sewardj0ad46092006-03-02 17:09:16 +00001847CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001848CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00001849LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00001850AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001851
sewardj03d86f22006-10-17 00:57:24 +00001852## See if MPI_CC works for the secondary target. Complication: what if
1853## there is no secondary target? We need this to then fail.
1854## Kludge this by making MPI_CC something which will surely fail in
1855## such a case.
1856##
1857AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1858saved_CC=$CC
1859saved_CFLAGS=$CFLAGS
philippef7c54332012-05-17 15:32:54 +00001860saved_LDFLAGS="$LDFLAGS"
1861LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
njn7fd6d382009-01-22 21:56:32 +00001862if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001863 CC="$MPI_CC this will surely fail"
1864else
1865 CC=$MPI_CC
1866fi
philippef7c54332012-05-17 15:32:54 +00001867CFLAGS="$CFLAGS_MPI $mflag_secondary"
bart417cf3e2011-10-22 09:21:24 +00001868AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00001869#include <mpi.h>
1870#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00001871]], [[
philippef7c54332012-05-17 15:32:54 +00001872 int ni, na, nd, comb;
sewardj03d86f22006-10-17 00:57:24 +00001873 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00001874 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
1875 r |= MPI_Finalize();
sewardj03d86f22006-10-17 00:57:24 +00001876 return r;
bart417cf3e2011-10-22 09:21:24 +00001877]])], [
sewardj03d86f22006-10-17 00:57:24 +00001878ac_have_mpi2_sec=yes
1879AC_MSG_RESULT([yes, $MPI_CC])
1880], [
1881ac_have_mpi2_sec=no
1882AC_MSG_RESULT([no])
1883])
1884CC=$saved_CC
1885CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00001886LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00001887AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001888
1889
njn7fd6d382009-01-22 21:56:32 +00001890#----------------------------------------------------------------------------
1891# Other library checks
1892#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00001893# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00001894# tests are present because Drd has some regression tests that use
1895# these packages. All regression test programs all compiled only
1896# for the primary target. And so it is important that the configure
1897# checks that follow, use the correct -m32 or -m64 flag for the
1898# primary target (called $mflag_primary). Otherwise, we can end up
1899# in a situation (eg) where, on amd64-linux, the test for Boost checks
1900# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1901# only build (meaning, the primary target is x86-linux), the build
1902# of the regtest programs that use Boost fails, because they are
1903# build as 32-bit (IN THIS EXAMPLE).
1904#
1905# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1906# NEEDED BY THE REGRESSION TEST PROGRAMS.
1907
1908
sewardj493c4ef2008-12-13 16:45:19 +00001909# Check whether the boost library 1.35 or later has been installed.
1910# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1911
1912AC_MSG_CHECKING([for boost])
1913
1914AC_LANG(C++)
1915safe_CXXFLAGS=$CXXFLAGS
bart7129c722012-04-18 18:34:22 +00001916CXXFLAGS="$mflag_primary"
1917safe_LIBS="$LIBS"
1918LIBS="-lboost_thread-mt $LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00001919
bart128fc522011-03-12 10:36:35 +00001920AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001921#include <boost/thread.hpp>
1922static void thread_func(void)
1923{ }
1924int main(int argc, char** argv)
1925{
1926 boost::thread t(thread_func);
1927 return 0;
1928}
bart128fc522011-03-12 10:36:35 +00001929])],
sewardj493c4ef2008-12-13 16:45:19 +00001930[
1931ac_have_boost_1_35=yes
1932AC_SUBST([BOOST_CFLAGS], [])
bartbb31f2d2012-04-18 18:42:34 +00001933AC_SUBST([BOOST_LIBS], [-lboost_thread-mt])
sewardj493c4ef2008-12-13 16:45:19 +00001934AC_MSG_RESULT([yes])
1935], [
1936ac_have_boost_1_35=no
1937AC_MSG_RESULT([no])
1938])
1939
bart7129c722012-04-18 18:34:22 +00001940LIBS="$safe_LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00001941CXXFLAGS=$safe_CXXFLAGS
1942AC_LANG(C)
1943
1944AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1945
1946
1947# does this compiler support -fopenmp, does it have the include file
1948# <omp.h> and does it have libgomp ?
1949
1950AC_MSG_CHECKING([for OpenMP])
1951
1952safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001953CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001954
bart128fc522011-03-12 10:36:35 +00001955AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00001956#include <omp.h>
1957int main(int argc, char** argv)
1958{
1959 omp_set_dynamic(0);
1960 return 0;
1961}
bart128fc522011-03-12 10:36:35 +00001962])],
sewardj493c4ef2008-12-13 16:45:19 +00001963[
1964ac_have_openmp=yes
1965AC_MSG_RESULT([yes])
1966], [
1967ac_have_openmp=no
1968AC_MSG_RESULT([no])
1969])
1970CFLAGS=$safe_CFLAGS
1971
1972AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1973
1974
bart78bfc712011-12-08 16:14:59 +00001975# does this compiler have built-in functions for atomic memory access for the
1976# primary target ?
1977AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00001978
1979safe_CFLAGS=$CFLAGS
1980CFLAGS="$mflag_primary"
1981
bart417cf3e2011-10-22 09:21:24 +00001982AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00001983 int variable = 1;
1984 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1985 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00001986]])], [
bartb4ff7822011-12-10 19:48:04 +00001987 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00001988 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00001989 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 +00001990], [
bartb4ff7822011-12-10 19:48:04 +00001991 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00001992 AC_MSG_RESULT([no])
1993])
1994
1995CFLAGS=$safe_CFLAGS
1996
bartb4ff7822011-12-10 19:48:04 +00001997AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
1998 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00001999
bart78bfc712011-12-08 16:14:59 +00002000
2001# does this compiler have built-in functions for atomic memory access for the
2002# secondary target ?
2003
2004if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2005
2006AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2007
2008safe_CFLAGS=$CFLAGS
2009CFLAGS="$mflag_secondary"
2010
2011AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2012 int variable = 1;
2013 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2014]])], [
2015 ac_have_builtin_atomic_secondary=yes
2016 AC_MSG_RESULT([yes])
2017], [
2018 ac_have_builtin_atomic_secondary=no
2019 AC_MSG_RESULT([no])
2020])
2021
2022CFLAGS=$safe_CFLAGS
2023
2024fi
2025
2026AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2027 [test x$ac_have_builtin_atomic_secondary = xyes])
2028
bart1e856ea2011-12-17 12:53:23 +00002029# does this compiler have built-in functions for atomic memory access on
2030# 64-bit integers for all targets ?
2031
2032AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2033
2034AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2035 #include <stdint.h>
2036]], [[
2037 uint64_t variable = 1;
2038 return __sync_add_and_fetch(&variable, 1)
2039]])], [
2040 ac_have_builtin_atomic64_primary=yes
2041], [
2042 ac_have_builtin_atomic64_primary=no
2043])
2044
2045if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2046
2047safe_CFLAGS=$CFLAGS
2048CFLAGS="$mflag_secondary"
2049
2050AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2051 #include <stdint.h>
2052]], [[
2053 uint64_t variable = 1;
2054 return __sync_add_and_fetch(&variable, 1)
2055]])], [
2056 ac_have_builtin_atomic64_secondary=yes
2057], [
2058 ac_have_builtin_atomic64_secondary=no
2059])
2060
2061CFLAGS=$safe_CFLAGS
2062
2063fi
2064
2065if test x$ac_have_builtin_atomic64_primary = xyes && \
2066 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2067 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2068 AC_MSG_RESULT([yes])
2069 ac_have_builtin_atomic64=yes
2070else
2071 AC_MSG_RESULT([no])
2072 ac_have_builtin_atomic64=no
2073fi
2074
2075AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2076 [test x$ac_have_builtin_atomic64 = xyes])
2077
bart78bfc712011-12-08 16:14:59 +00002078
barte8740422011-03-24 20:27:54 +00002079# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002080AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002081
2082safe_CXXFLAGS=$CXXFLAGS
2083CXXFLAGS="$mflag_primary"
2084
2085AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002086AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002087 int variable = 1;
2088 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2089 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002090]])], [
barte8740422011-03-24 20:27:54 +00002091 ac_have_builtin_atomic_cxx=yes
2092 AC_MSG_RESULT([yes])
2093 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 +00002094], [
barte8740422011-03-24 20:27:54 +00002095 ac_have_builtin_atomic_cxx=no
2096 AC_MSG_RESULT([no])
2097])
2098AC_LANG_POP(C++)
2099
2100CXXFLAGS=$safe_CXXFLAGS
2101
2102AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002103
bart78bfc712011-12-08 16:14:59 +00002104
2105if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002106 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002107 ac_enable_linux_ticket_lock_primary=yes
2108fi
2109AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2110 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2111
2112if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2113 -a x$ac_have_usable_linux_futex_h = xyes \
2114 -a x$ac_have_builtin_atomic_secondary = xyes; then
2115 ac_enable_linux_ticket_lock_secondary=yes
2116fi
2117AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2118 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2119
2120
bartf68af882011-12-10 19:42:05 +00002121# does libstdc++ support annotating shared pointers ?
2122AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2123
2124safe_CXXFLAGS=$CFLAGS
2125CXXFLAGS="-std=c++0x"
2126
2127AC_LANG_PUSH(C++)
2128AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2129 #include <memory>
2130]], [[
2131 std::shared_ptr<int> p
2132]])], [
2133 ac_have_shared_ptr=yes
2134], [
2135 ac_have_shared_ptr=no
2136])
2137if test x$ac_have_shared_ptr = xyes; then
2138 # If compilation of the program below fails because of a syntax error
2139 # triggered by substituting one of the annotation macros then that
2140 # means that libstdc++ supports these macros.
2141 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2142 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2143 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2144 #include <memory>
2145 ]], [[
2146 std::shared_ptr<int> p
2147 ]])], [
2148 ac_have_shared_pointer_annotation=no
2149 AC_MSG_RESULT([no])
2150 ], [
2151 ac_have_shared_pointer_annotation=yes
2152 AC_MSG_RESULT([yes])
2153 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2154 [Define to 1 if libstd++ supports annotating shared pointers])
2155 ])
2156else
2157 ac_have_shared_pointer_annotation=no
2158 AC_MSG_RESULT([no])
2159fi
2160AC_LANG_POP(C++)
2161
2162CXXFLAGS=$safe_CXXFLAGS
2163
2164AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2165 [test x$ac_have_shared_pointer_annotation = xyes])
2166
2167
njn7fd6d382009-01-22 21:56:32 +00002168#----------------------------------------------------------------------------
2169# Ok. We're done checking.
2170#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002171
njn8b68b642009-06-24 00:37:09 +00002172# Nb: VEX/Makefile is generated from Makefile.vex.in.
2173AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002174 Makefile
njn8b68b642009-06-24 00:37:09 +00002175 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002176 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002177 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002178 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002179 docs/Makefile
2180 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002181 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002182 perf/Makefile
2183 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002184 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002185 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002186 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002187 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002188 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002189 memcheck/Makefile
2190 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002191 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002192 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002193 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002194 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002195 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002196 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002197 memcheck/tests/ppc32/Makefile
2198 memcheck/tests/ppc64/Makefile
florian0bb707e2012-05-30 20:46:58 +00002199 memcheck/tests/s390x/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002200 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002201 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002202 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002203 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002204 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002205 callgrind/Makefile
2206 callgrind/callgrind_annotate
2207 callgrind/callgrind_control
2208 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002209 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002210 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002211 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002212 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002213 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002214 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002215 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002216 none/Makefile
2217 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002218 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002219 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002220 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002221 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002222 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002223 none/tests/s390x/Makefile
njn0458a122009-02-13 06:23:46 +00002224 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002225 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002226 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002227 exp-sgcheck/Makefile
2228 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002229 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002230 drd/scripts/download-and-build-splash2
2231 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002232 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002233 exp-bbv/tests/Makefile
2234 exp-bbv/tests/x86/Makefile
2235 exp-bbv/tests/x86-linux/Makefile
2236 exp-bbv/tests/amd64-linux/Makefile
2237 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002238 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002239 exp-dhat/Makefile
2240 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002241])
sewardjd3645802010-06-13 22:13:58 +00002242AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2243 [chmod +x coregrind/link_tool_exe_linux])
2244AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2245 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002246AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002247
2248cat<<EOF
2249
njn311303f2009-02-06 03:46:50 +00002250 Maximum build arch: ${ARCH_MAX}
2251 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002252 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002253 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002254 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2255 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002256 Platform variant: ${VGCONF_PLATVARIANT}
2257 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002258 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002259
gobry3b777892002-04-04 09:18:39 +00002260EOF