blob: 8e16bdaf3a72690e2a485d949b429cddca70d9e3 [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.
sewardj956b6d22014-09-02 10:30:12 +000011AC_INIT([Valgrind],[3.10.0.BETA1],[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])
sewardjf9a698e2013-09-02 12:44:52 +000014AM_INIT_AUTOMAKE([foreign subdir-objects])
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"
floriand79b3bf2013-10-02 15:14:59 +000022CXXFLAGS="-Wno-long-long $CXXFLAGS"
gobrye721a522002-03-22 13:38:30 +000023
sewardjde4a1d02002-03-22 01:27:54 +000024AC_PROG_LN_S
25AC_PROG_CC
bart0affa492008-03-18 17:53:09 +000026AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000027AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000028AC_PROG_CXX
njn629a5ec2009-07-14 01:29:39 +000029# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
30# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
31# base (eg. most likely as Darwin-specific tests) we'll need one of the
32# following:
njn0cd26892009-07-12 23:07:13 +000033# - put AC_PROG_OBJC in a Darwin-specific part of this file
34# - Use AC_PROG_OBJC here and up the minimum autoconf version
35# - Use the following, which is apparently equivalent:
36# m4_ifdef([AC_PROG_OBJC],
37# [AC_PROG_OBJC],
38# [AC_CHECK_TOOL([OBJC], [gcc])
39# AC_SUBST([OBJC])
40# AC_SUBST([OBJCFLAGS])
41# ])
sewardjde4a1d02002-03-22 01:27:54 +000042AC_PROG_RANLIB
bart07de2c92010-05-29 06:44:28 +000043# provide a very basic definition for AC_PROG_SED if it's not provided by
44# autoconf (as e.g. in autoconf 2.59).
45m4_ifndef([AC_PROG_SED],
46 [AC_DEFUN([AC_PROG_SED],
47 [AC_ARG_VAR([SED])
48 AC_CHECK_PROGS([SED],[gsed sed])])])
bart12e91122010-05-15 08:37:24 +000049AC_PROG_SED
sewardjde4a1d02002-03-22 01:27:54 +000050
bartcddeaf52008-05-25 15:58:11 +000051# If no AR variable was specified, look up the name of the archiver. Otherwise
52# do not touch the AR variable.
53if test "x$AR" = "x"; then
bart07de2c92010-05-29 06:44:28 +000054 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
bartcddeaf52008-05-25 15:58:11 +000055fi
56AC_ARG_VAR([AR],[Archiver command])
57
gobrye721a522002-03-22 13:38:30 +000058# Check for the compiler support
59if test "${GCC}" != "yes" ; then
60 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
61fi
62
sewardj2f685952002-12-22 19:32:23 +000063# figure out where perl lives
64AC_PATH_PROG(PERL, perl)
65
njn9315df32003-04-16 20:50:50 +000066# figure out where gdb lives
sewardjf8722ca2008-11-17 00:20:45 +000067AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
njnfe408942004-11-23 17:52:24 +000068AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000069
daywalker48ccca52002-04-15 00:31:58 +000070# some older automake's don't have it so try something on our own
71ifdef([AM_PROG_AS],[AM_PROG_AS],
72[
gobry1be19852002-03-26 20:44:55 +000073AS="${CC}"
74AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000075
gobry1be19852002-03-26 20:44:55 +000076ASFLAGS=""
77AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000078])
gobry3b777892002-04-04 09:18:39 +000079
gobry3b777892002-04-04 09:18:39 +000080
njn0d2e58f2009-02-25 04:57:56 +000081# Check if 'diff' supports -u (universal diffs) and use it if possible.
82
83AC_MSG_CHECKING([for diff -u])
84AC_SUBST(DIFF)
85
sewardj6e9de462011-06-28 07:25:29 +000086# Comparing two identical files results in 0.
njn31f665e2009-02-26 21:25:50 +000087tmpfile="tmp-xxx-yyy-zzz"
88touch $tmpfile;
89if diff -u $tmpfile $tmpfile ; then
njn0d2e58f2009-02-25 04:57:56 +000090 AC_MSG_RESULT([yes])
91 DIFF="diff -u"
92else
93 AC_MSG_RESULT([no])
94 DIFF="diff"
95fi
njn31f665e2009-02-26 21:25:50 +000096rm $tmpfile
njn0d2e58f2009-02-25 04:57:56 +000097
98
sewardj535c50f2005-06-04 23:14:53 +000099# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +0000100AC_MSG_CHECKING([for a supported version of gcc])
101
bart85037442011-11-22 14:41:31 +0000102# Obtain the compiler version.
sewardja8ca2c52011-09-29 18:18:37 +0000103#
bart85037442011-11-22 14:41:31 +0000104# A few examples of how the ${CC} --version output looks like:
105#
106# Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
107# Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
108# openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
109# Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
bartc5214062012-01-11 11:34:23 +0000110# MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
bart85037442011-11-22 14:41:31 +0000111# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
112# 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)
113# Clang: clang version 2.9 (tags/RELEASE_29/final)
bart048081f2012-06-17 05:53:02 +0000114# Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
115# FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
sewardja8ca2c52011-09-29 18:18:37 +0000116#
bartc5214062012-01-11 11:34:23 +0000117[
bart048081f2012-06-17 05:53:02 +0000118if test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ; then
119 is_clang="clang"
120 # Don't use -dumpversion with clang: it will always produce "4.2.1".
121 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
florian3d9368e2013-10-04 21:12:17 +0000122 CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
123 CXXFLAGS="$CXXFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
bart048081f2012-06-17 05:53:02 +0000124else
125 is_clang="notclang"
126 gcc_version=`${CC} -dumpversion 2>/dev/null`
127 if test "x$gcc_version" = x; then
128 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
129 fi
sewardj3ab7b662011-09-29 17:30:13 +0000130fi
bart048081f2012-06-17 05:53:02 +0000131]
florian3d9368e2013-10-04 21:12:17 +0000132AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang)
sewardj3ab7b662011-09-29 17:30:13 +0000133
134case "${is_clang}-${gcc_version}" in
135 notclang-3.*)
136 AC_MSG_RESULT([ok (${gcc_version})])
137 ;;
138 notclang-4.*)
139 AC_MSG_RESULT([ok (${gcc_version})])
140 ;;
mjwa384c3f2014-09-10 00:52:30 +0000141 notclang-5.*)
142 AC_MSG_RESULT([ok (${gcc_version})])
143 ;;
sewardjae284e52012-08-02 18:25:04 +0000144 clang-2.9|clang-3.*|clang-4.*)
sewardj3ab7b662011-09-29 17:30:13 +0000145 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000146 ;;
gobrye721a522002-03-22 13:38:30 +0000147 *)
sewardj3ab7b662011-09-29 17:30:13 +0000148 AC_MSG_RESULT([no (${gcc_version})])
149 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000150 ;;
151esac
152
njn7fd6d382009-01-22 21:56:32 +0000153#----------------------------------------------------------------------------
154# Arch/OS/platform tests.
155#----------------------------------------------------------------------------
156# We create a number of arch/OS/platform-related variables. We prefix them
157# all with "VGCONF_" which indicates that they are defined at
158# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
159# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000160
sewardjde4a1d02002-03-22 01:27:54 +0000161AC_CANONICAL_HOST
162
163AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000164
njn7fd6d382009-01-22 21:56:32 +0000165# ARCH_MAX reflects the most that this CPU can do: for example if it
166# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
167# Ditto for amd64. It is used for more configuration below, but is not used
168# outside this file.
carllcae0cc22014-08-07 23:17:29 +0000169#
170# Power PC returns powerpc for Big Endian. This was not changed when Little
171# Endian support was added to the 64-bit architecture. The 64-bit Little
172# Endian systems explicitly state le in the host_cpu. For clarity in the
173# Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of
174# the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
175# The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
176# Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess.
177# The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
178# Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
179# Little Endian.
180
gobrye721a522002-03-22 13:38:30 +0000181case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000182 i?86)
183 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000184 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000185 ;;
186
njnfe408942004-11-23 17:52:24 +0000187 x86_64)
188 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000189 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000190 ;;
191
sewardj2c48c7b2005-11-29 13:05:56 +0000192 powerpc64)
carllcae0cc22014-08-07 23:17:29 +0000193 # this only referrs to 64-bit Big Endian
sewardj2c48c7b2005-11-29 13:05:56 +0000194 AC_MSG_RESULT([ok (${host_cpu})])
carllcae0cc22014-08-07 23:17:29 +0000195 ARCH_MAX="ppc64be"
196 ;;
197
198 powerpc64le)
199 # this only referrs to 64-bit Little Endian
200 AC_MSG_RESULT([ok (${host_cpu})])
201 ARCH_MAX="ppc64le"
sewardj2c48c7b2005-11-29 13:05:56 +0000202 ;;
203
204 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000205 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000206 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000207 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000208 ;;
209
sewardjb5b87402011-03-07 16:05:35 +0000210 s390x)
211 AC_MSG_RESULT([ok (${host_cpu})])
212 ARCH_MAX="s390x"
213 ;;
214
sewardj59570ff2010-01-01 11:59:33 +0000215 armv7*)
216 AC_MSG_RESULT([ok (${host_cpu})])
217 ARCH_MAX="arm"
218 ;;
219
sewardjf0c12502014-01-12 12:54:00 +0000220 aarch64*)
221 AC_MSG_RESULT([ok (${host_cpu})])
222 ARCH_MAX="arm64"
223 ;;
224
sewardj5db15402012-06-07 09:13:21 +0000225 mips)
petarj4df0bfc2013-02-27 23:17:33 +0000226 AC_MSG_RESULT([ok (${host_cpu})])
227 ARCH_MAX="mips32"
228 ;;
sewardj5db15402012-06-07 09:13:21 +0000229
230 mipsel)
petarj4df0bfc2013-02-27 23:17:33 +0000231 AC_MSG_RESULT([ok (${host_cpu})])
232 ARCH_MAX="mips32"
233 ;;
sewardj5db15402012-06-07 09:13:21 +0000234
235 mipsisa32r2)
petarj4df0bfc2013-02-27 23:17:33 +0000236 AC_MSG_RESULT([ok (${host_cpu})])
237 ARCH_MAX="mips32"
238 ;;
sewardj5db15402012-06-07 09:13:21 +0000239
petarj4df0bfc2013-02-27 23:17:33 +0000240 mips64*)
241 AC_MSG_RESULT([ok (${host_cpu})])
242 ARCH_MAX="mips64"
243 ;;
244
245 mipsisa64*)
246 AC_MSG_RESULT([ok (${host_cpu})])
247 ARCH_MAX="mips64"
248 ;;
sewardjde4a1d02002-03-22 01:27:54 +0000249 *)
250 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000251 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000252 ;;
253esac
254
njn7fd6d382009-01-22 21:56:32 +0000255#----------------------------------------------------------------------------
256
sewardj86e992f2006-01-28 18:39:09 +0000257# Sometimes it's convenient to subvert the bi-arch build system and
258# just have a single build even though the underlying platform is
259# capable of both. Hence handle --enable-only64bit and
260# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000261# [Actually, if either of these options are used, I think both get built,
262# but only one gets installed. So if you use an in-place build, both can be
263# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000264
265# Check if a 64-bit only build has been requested
266AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
267 [AC_ARG_ENABLE(only64bit,
268 [ --enable-only64bit do a 64-bit only build],
269 [vg_cv_only64bit=$enableval],
270 [vg_cv_only64bit=no])])
271
272# Check if a 32-bit only build has been requested
273AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
274 [AC_ARG_ENABLE(only32bit,
275 [ --enable-only32bit do a 32-bit only build],
276 [vg_cv_only32bit=$enableval],
277 [vg_cv_only32bit=no])])
278
279# Stay sane
280if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
281 AC_MSG_ERROR(
282 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
283fi
284
njn7fd6d382009-01-22 21:56:32 +0000285#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000286
njn311303f2009-02-06 03:46:50 +0000287# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
288# compilation of many C files via -VGO_$(VGCONF_OS) and
289# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000290AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000291AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000292
njnf76d27a2009-05-28 01:53:07 +0000293DEFAULT_SUPP=""
294
gobrye721a522002-03-22 13:38:30 +0000295case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000296 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000297 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000298 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000299
300 # Ok, this is linux. Check the kernel version
301 AC_MSG_CHECKING([for the kernel version])
302
303 kernel=`uname -r`
304
305 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000306 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000307 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
308 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 +0000309 ;;
310
311 2.4.*)
312 AC_MSG_RESULT([2.4 family (${kernel})])
313 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
314 ;;
315
mueller8c68e042004-01-03 15:21:14 +0000316 *)
317 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000318 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000319 ;;
320 esac
321
322 ;;
323
njnf76d27a2009-05-28 01:53:07 +0000324 *darwin*)
325 AC_MSG_RESULT([ok (${host_os})])
326 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000327 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
328 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
329 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
sewardjae284e52012-08-02 18:25:04 +0000330 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
sewardjec66ad52014-06-20 11:48:38 +0000331 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
njnf76d27a2009-05-28 01:53:07 +0000332
333 AC_MSG_CHECKING([for the kernel version])
334 kernel=`uname -r`
335
336 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
337 # has only one relevant version, the OS version. The `uname` check
338 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000339 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
340 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000341 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000342 #
343 # XXX: `uname -r` won't do the right thing for cross-compiles, but
344 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000345 #
346 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
347 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
348 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
349 # time support for 10.5 (the 9.* pattern just below), I'll leave it
350 # in for now, just in case anybody wants to give it a try. But I'm
351 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000352 case "${kernel}" in
353 9.*)
354 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000355 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000356 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000357 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000358 ;;
njnea2d6fd2010-07-01 00:20:20 +0000359 10.*)
360 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
361 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
362 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
363 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
364 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000365 11.*)
366 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
367 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
sewardj731f9cf2011-09-21 08:43:08 +0000368 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
369 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
370 ;;
sewardjae284e52012-08-02 18:25:04 +0000371 12.*)
372 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
373 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
374 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
375 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
376 ;;
sewardjec66ad52014-06-20 11:48:38 +0000377 13.*)
378 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
379 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
380 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
381 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
382 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000383 *)
njnf76d27a2009-05-28 01:53:07 +0000384 AC_MSG_RESULT([unsupported (${kernel})])
sewardjec66ad52014-06-20 11:48:38 +0000385 AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x and 13.x (Mac OS X 10.6/7/8/9)])
njnf76d27a2009-05-28 01:53:07 +0000386 ;;
387 esac
388 ;;
389
sewardjde4a1d02002-03-22 01:27:54 +0000390 *)
391 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000392 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000393 ;;
394esac
395
njn7fd6d382009-01-22 21:56:32 +0000396#----------------------------------------------------------------------------
397
tomd6398392006-06-07 17:44:36 +0000398# If we are building on a 64 bit platform test to see if the system
399# supports building 32 bit programs and disable 32 bit support if it
400# does not support building 32 bit programs
401
njn7fd6d382009-01-22 21:56:32 +0000402case "$ARCH_MAX-$VGCONF_OS" in
mjw676bf0d2014-08-27 18:29:34 +0000403 amd64-linux|ppc64be-linux|arm64-linux)
tomd6398392006-06-07 17:44:36 +0000404 AC_MSG_CHECKING([for 32 bit build support])
405 safe_CFLAGS=$CFLAGS
406 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000407 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000408 return 0;
bart417cf3e2011-10-22 09:21:24 +0000409 ]])], [
tomd6398392006-06-07 17:44:36 +0000410 AC_MSG_RESULT([yes])
411 ], [
412 vg_cv_only64bit="yes"
413 AC_MSG_RESULT([no])
414 ])
415 CFLAGS=$safe_CFLAGS;;
416esac
417
418if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
419 AC_MSG_ERROR(
420 [--enable-only32bit was specified but system does not support 32 bit builds])
421fi
nethercote888ecb72004-08-23 14:54:40 +0000422
njn7fd6d382009-01-22 21:56:32 +0000423#----------------------------------------------------------------------------
424
njn311303f2009-02-06 03:46:50 +0000425# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
426# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
427# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
428# above) will be "amd64" since that reflects the most that this cpu can do,
429# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
430# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000431# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
432# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
433AC_SUBST(VGCONF_ARCH_PRI)
434
njn3f8a6e92009-06-02 00:20:47 +0000435# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
436# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
437# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
438# It is empty if there is no secondary target.
439AC_SUBST(VGCONF_ARCH_SEC)
440
njn311303f2009-02-06 03:46:50 +0000441# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
442# The entire system, including regression and performance tests, will be
443# built for this target. The "_CAPS" indicates that the name is in capital
444# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000445# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000446# convention and cannot contain '-' characters. This is in contrast to
447# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000448AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
449
450# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
451# Valgrind and tools will also be built for this target, but not the
452# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000453#
njn7fd6d382009-01-22 21:56:32 +0000454# By default, the primary arch is the same as the "max" arch, as commented
455# above (at the definition of ARCH_MAX). We may choose to downgrade it in
456# the big case statement just below here, in the case where we're building
457# on a 64 bit machine but have been requested only to do a 32 bit build.
458AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
459
sewardj01262142006-01-04 01:20:28 +0000460AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000461
njnea2d6fd2010-07-01 00:20:20 +0000462# NB. The load address for a given platform may be specified in more
463# than one place, in some cases, depending on whether we're doing a biarch,
464# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
465# Be careful to give consistent values in all subcases. Also, all four
466# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
467# even if it is to "0xUNSET".
468#
njn7fd6d382009-01-22 21:56:32 +0000469case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000470 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000471 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000472 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000473 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
474 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000475 valt_load_address_pri_norml="0x38000000"
476 valt_load_address_pri_inner="0x28000000"
477 valt_load_address_sec_norml="0xUNSET"
478 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000479 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000480 ;;
481 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000482 valt_load_address_sec_norml="0xUNSET"
483 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000484 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000485 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000486 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000487 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
488 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000489 valt_load_address_pri_norml="0x38000000"
490 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000491 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000492 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000493 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000494 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
495 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000496 valt_load_address_pri_norml="0x38000000"
497 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000498 else
njn7fd6d382009-01-22 21:56:32 +0000499 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000500 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000501 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
502 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000503 valt_load_address_pri_norml="0x38000000"
504 valt_load_address_pri_inner="0x28000000"
505 valt_load_address_sec_norml="0x38000000"
506 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000507 fi
njn377c43f2009-05-19 07:39:22 +0000508 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000509 ;;
510 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000511 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000512 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000513 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
514 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000515 valt_load_address_pri_norml="0x38000000"
516 valt_load_address_pri_inner="0x28000000"
517 valt_load_address_sec_norml="0xUNSET"
518 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000519 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000520 ;;
carllcae0cc22014-08-07 23:17:29 +0000521 ppc64be-linux)
njnea2d6fd2010-07-01 00:20:20 +0000522 valt_load_address_sec_norml="0xUNSET"
523 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000524 if test x$vg_cv_only64bit = xyes; then
carllcae0cc22014-08-07 23:17:29 +0000525 VGCONF_ARCH_PRI="ppc64be"
njn3f8a6e92009-06-02 00:20:47 +0000526 VGCONF_ARCH_SEC=""
carllcae0cc22014-08-07 23:17:29 +0000527 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
njn7fd6d382009-01-22 21:56:32 +0000528 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000529 valt_load_address_pri_norml="0x38000000"
530 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000531 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000532 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000533 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000534 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
535 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000536 valt_load_address_pri_norml="0x38000000"
537 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000538 else
carllcae0cc22014-08-07 23:17:29 +0000539 VGCONF_ARCH_PRI="ppc64be"
njn3f8a6e92009-06-02 00:20:47 +0000540 VGCONF_ARCH_SEC="ppc32"
carllcae0cc22014-08-07 23:17:29 +0000541 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
njn7fd6d382009-01-22 21:56:32 +0000542 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000543 valt_load_address_pri_norml="0x38000000"
544 valt_load_address_pri_inner="0x28000000"
545 valt_load_address_sec_norml="0x38000000"
546 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000547 fi
njn377c43f2009-05-19 07:39:22 +0000548 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000549 ;;
carllcae0cc22014-08-07 23:17:29 +0000550 ppc64le-linux)
551 # Little Endian is only supported on PPC64
552 valt_load_address_sec_norml="0xUNSET"
553 valt_load_address_sec_inner="0xUNSET"
554 VGCONF_ARCH_PRI="ppc64le"
555 VGCONF_ARCH_SEC=""
556 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
557 VGCONF_PLATFORM_SEC_CAPS=""
558 valt_load_address_pri_norml="0x38000000"
559 valt_load_address_pri_inner="0x28000000"
560 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
561 ;;
njncc58cea2010-07-05 07:21:22 +0000562 # Darwin gets identified as 32-bit even when it supports 64-bit.
563 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
564 # all Macs support both 32-bit and 64-bit, so we just build both. If
565 # someone has a really old 32-bit only machine they can (hopefully?)
566 # build with --enable-only32bit. See bug 243362.
567 x86-darwin|amd64-darwin)
568 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000569 valt_load_address_sec_norml="0xUNSET"
570 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000571 if test x$vg_cv_only64bit = xyes; then
572 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000573 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000574 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
575 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000576 valt_load_address_pri_norml="0x138000000"
577 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000578 elif test x$vg_cv_only32bit = xyes; then
579 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000580 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000581 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
582 VGCONF_PLATFORM_SEC_CAPS=""
583 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000584 valt_load_address_pri_norml="0x38000000"
585 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000586 else
587 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000588 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000589 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
590 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000591 valt_load_address_pri_norml="0x138000000"
592 valt_load_address_pri_inner="0x128000000"
593 valt_load_address_sec_norml="0x38000000"
594 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000595 fi
njnf76d27a2009-05-28 01:53:07 +0000596 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
597 ;;
sewardj59570ff2010-01-01 11:59:33 +0000598 arm-linux)
599 VGCONF_ARCH_PRI="arm"
600 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
601 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000602 valt_load_address_pri_norml="0x38000000"
603 valt_load_address_pri_inner="0x28000000"
604 valt_load_address_sec_norml="0xUNSET"
605 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000606 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
607 ;;
sewardjf0c12502014-01-12 12:54:00 +0000608 arm64-linux)
609 valt_load_address_sec_norml="0xUNSET"
610 valt_load_address_sec_inner="0xUNSET"
611 if test x$vg_cv_only64bit = xyes; then
612 VGCONF_ARCH_PRI="arm64"
613 VGCONF_ARCH_SEC=""
614 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
615 VGCONF_PLATFORM_SEC_CAPS=""
616 valt_load_address_pri_norml="0x38000000"
617 valt_load_address_pri_inner="0x28000000"
618 elif test x$vg_cv_only32bit = xyes; then
619 VGCONF_ARCH_PRI="arm"
620 VGCONF_ARCH_SEC=""
621 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
622 VGCONF_PLATFORM_SEC_CAPS=""
623 valt_load_address_pri_norml="0x38000000"
624 valt_load_address_pri_inner="0x28000000"
625 else
626 VGCONF_ARCH_PRI="arm64"
627 VGCONF_ARCH_SEC="arm"
628 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
629 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
630 valt_load_address_pri_norml="0x38000000"
631 valt_load_address_pri_inner="0x28000000"
632 valt_load_address_sec_norml="0x38000000"
633 valt_load_address_sec_inner="0x28000000"
634 fi
635 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
636 ;;
sewardjb5b87402011-03-07 16:05:35 +0000637 s390x-linux)
638 VGCONF_ARCH_PRI="s390x"
639 VGCONF_ARCH_SEC=""
640 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
641 VGCONF_PLATFORM_SEC_CAPS=""
cborntraf4c46902013-10-23 16:23:30 +0000642 # To improve branch prediction hit rate we want to have
643 # the generated code close to valgrind (host) code
644 valt_load_address_pri_norml="0x800000000"
645 valt_load_address_pri_inner="0x810000000"
sewardjb5b87402011-03-07 16:05:35 +0000646 valt_load_address_sec_norml="0xUNSET"
647 valt_load_address_sec_inner="0xUNSET"
648 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
649 ;;
sewardj5db15402012-06-07 09:13:21 +0000650 mips32-linux)
651 VGCONF_ARCH_PRI="mips32"
652 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
653 VGCONF_PLATFORM_SEC_CAPS=""
654 valt_load_address_pri_norml="0x38000000"
655 valt_load_address_pri_inner="0x28000000"
656 valt_load_address_sec_norml="0xUNSET"
657 valt_load_address_sec_inner="0xUNSET"
658 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
petarj4df0bfc2013-02-27 23:17:33 +0000659 ;;
660 mips64-linux)
661 VGCONF_ARCH_PRI="mips64"
662 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
663 VGCONF_PLATFORM_SEC_CAPS=""
664 valt_load_address_pri_norml="0x38000000"
665 valt_load_address_pri_inner="0x28000000"
666 valt_load_address_sec_norml="0xUNSET"
667 valt_load_address_sec_inner="0xUNSET"
668 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj5db15402012-06-07 09:13:21 +0000669 ;;
nethercote888ecb72004-08-23 14:54:40 +0000670 *)
njn7fd6d382009-01-22 21:56:32 +0000671 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000672 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000673 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
674 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000675 valt_load_address_pri_norml="0xUNSET"
676 valt_load_address_pri_inner="0xUNSET"
677 valt_load_address_sec_norml="0xUNSET"
678 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000679 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000680 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000681 ;;
682esac
sewardjde4a1d02002-03-22 01:27:54 +0000683
njn7fd6d382009-01-22 21:56:32 +0000684#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000685
njn7fd6d382009-01-22 21:56:32 +0000686# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
687# defined.
688AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
689 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000690 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
691 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
692 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000693AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000694 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
695 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000696AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
697 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000698 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000699AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
carllcae0cc22014-08-07 23:17:29 +0000700 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
701 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000702AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
sewardjf0c12502014-01-12 12:54:00 +0000703 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
704 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
705AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
706 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000707AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
708 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj5db15402012-06-07 09:13:21 +0000709AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
710 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
petarj4df0bfc2013-02-27 23:17:33 +0000711AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
712 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000713
njn7fd6d382009-01-22 21:56:32 +0000714# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
715# become defined.
716AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
717 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
718 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
719AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
720 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
721AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
722 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
723 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
carllcae0cc22014-08-07 23:17:29 +0000724AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
725 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
726AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
727 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000728AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
sewardjf0c12502014-01-12 12:54:00 +0000729 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
730 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
731AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
732 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000733AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
734 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
735 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
sewardj5db15402012-06-07 09:13:21 +0000736AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
737 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
petarj4df0bfc2013-02-27 23:17:33 +0000738AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
739 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000740AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
741 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
742 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
743AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
744 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
745
746
sewardj72a2d802010-07-29 05:24:20 +0000747# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000748# Relies on the assumption that the primary and secondary targets are
749# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000750AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
751 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
752 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
753 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
carllcae0cc22014-08-07 23:17:29 +0000754 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
755 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000756 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
sewardjf0c12502014-01-12 12:54:00 +0000757 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardj5db15402012-06-07 09:13:21 +0000758 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +0000759 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
760 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000761AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
762 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
763 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000764
765
njn7fd6d382009-01-22 21:56:32 +0000766# Sometimes, in the Makefile.am files, it's useful to know whether or not
767# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000768AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000769 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000770
philippef32cbe82012-05-18 16:48:20 +0000771dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
772dnl fallback definition
773dnl The macro is courtesy of Dave Hart:
774dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
775m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
776if test -z "$$1_TRUE"; then :
777 m4_n([$2])[]dnl
778m4_ifval([$3],
779[else
780 $3
781])dnl
782fi[]dnl
783])])
tomb637bad2005-11-08 12:28:35 +0000784
njn7fd6d382009-01-22 21:56:32 +0000785#----------------------------------------------------------------------------
786# Inner Valgrind?
787#----------------------------------------------------------------------------
788
njnd74b0ef2009-01-20 06:06:52 +0000789# Check if this should be built as an inner Valgrind, to be run within
790# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000791AC_SUBST(VALT_LOAD_ADDRESS_PRI)
792AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000793AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
794 [AC_ARG_ENABLE(inner,
795 [ --enable-inner enables self-hosting],
796 [vg_cv_inner=$enableval],
797 [vg_cv_inner=no])])
798if test "$vg_cv_inner" = yes; then
799 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000800 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
801 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000802else
njnea2d6fd2010-07-01 00:20:20 +0000803 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
804 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000805fi
806
807
njn7fd6d382009-01-22 21:56:32 +0000808#----------------------------------------------------------------------------
sewardj5db15402012-06-07 09:13:21 +0000809# Define MIPS_PAGE_SHIFT (--with-pagesize)
810#----------------------------------------------------------------------------
811AC_ARG_WITH(pagesize,
812 [ --with-pagesize= override detected page size (4, 16 or 64)],
813 [psize=$withval],
814 [psize=0]
815)
816
817if test "$psize" = "0"; then
818 psizer=`getconf PAGESIZE`
florian62477d22014-02-22 13:24:15 +0000819 psize=$((${psizer}/1024))
sewardj5db15402012-06-07 09:13:21 +0000820fi
821
822if test "$psize" = "4"; then
823 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
824elif test "$psize" = "16"; then
825 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
826elif test "$psize" = "64"; then
827 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
828else
829 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
830fi
831AC_MSG_RESULT([checking for Pagesize... ${psize}k])
832
sewardj5db15402012-06-07 09:13:21 +0000833
834#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000835# Extra fine-tuning of installation directories
836#----------------------------------------------------------------------------
837AC_ARG_WITH(tmpdir,
838 [ --with-tmpdir=PATH Specify path for temporary files],
839 tmpdir="$withval",
840 tmpdir="/tmp")
841AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
florian7fd2ec32014-06-21 20:25:30 +0000842AC_SUBST(VG_TMPDIR, [$tmpdir])
sewardjcb495c82011-07-11 20:42:34 +0000843
sewardj0ba37c92011-07-12 11:46:24 +0000844
sewardjcb495c82011-07-11 20:42:34 +0000845#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000846# Libc and suppressions
847#----------------------------------------------------------------------------
848# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000849AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000850
bart12e91122010-05-15 08:37:24 +0000851AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000852
bart12e91122010-05-15 08:37:24 +0000853if test x$ac_cv_header_features_h = xyes; then
854 rm -f conftest.$ac_ext
855 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000856#include <features.h>
bart12e91122010-05-15 08:37:24 +0000857#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
858glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000859#endif
bart12e91122010-05-15 08:37:24 +0000860_ACEOF
mjwa384c3f2014-09-10 00:52:30 +0000861 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
bart12e91122010-05-15 08:37:24 +0000862fi
bartb7c3f082010-05-13 06:32:36 +0000863
njnf76d27a2009-05-28 01:53:07 +0000864# not really a version check
865AC_EGREP_CPP([DARWIN_LIBC], [
866#include <sys/cdefs.h>
867#if defined(__DARWIN_VERS_1050)
868 DARWIN_LIBC
869#endif
870],
871GLIBC_VERSION="darwin")
872
sewardjcb495c82011-07-11 20:42:34 +0000873# not really a version check
874AC_EGREP_CPP([BIONIC_LIBC], [
875#if defined(__ANDROID__)
876 BIONIC_LIBC
877#endif
878],
879GLIBC_VERSION="bionic")
880
881
dirk07596a22008-04-25 11:33:30 +0000882AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000883
dirk07596a22008-04-25 11:33:30 +0000884case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000885 2.2)
886 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000887 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000888 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
889 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000890 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000891 ;;
892
sewardj08c7f012002-10-07 23:56:55 +0000893 2.3)
894 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000895 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000896 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000897 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000898 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000899 ;;
900
njn781dba52005-06-30 04:06:38 +0000901 2.4)
902 AC_MSG_RESULT(2.4 family)
903 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000904 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000905 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000906 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000907 ;;
908
dirkaece45c2006-10-12 08:17:49 +0000909 2.5)
910 AC_MSG_RESULT(2.5 family)
911 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000912 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000913 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000914 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000915 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000916 2.6)
917 AC_MSG_RESULT(2.6 family)
918 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000919 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000920 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000921 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000922 ;;
923 2.7)
924 AC_MSG_RESULT(2.7 family)
925 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000926 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000927 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000928 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000929 ;;
dirk07596a22008-04-25 11:33:30 +0000930 2.8)
931 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000932 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000933 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
934 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
935 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
936 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000937 2.9)
938 AC_MSG_RESULT(2.9 family)
939 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
940 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
941 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
942 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
943 ;;
sewardj5d425e82009-02-01 19:01:11 +0000944 2.10)
945 AC_MSG_RESULT(2.10 family)
946 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
947 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
948 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
949 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
950 ;;
bart0fac7ff2009-11-15 19:11:19 +0000951 2.11)
952 AC_MSG_RESULT(2.11 family)
953 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
954 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
955 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
956 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000957 ;;
958 2.12)
959 AC_MSG_RESULT(2.12 family)
960 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
961 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
962 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
963 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000964 ;;
tomebd619b2011-02-10 09:09:09 +0000965 2.13)
966 AC_MSG_RESULT(2.13 family)
967 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
968 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
969 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
970 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
971 ;;
tomcc077412011-06-07 21:52:26 +0000972 2.14)
973 AC_MSG_RESULT(2.14 family)
974 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
975 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
976 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
977 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
978 ;;
dirke75fdeb2011-12-29 08:24:55 +0000979 2.15)
980 AC_MSG_RESULT(2.15 family)
981 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
982 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
983 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
984 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
985 ;;
sewardjc7188be2012-07-14 10:07:06 +0000986 2.16)
987 AC_MSG_RESULT(2.16 family)
988 AC_DEFINE([GLIBC_2_16], 1, [Define to 1 if you're using glibc 2.16.x])
989 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
990 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
991 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
992 ;;
tom3781ac12013-01-14 09:48:49 +0000993 2.17)
994 AC_MSG_RESULT(2.17 family)
995 AC_DEFINE([GLIBC_2_17], 1, [Define to 1 if you're using glibc 2.17.x])
996 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
997 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
998 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
999 ;;
mjw317f01b2013-08-21 14:47:52 +00001000 2.18)
1001 AC_MSG_RESULT(2.18 family)
1002 AC_DEFINE([GLIBC_2_18], 1, [Define to 1 if you're using glibc 2.18.x])
1003 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1004 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1005 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1006 ;;
mjw28ae1992014-02-21 21:13:55 +00001007 2.19)
1008 AC_MSG_RESULT(2.19 family)
1009 AC_DEFINE([GLIBC_2_19], 1, [Define to 1 if you're using glibc 2.19.x])
1010 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1011 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1012 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1013 ;;
mjwedd30332014-09-08 23:41:31 +00001014 2.20)
1015 AC_MSG_RESULT(2.20 family)
1016 AC_DEFINE([GLIBC_2_20], 1, [Define to 1 if you're using glibc 2.20.x])
1017 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1018 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1019 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1020 ;;
njnf76d27a2009-05-28 01:53:07 +00001021 darwin)
1022 AC_MSG_RESULT(Darwin)
1023 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1024 # DEFAULT_SUPP set by kernel version check above.
1025 ;;
sewardjcb495c82011-07-11 20:42:34 +00001026 bionic)
1027 AC_MSG_RESULT(Bionic)
1028 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1029 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1030 ;;
dirkaece45c2006-10-12 08:17:49 +00001031
sewardjde4a1d02002-03-22 01:27:54 +00001032 *)
bart12e91122010-05-15 08:37:24 +00001033 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
mjw28ae1992014-02-21 21:13:55 +00001034 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.19])
1035 AC_MSG_ERROR([or Darwin or Bionic libc])
sewardjde4a1d02002-03-22 01:27:54 +00001036 ;;
1037esac
1038
dirk07596a22008-04-25 11:33:30 +00001039AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +00001040
sewardj414f3582008-07-18 20:46:00 +00001041
1042# Add default suppressions for the X client libraries. Make no
1043# attempt to detect whether such libraries are installed on the
1044# build machine (or even if any X facilities are present); just
1045# add the suppressions antidisirregardless.
1046DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1047DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +00001048
sewardjd2f95a02011-05-11 16:04:28 +00001049# Add glibc and X11 suppressions for exp-sgcheck
1050DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +00001051
sewardj2e10a682003-04-07 19:36:41 +00001052
njn7fd6d382009-01-22 21:56:32 +00001053#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +00001054# Platform variants?
1055#----------------------------------------------------------------------------
1056
1057# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1058# But there are times where we need a bit more control. The motivating
philippe5d5dd8e2012-08-05 00:08:25 +00001059# and currently only case is Android: this is almost identical to
dejanj9c6b05d2013-12-27 09:06:55 +00001060# {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1061# platform variant tags, which get passed in the compile as
1062# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
sewardjcb495c82011-07-11 20:42:34 +00001063#
1064# In almost all cases, the <variant> bit is "vanilla". But for Android
1065# it is "android" instead.
1066#
1067# Consequently (eg), plain arm-linux would build with
1068#
1069# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1070#
1071# whilst an Android build would have
1072#
1073# -DVGP_arm_linux -DVGPV_arm_linux_android
1074#
philippe5d5dd8e2012-08-05 00:08:25 +00001075# Same for x86. The setup of the platform variant is pushed relatively far
1076# down this file in order that we can inspect any of the variables set above.
sewardjcb495c82011-07-11 20:42:34 +00001077
1078# In the normal case ..
1079VGCONF_PLATVARIANT="vanilla"
1080
philippe5d5dd8e2012-08-05 00:08:25 +00001081# Android ?
1082if test "$GLIBC_VERSION" = "bionic";
sewardjcb495c82011-07-11 20:42:34 +00001083then
1084 VGCONF_PLATVARIANT="android"
1085fi
1086
1087AC_SUBST(VGCONF_PLATVARIANT)
1088
1089
1090# FIXME: do we also want to define automake variables
1091# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1092# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1093# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1094# do that. Problem is that we can't do and-ing in Makefile.am's, but
1095# that's what we'd need to do to use this, since what we'd want to write
1096# is something like
1097#
1098# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1099#
sewardj0ba37c92011-07-12 11:46:24 +00001100# Hmm. Can't think of a nice clean solution to this.
1101
1102AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1103 test x$VGCONF_PLATVARIANT = xvanilla)
1104AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1105 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +00001106
1107
1108#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +00001109# Checking for various library functions and other definitions
1110#----------------------------------------------------------------------------
1111
florian28db75c2012-12-08 19:26:03 +00001112# Check for AT_FDCWD
1113
1114AC_MSG_CHECKING([for AT_FDCWD])
1115AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1116#define _GNU_SOURCE
1117#include <fcntl.h>
1118#include <unistd.h>
1119]], [[
1120 int a = AT_FDCWD;
1121]])], [
1122ac_have_at_fdcwd=yes
1123AC_MSG_RESULT([yes])
1124], [
1125ac_have_at_fdcwd=no
florian28db75c2012-12-08 19:26:03 +00001126AC_MSG_RESULT([no])
1127])
1128
1129AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1130
sewardj24cf8df2012-12-14 10:30:57 +00001131# Check for stpncpy function definition in string.h
1132# This explicitly checks with _GNU_SOURCE defined since that is also
1133# used in the test case (some systems might define it without anyway
1134# since stpncpy is part of The Open Group Base Specifications Issue 7
1135# IEEE Std 1003.1-2008.
1136AC_MSG_CHECKING([for stpncpy])
1137AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1138#define _GNU_SOURCE
1139#include <string.h>
1140]], [[
1141 char *d;
1142 char *s;
1143 size_t n = 0;
1144 char *r = stpncpy(d, s, n);
1145]])], [
1146ac_have_gnu_stpncpy=yes
1147AC_MSG_RESULT([yes])
1148], [
1149ac_have_gnu_stpncpy=no
1150AC_MSG_RESULT([no])
1151])
1152
1153AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
florian28db75c2012-12-08 19:26:03 +00001154
philippe4e98f7c2013-08-03 20:34:58 +00001155# Check for PTRACE_GETREGS
1156
1157AC_MSG_CHECKING([for PTRACE_GETREGS])
1158AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1159#include <stddef.h>
1160#include <sys/ptrace.h>
1161#include <sys/user.h>
1162]], [[
1163 void *p;
1164 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1165]])], [
1166AC_MSG_RESULT([yes])
1167AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1168 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1169], [
1170AC_MSG_RESULT([no])
1171])
1172
1173
bart59e2f182008-04-28 16:22:53 +00001174# Check for CLOCK_MONOTONIC
1175
1176AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1177
bart417cf3e2011-10-22 09:21:24 +00001178AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +00001179#include <time.h>
bart417cf3e2011-10-22 09:21:24 +00001180]], [[
bart59e2f182008-04-28 16:22:53 +00001181 struct timespec t;
1182 clock_gettime(CLOCK_MONOTONIC, &t);
1183 return 0;
bart417cf3e2011-10-22 09:21:24 +00001184]])], [
bart59e2f182008-04-28 16:22:53 +00001185AC_MSG_RESULT([yes])
1186AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1187 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1188], [
1189AC_MSG_RESULT([no])
1190])
1191
bartfea06922008-05-03 09:12:15 +00001192
sewardj0c09bf02011-07-11 22:11:58 +00001193# Check for PTHREAD_RWLOCK_T
1194
1195AC_MSG_CHECKING([for pthread_rwlock_t])
1196
bart417cf3e2011-10-22 09:21:24 +00001197AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +00001198#define _GNU_SOURCE
1199#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001200]], [[
sewardj0c09bf02011-07-11 22:11:58 +00001201 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +00001202]])], [
sewardj0c09bf02011-07-11 22:11:58 +00001203AC_MSG_RESULT([yes])
1204AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1205 [Define to 1 if you have the `pthread_rwlock_t' type.])
1206], [
1207AC_MSG_RESULT([no])
1208])
1209
1210
bartfea06922008-05-03 09:12:15 +00001211# Check for PTHREAD_MUTEX_ADAPTIVE_NP
1212
1213AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1214
bart417cf3e2011-10-22 09:21:24 +00001215AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001216#define _GNU_SOURCE
1217#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001218]], [[
bartfea06922008-05-03 09:12:15 +00001219 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001220]])], [
bartfea06922008-05-03 09:12:15 +00001221AC_MSG_RESULT([yes])
1222AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1223 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1224], [
1225AC_MSG_RESULT([no])
1226])
1227
1228
1229# Check for PTHREAD_MUTEX_ERRORCHECK_NP
1230
1231AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1232
bart417cf3e2011-10-22 09:21:24 +00001233AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001234#define _GNU_SOURCE
1235#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001236]], [[
bartfea06922008-05-03 09:12:15 +00001237 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +00001238]])], [
bartfea06922008-05-03 09:12:15 +00001239AC_MSG_RESULT([yes])
1240AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1241 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1242], [
1243AC_MSG_RESULT([no])
1244])
1245
1246
1247# Check for PTHREAD_MUTEX_RECURSIVE_NP
1248
1249AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1250
bart417cf3e2011-10-22 09:21:24 +00001251AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001252#define _GNU_SOURCE
1253#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001254]], [[
bartfea06922008-05-03 09:12:15 +00001255 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001256]])], [
bartfea06922008-05-03 09:12:15 +00001257AC_MSG_RESULT([yes])
1258AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1259 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1260], [
1261AC_MSG_RESULT([no])
1262])
1263
1264
1265# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1266
1267AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1268
bart417cf3e2011-10-22 09:21:24 +00001269AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001270#define _GNU_SOURCE
1271#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001272]], [[
bartfea06922008-05-03 09:12:15 +00001273 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1274 return 0;
bart417cf3e2011-10-22 09:21:24 +00001275]])], [
bartfea06922008-05-03 09:12:15 +00001276AC_MSG_RESULT([yes])
1277AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1278 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1279], [
1280AC_MSG_RESULT([no])
1281])
1282
1283
bart5e389f12008-04-05 12:53:15 +00001284# Check whether pthread_mutex_t has a member called __m_kind.
1285
bartb11355c2010-04-29 16:37:26 +00001286AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1287 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1288 1,
1289 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1290 ],
1291 [],
1292 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001293
1294
1295# Check whether pthread_mutex_t has a member called __data.__kind.
1296
bartb11355c2010-04-29 16:37:26 +00001297AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1298 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1299 1,
1300 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1301 ],
1302 [],
1303 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001304
1305
bart62c370e2008-05-12 18:50:51 +00001306# does this compiler support -maltivec and does it have the include file
1307# <altivec.h> ?
1308
1309AC_MSG_CHECKING([for Altivec])
1310
1311safe_CFLAGS=$CFLAGS
1312CFLAGS="-maltivec"
1313
bart417cf3e2011-10-22 09:21:24 +00001314AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001315#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001316]], [[
bart62c370e2008-05-12 18:50:51 +00001317 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001318]])], [
bart62c370e2008-05-12 18:50:51 +00001319ac_have_altivec=yes
1320AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001321AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001322 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001323], [
1324ac_have_altivec=no
1325AC_MSG_RESULT([no])
1326])
1327CFLAGS=$safe_CFLAGS
1328
sewardj0e342a02010-09-03 23:49:33 +00001329AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001330
1331
sewardjf34eb492011-04-15 11:57:05 +00001332# Check that both: the compiler supports -mvsx and that the assembler
1333# understands VSX instructions. If either of those doesn't work,
1334# conclude that we can't do VSX. NOTE: basically this is a kludge
1335# in that it conflates two things that should be separate -- whether
1336# the compiler understands the flag vs whether the assembler
1337# understands the opcodes. This really ought to be cleaned up
1338# and done properly, like it is for x86/x86_64.
1339
1340AC_MSG_CHECKING([for VSX])
1341
1342safe_CFLAGS=$CFLAGS
1343CFLAGS="-mvsx"
1344
bart417cf3e2011-10-22 09:21:24 +00001345AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001346#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001347]], [[
sewardjf34eb492011-04-15 11:57:05 +00001348 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001349 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001350]])], [
sewardjf34eb492011-04-15 11:57:05 +00001351ac_have_vsx=yes
1352AC_MSG_RESULT([yes])
1353], [
1354ac_have_vsx=no
1355AC_MSG_RESULT([no])
1356])
1357CFLAGS=$safe_CFLAGS
1358
1359AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1360
sewardj4e1c1912012-08-08 22:22:26 +00001361
sewardjb0ccb4d2012-04-02 10:22:05 +00001362AC_MSG_CHECKING([that assembler knows DFP])
1363
1364AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1365]], [[
1366 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001367 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001368]])], [
1369ac_asm_have_dfp=yes
1370AC_MSG_RESULT([yes])
1371], [
1372ac_asm_have_dfp=no
1373AC_MSG_RESULT([no])
1374])
1375
sewardj4e1c1912012-08-08 22:22:26 +00001376
sewardjb0ccb4d2012-04-02 10:22:05 +00001377AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1378safe_CFLAGS=$CFLAGS
1379CFLAGS="-mhard-dfp"
1380AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1381]], [[
1382 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001383 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001384]])], [
1385ac_gcc_have_dfp=yes
1386AC_MSG_RESULT([yes])
1387], [
1388ac_gcc_have_dfp=no
1389AC_MSG_RESULT([no])
1390])
1391
sewardjb0ccb4d2012-04-02 10:22:05 +00001392CFLAGS=$safe_CFLAGS
1393
1394AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001395
sewardj4e1c1912012-08-08 22:22:26 +00001396
florian46825982012-11-10 22:35:24 +00001397AC_MSG_CHECKING([that compiler knows DFP datatypes])
1398AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1399]], [[
1400 _Decimal64 x = 0.0DD;
1401]])], [
1402ac_gcc_have_dfp_type=yes
1403AC_MSG_RESULT([yes])
1404], [
1405ac_gcc_have_dfp_type=no
1406AC_MSG_RESULT([no])
1407])
1408
1409AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1410
carlldfbf2942013-08-12 18:04:22 +00001411# isa 2.07 checking
1412AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1413
1414AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1415]], [[
1416 __asm__ __volatile__("mtvsrd 1,2 ");
1417]])], [
1418ac_asm_have_isa_2_07=yes
1419AC_MSG_RESULT([yes])
1420], [
1421ac_asm_have_isa_2_07=no
1422AC_MSG_RESULT([no])
1423])
1424
1425AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
florian46825982012-11-10 22:35:24 +00001426
bart36dd85a2009-04-26 07:11:48 +00001427# Check for pthread_create@GLIBC2.0
1428AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1429
bart16e1c5a2009-04-26 07:38:53 +00001430safe_CFLAGS=$CFLAGS
1431CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001432AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001433extern int pthread_create_glibc_2_0(void*, const void*,
1434 void *(*)(void*), void*);
1435__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001436]], [[
bart276ed3a2009-05-10 15:41:45 +00001437#ifdef __powerpc__
1438/*
1439 * Apparently on PowerPC linking this program succeeds and generates an
1440 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1441 */
1442#error This test does not work properly on PowerPC.
1443#else
bart16e1c5a2009-04-26 07:38:53 +00001444 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001445#endif
bart16e1c5a2009-04-26 07:38:53 +00001446 return 0;
bart417cf3e2011-10-22 09:21:24 +00001447]])], [
bart36dd85a2009-04-26 07:11:48 +00001448ac_have_pthread_create_glibc_2_0=yes
1449AC_MSG_RESULT([yes])
1450AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1451 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1452], [
1453ac_have_pthread_create_glibc_2_0=no
1454AC_MSG_RESULT([no])
1455])
bart16e1c5a2009-04-26 07:38:53 +00001456CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001457
1458AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001459 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001460
1461
philippe1670b052014-08-15 10:27:52 +00001462# Check for dlinfo RTLD_DI_TLS_MODID
1463AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1464
1465safe_LIBS="$LIBS"
1466LIBS="-ldl"
1467AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1468#ifndef _GNU_SOURCE
1469#define _GNU_SOURCE
1470#endif
1471#include <link.h>
1472#include <dlfcn.h>
1473]], [[
1474 size_t sizes[10000];
1475 size_t modid_offset;
1476 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1477 return 0;
1478]])], [
1479ac_have_dlinfo_rtld_di_tls_modid=yes
1480AC_MSG_RESULT([yes])
1481AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1482 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1483], [
1484ac_have_dlinfo_rtld_di_tls_modid=no
1485AC_MSG_RESULT([no])
1486])
1487LIBS=$safe_LIBS
1488
1489AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1490 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1491
1492
barta50aa8a2008-04-27 06:06:57 +00001493# Check for eventfd_t, eventfd() and eventfd_read()
1494AC_MSG_CHECKING([for eventfd()])
1495
bart417cf3e2011-10-22 09:21:24 +00001496AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001497#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001498]], [[
barta50aa8a2008-04-27 06:06:57 +00001499 eventfd_t ev;
1500 int fd;
1501
1502 fd = eventfd(5, 0);
1503 eventfd_read(fd, &ev);
1504 return 0;
bart417cf3e2011-10-22 09:21:24 +00001505]])], [
barta50aa8a2008-04-27 06:06:57 +00001506AC_MSG_RESULT([yes])
1507AC_DEFINE([HAVE_EVENTFD], 1,
1508 [Define to 1 if you have the `eventfd' function.])
1509AC_DEFINE([HAVE_EVENTFD_READ], 1,
1510 [Define to 1 if you have the `eventfd_read' function.])
1511], [
1512AC_MSG_RESULT([no])
1513])
1514
1515
florian24fefb62013-10-08 13:04:00 +00001516# Check whether compiler can process #include <thread> without errors
1517# clang 3.3 cannot process <thread> from e.g.
1518# gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1519
1520AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1521AC_LANG(C++)
1522safe_CXXFLAGS=$CXXFLAGS
1523CXXFLAGS=-std=c++0x
1524
1525AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1526#include <thread>
1527])],
1528[
1529ac_cxx_can_include_thread_header=yes
1530AC_MSG_RESULT([yes])
1531], [
1532ac_cxx_can_include_thread_header=no
1533AC_MSG_RESULT([no])
1534])
1535CXXFLAGS=$safe_CXXFLAGS
1536AC_LANG(C)
1537
1538AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1539
mjw2a429f52014-07-18 20:45:37 +00001540
1541# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1542# of the user_regs_struct from sys/user.h. They are structurally the same
1543# but we get either one or the other.
1544
1545AC_CHECK_TYPE([struct user_regs_struct],
1546 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1547 [[#include <sys/ptrace.h>]
1548 [#include <sys/time.h>]
1549 [#include <sys/user.h>]])
1550if test "$sys_user_has_user_regs" = "yes"; then
1551 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1552 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1553fi
1554
1555
njn7fd6d382009-01-22 21:56:32 +00001556#----------------------------------------------------------------------------
1557# Checking for supported compiler flags.
1558#----------------------------------------------------------------------------
1559
sewardj535c50f2005-06-04 23:14:53 +00001560# does this compiler support -m32 ?
1561AC_MSG_CHECKING([if gcc accepts -m32])
1562
1563safe_CFLAGS=$CFLAGS
1564CFLAGS="-m32"
1565
bart417cf3e2011-10-22 09:21:24 +00001566AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001567 return 0;
bart417cf3e2011-10-22 09:21:24 +00001568]])], [
sewardj535c50f2005-06-04 23:14:53 +00001569FLAG_M32="-m32"
1570AC_MSG_RESULT([yes])
1571], [
1572FLAG_M32=""
1573AC_MSG_RESULT([no])
1574])
1575CFLAGS=$safe_CFLAGS
1576
1577AC_SUBST(FLAG_M32)
1578
1579
sewardj01262142006-01-04 01:20:28 +00001580# does this compiler support -m64 ?
1581AC_MSG_CHECKING([if gcc accepts -m64])
1582
1583safe_CFLAGS=$CFLAGS
1584CFLAGS="-m64"
1585
bart417cf3e2011-10-22 09:21:24 +00001586AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001587 return 0;
bart417cf3e2011-10-22 09:21:24 +00001588]])], [
sewardj01262142006-01-04 01:20:28 +00001589FLAG_M64="-m64"
1590AC_MSG_RESULT([yes])
1591], [
1592FLAG_M64=""
1593AC_MSG_RESULT([no])
1594])
1595CFLAGS=$safe_CFLAGS
1596
1597AC_SUBST(FLAG_M64)
1598
1599
dejanjf674e382014-02-18 16:40:25 +00001600# does this compiler support -march=mips32 (mips32 default) ?
1601AC_MSG_CHECKING([if gcc accepts -march=mips32])
1602
1603safe_CFLAGS=$CFLAGS
1604CFLAGS="$CFLAGS -march=mips32"
1605
1606AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1607 return 0;
1608]])], [
1609FLAG_MIPS32="-march=mips32"
1610AC_MSG_RESULT([yes])
1611], [
1612FLAG_MIPS32=""
1613AC_MSG_RESULT([no])
1614])
1615CFLAGS=$safe_CFLAGS
1616
1617AC_SUBST(FLAG_MIPS32)
1618
1619
1620# does this compiler support -march=mips64 (mips64 default) ?
1621AC_MSG_CHECKING([if gcc accepts -march=mips64])
1622
1623safe_CFLAGS=$CFLAGS
1624CFLAGS="$CFLAGS -march=mips64"
1625
1626AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1627 return 0;
1628]])], [
1629FLAG_MIPS64="-march=mips64"
1630AC_MSG_RESULT([yes])
1631], [
1632FLAG_MIPS64=""
1633AC_MSG_RESULT([no])
1634])
1635CFLAGS=$safe_CFLAGS
1636
1637AC_SUBST(FLAG_MIPS64)
1638
1639
petarj1546c7a2014-01-29 18:08:50 +00001640# does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1641AC_MSG_CHECKING([if gcc accepts -march=octeon])
1642
1643safe_CFLAGS=$CFLAGS
1644CFLAGS="$CFLAGS -march=octeon"
1645
1646AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1647 return 0;
1648]])], [
1649FLAG_OCTEON="-march=octeon"
1650AC_MSG_RESULT([yes])
1651], [
1652FLAG_OCTEON=""
1653AC_MSG_RESULT([no])
1654])
1655CFLAGS=$safe_CFLAGS
1656
1657AC_SUBST(FLAG_OCTEON)
1658
dejanjf674e382014-02-18 16:40:25 +00001659
petarj1546c7a2014-01-29 18:08:50 +00001660# does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1661AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1662
1663safe_CFLAGS=$CFLAGS
1664CFLAGS="$CFLAGS -march=octeon2"
1665
1666AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1667 return 0;
1668]])], [
1669FLAG_OCTEON2="-march=octeon2"
1670AC_MSG_RESULT([yes])
1671], [
1672FLAG_OCTEON2=""
1673AC_MSG_RESULT([no])
1674])
1675CFLAGS=$safe_CFLAGS
1676
1677AC_SUBST(FLAG_OCTEON2)
1678
1679
sewardj67f1fcc2005-07-03 10:41:02 +00001680# does this compiler support -mmmx ?
1681AC_MSG_CHECKING([if gcc accepts -mmmx])
1682
1683safe_CFLAGS=$CFLAGS
1684CFLAGS="-mmmx"
1685
bart417cf3e2011-10-22 09:21:24 +00001686AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001687 return 0;
bart417cf3e2011-10-22 09:21:24 +00001688]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001689FLAG_MMMX="-mmmx"
1690AC_MSG_RESULT([yes])
1691], [
1692FLAG_MMMX=""
1693AC_MSG_RESULT([no])
1694])
1695CFLAGS=$safe_CFLAGS
1696
1697AC_SUBST(FLAG_MMMX)
1698
1699
1700# does this compiler support -msse ?
1701AC_MSG_CHECKING([if gcc accepts -msse])
1702
1703safe_CFLAGS=$CFLAGS
1704CFLAGS="-msse"
1705
bart417cf3e2011-10-22 09:21:24 +00001706AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001707 return 0;
bart417cf3e2011-10-22 09:21:24 +00001708]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001709FLAG_MSSE="-msse"
1710AC_MSG_RESULT([yes])
1711], [
1712FLAG_MSSE=""
1713AC_MSG_RESULT([no])
1714])
1715CFLAGS=$safe_CFLAGS
1716
1717AC_SUBST(FLAG_MSSE)
1718
1719
sewardj98977e02014-09-05 20:00:22 +00001720# does this compiler support -mpreferred-stack-boundary=2 when
1721# generating code for a 32-bit target? Note that we only care about
1722# this when generating code for (32-bit) x86, so if the compiler
1723# doesn't recognise -m32 it's no big deal. We'll just get code for
1724# the Memcheck and other helper functions, that is a bit slower than
1725# it could be, on x86; and no difference at all on any other platform.
1726AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
sewardj5b754b42002-06-03 22:53:35 +00001727
daywalker3664f562003-10-17 13:43:46 +00001728safe_CFLAGS=$CFLAGS
sewardj98977e02014-09-05 20:00:22 +00001729CFLAGS="-mpreferred-stack-boundary=2 -m32"
sewardj5b754b42002-06-03 22:53:35 +00001730
bart417cf3e2011-10-22 09:21:24 +00001731AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001732 return 0;
bart417cf3e2011-10-22 09:21:24 +00001733]])], [
sewardj98977e02014-09-05 20:00:22 +00001734PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001735AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001736], [
sewardj98977e02014-09-05 20:00:22 +00001737PREFERRED_STACK_BOUNDARY_2=""
sewardj5b754b42002-06-03 22:53:35 +00001738AC_MSG_RESULT([no])
1739])
daywalker3664f562003-10-17 13:43:46 +00001740CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001741
sewardj98977e02014-09-05 20:00:22 +00001742AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
sewardj5b754b42002-06-03 22:53:35 +00001743
sewardj535c50f2005-06-04 23:14:53 +00001744
mjwab69b4a2014-08-20 16:11:53 +00001745# Convenience function to check whether GCC supports a particular
1746# warning option. Takes two arguments, first the warning flag name
1747# to check (without -W), then the conditional name to set if that
1748# warning flag is supported.
1749AC_DEFUN([AC_GCC_WARNING_COND],[
sewardja3a27fe2014-09-01 21:16:02 +00001750 AC_MSG_CHECKING([if gcc accepts -W$1])
1751 safe_CFLAGS=$CFLAGS
1752 CFLAGS="-W$1"
1753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1754 has_warning_flag=yes
1755 AC_MSG_RESULT([yes])], [
1756 has_warning_flag=no
1757 AC_MSG_RESULT([no])])
1758 CFLAGS=$safe_CFLAGS
1759 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes)
1760])
florianda8c1262012-11-18 14:39:11 +00001761
mjwab69b4a2014-08-20 16:11:53 +00001762AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING])
1763AC_GCC_WARNING_COND([write-strings], [HAS_WRITE_STRINGS_WARNING])
florianda8c1262012-11-18 14:39:11 +00001764
mjwab69b4a2014-08-20 16:11:53 +00001765# Convenience function to check whether GCC supports a particular
1766# warning option. Similar to AC_GCC_WARNING_COND, but does a
1767# substitution instead of setting an conditional. Takes two arguments,
1768# first the warning flag name to check (without -W), then the
1769# substitution name to set with -Wno-warning-flag if the flag exists,
1770# or the empty string if the compiler doesn't accept the flag. Note
1771# that checking is done against the warning flag itself, but the
1772# substitution is then done to cancel the warning flag.
1773AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
sewardja3a27fe2014-09-01 21:16:02 +00001774 AC_MSG_CHECKING([if gcc accepts -W$1])
1775 safe_CFLAGS=$CFLAGS
1776 CFLAGS="-W$1"
1777 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1778 AC_SUBST([$2], [-Wno-$1])
1779 AC_MSG_RESULT([yes])], [
1780 AC_SUBST([$2], [])
1781 AC_MSG_RESULT([no])])
1782 CFLAGS=$safe_CFLAGS
barte026bd22009-07-04 12:17:07 +00001783])
barte026bd22009-07-04 12:17:07 +00001784
mjwab69b4a2014-08-20 16:11:53 +00001785AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY])
1786AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH])
1787AC_GCC_WARNING_SUBST_NO([tautological-compare], [FLAG_W_NO_TAUTOLOGICAL_COMPARE])
1788AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1789AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1790AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
florian807c4542014-09-05 18:30:05 +00001791AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1792AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
bartbf9b85c2009-08-12 12:55:56 +00001793
sewardja3a27fe2014-09-01 21:16:02 +00001794
bart56730cd2008-05-11 06:41:46 +00001795# does this compiler support -Wextra or the older -W ?
1796
1797AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1798
1799safe_CFLAGS=$CFLAGS
1800CFLAGS="-Wextra"
1801
bart417cf3e2011-10-22 09:21:24 +00001802AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001803 return 0;
bart417cf3e2011-10-22 09:21:24 +00001804]])], [
bart56730cd2008-05-11 06:41:46 +00001805AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1806AC_MSG_RESULT([-Wextra])
1807], [
1808 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001809 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001810 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001811 ]])], [
bart56730cd2008-05-11 06:41:46 +00001812 AC_SUBST([FLAG_W_EXTRA], [-W])
1813 AC_MSG_RESULT([-W])
1814 ], [
1815 AC_SUBST([FLAG_W_EXTRA], [])
1816 AC_MSG_RESULT([not supported])
1817 ])
1818])
1819CFLAGS=$safe_CFLAGS
1820
1821
sewardja72c26d2007-05-01 13:44:08 +00001822# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001823AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001824
1825safe_CFLAGS=$CFLAGS
1826CFLAGS="-fno-stack-protector"
1827
bart417cf3e2011-10-22 09:21:24 +00001828AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001829 return 0;
bart417cf3e2011-10-22 09:21:24 +00001830]])], [
sewardja72c26d2007-05-01 13:44:08 +00001831no_stack_protector=yes
1832FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1833AC_MSG_RESULT([yes])
1834], [
1835no_stack_protector=no
1836FLAG_FNO_STACK_PROTECTOR=""
1837AC_MSG_RESULT([no])
1838])
1839CFLAGS=$safe_CFLAGS
1840
1841AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1842
1843if test x$no_stack_protector = xyes; then
1844 CFLAGS="$CFLAGS -fno-stack-protector"
floriand79b3bf2013-10-02 15:14:59 +00001845 CXXFLAGS="$CXXFLAGS -fno-stack-protector"
sewardja72c26d2007-05-01 13:44:08 +00001846fi
1847
1848
bart56730cd2008-05-11 06:41:46 +00001849# does this compiler support --param inline-unit-growth=... ?
1850
1851AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1852
1853safe_CFLAGS=$CFLAGS
1854CFLAGS="--param inline-unit-growth=900"
1855
bart417cf3e2011-10-22 09:21:24 +00001856AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001857 return 0;
bart417cf3e2011-10-22 09:21:24 +00001858]])], [
bart56730cd2008-05-11 06:41:46 +00001859AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1860 ["--param inline-unit-growth=900"])
1861AC_MSG_RESULT([yes])
1862], [
1863AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1864AC_MSG_RESULT([no])
1865])
1866CFLAGS=$safe_CFLAGS
1867
1868
sewardjd9350682012-04-05 07:55:47 +00001869# does this compiler support -gdwarf-4 -fdebug-types-section ?
1870
1871AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1872
1873safe_CFLAGS=$CFLAGS
1874CFLAGS="-gdwarf-4 -fdebug-types-section"
1875
1876AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1877 return 0;
1878]])], [
1879ac_have_dwarf4=yes
1880AC_MSG_RESULT([yes])
1881], [
1882ac_have_dwarf4=no
1883AC_MSG_RESULT([no])
1884])
1885AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1886CFLAGS=$safe_CFLAGS
1887
1888
florian3df02112013-10-04 11:35:50 +00001889# does this compiler support -gstabs ?
1890
1891AC_MSG_CHECKING([if gcc accepts -gstabs])
1892
1893safe_CFLAGS=$CFLAGS
1894CFLAGS="-gstabs"
1895AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1896 return 0;
1897]])], [
1898ac_have_gstabs=yes
1899AC_MSG_RESULT([yes])
1900], [
1901ac_have_gstabs=no
1902AC_MSG_RESULT([no])
1903])
1904CFLAGS=$safe_CFLAGS
1905AM_CONDITIONAL([HAVE_GSTABS], [test x$ac_have_gstabs = xyes])
1906
1907
1908# does this compiler support nested functions ?
1909
1910AC_MSG_CHECKING([if gcc accepts nested functions])
1911
1912AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1913 int foo() { return 1; }
1914 return foo();
1915]])], [
1916ac_have_nested_functions=yes
1917AC_MSG_RESULT([yes])
1918], [
1919ac_have_nested_functions=no
1920AC_MSG_RESULT([no])
1921])
1922AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1923
1924
1925# does this compiler support the 'p' constraint in ASM statements ?
1926
1927AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1928
1929AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1930 char *p;
1931 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1932]])], [
1933ac_have_asm_constraint_p=yes
1934AC_MSG_RESULT([yes])
1935], [
1936ac_have_asm_constraint_p=no
1937AC_MSG_RESULT([no])
1938])
1939AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1940
1941
sewardje4bc7032013-03-22 11:49:46 +00001942# We want to use use the -Ttext-segment option to the linker.
1943# GNU (bfd) ld supports this directly. Newer GNU gold linkers
1944# support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1945# semantics are NOT what we want (GNU gold -Ttext is fine).
1946#
1947# For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1948# will reside. -Ttext aligns just the .text section start (but not any
1949# other section).
1950#
1951# So test for -Ttext-segment which is supported by all bfd ld versions
1952# and use that if it exists. If it doesn't exist it must be an older
1953# version of gold and we can fall back to using -Ttext which has the
1954# right semantics.
bart699fbac2010-06-08 18:23:59 +00001955
sewardje4bc7032013-03-22 11:49:46 +00001956AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
bart699fbac2010-06-08 18:23:59 +00001957
1958safe_CFLAGS=$CFLAGS
mjw941277a2013-04-17 19:11:05 +00001959CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
bart699fbac2010-06-08 18:23:59 +00001960
bart8508c752010-06-10 06:26:21 +00001961AC_LINK_IFELSE(
mjw941277a2013-04-17 19:11:05 +00001962[AC_LANG_SOURCE([int _start () { return 0; }])],
bart699fbac2010-06-08 18:23:59 +00001963[
tom04ce9f52013-03-28 15:53:21 +00001964 linker_using_t_text="no"
sewardje4bc7032013-03-22 11:49:46 +00001965 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
bart699fbac2010-06-08 18:23:59 +00001966 AC_MSG_RESULT([yes])
1967], [
tom04ce9f52013-03-28 15:53:21 +00001968 linker_using_t_text="yes"
sewardje4bc7032013-03-22 11:49:46 +00001969 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
bart699fbac2010-06-08 18:23:59 +00001970 AC_MSG_RESULT([no])
1971])
1972CFLAGS=$safe_CFLAGS
1973
tom04ce9f52013-03-28 15:53:21 +00001974# If the linker only supports -Ttext (not -Ttext-segment) then we will
1975# have to strip any build-id ELF NOTEs from the staticly linked tools.
1976# Otherwise the build-id NOTE might end up at the default load address.
1977# (Pedantically if the linker is gold then -Ttext is fine, but newer
1978# gold versions also support -Ttext-segment. So just assume that unless
1979# we can use -Ttext-segment we need to strip the build-id NOTEs.
florian51b14ee2014-02-22 18:38:32 +00001980if test "x${linker_using_t_text}" = "xyes"; then
tom04ce9f52013-03-28 15:53:21 +00001981AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1982# does the linker support -Wl,--build-id=none ? Note, it's
1983# important that we test indirectly via whichever C compiler
1984# is selected, rather than testing /usr/bin/ld or whatever
1985# directly.
1986AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1987safe_CFLAGS=$CFLAGS
1988CFLAGS="-Wl,--build-id=none"
1989
1990AC_LINK_IFELSE(
1991[AC_LANG_PROGRAM([ ], [return 0;])],
1992[
1993 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1994 AC_MSG_RESULT([yes])
1995], [
1996 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1997 AC_MSG_RESULT([no])
1998])
1999else
2000AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2001AC_SUBST([FLAG_NO_BUILD_ID], [""])
2002fi
2003CFLAGS=$safe_CFLAGS
bart699fbac2010-06-08 18:23:59 +00002004
sewardj00f1e622006-03-12 16:47:10 +00002005# does the ppc assembler support "mtocrf" et al?
2006AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2007
bart417cf3e2011-10-22 09:21:24 +00002008AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00002009__asm__ __volatile__("mtocrf 4,0");
2010__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00002011]])], [
sewardj00f1e622006-03-12 16:47:10 +00002012ac_have_as_ppc_mftocrf=yes
2013AC_MSG_RESULT([yes])
2014], [
2015ac_have_as_ppc_mftocrf=no
2016AC_MSG_RESULT([no])
2017])
2018if test x$ac_have_as_ppc_mftocrf = xyes ; then
2019 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2020fi
2021
2022
carll1e5fa2f2013-08-09 21:55:45 +00002023# does the ppc assembler support "lfdp" and other phased out floating point insns?
2024AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2025
2026AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2027 do { typedef struct {
2028 double hi;
2029 double lo;
2030 } dbl_pair_t;
2031 dbl_pair_t dbl_pair[3];
2032 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2033 } while (0)
2034]])], [
2035ac_have_as_ppc_fpPO=yes
2036AC_MSG_RESULT([yes])
2037], [
2038ac_have_as_ppc_fpPO=no
2039AC_MSG_RESULT([no])
2040])
2041if test x$ac_have_as_ppc_fpPO = xyes ; then
2042 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2043fi
2044
sewardjb5b87402011-03-07 16:05:35 +00002045
sewardjf0aabf82007-03-22 00:24:21 +00002046# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00002047# Note, this doesn't generate a C-level symbol. It generates a
2048# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00002049AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2050
bart417cf3e2011-10-22 09:21:24 +00002051AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00002052 do { long long int x;
2053 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2054 while (0)
bart417cf3e2011-10-22 09:21:24 +00002055]])], [
sewardjf0aabf82007-03-22 00:24:21 +00002056ac_have_as_sse3=yes
2057AC_MSG_RESULT([yes])
2058], [
2059ac_have_as_sse3=no
2060AC_MSG_RESULT([no])
2061])
sewardjfa18a262007-03-22 12:13:13 +00002062
2063AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00002064
2065
sewardj6d6da5b2008-02-09 12:07:40 +00002066# Ditto for SSSE3 instructions (note extra S)
2067# Note, this doesn't generate a C-level symbol. It generates a
2068# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2069AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2070
florianc443b962011-10-28 21:37:19 +00002071save_CFLAGS="$CFLAGS"
2072CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00002073AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00002074 do { long long int x;
2075 __asm__ __volatile__(
2076 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2077 while (0)
bart417cf3e2011-10-22 09:21:24 +00002078]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00002079ac_have_as_ssse3=yes
2080AC_MSG_RESULT([yes])
2081], [
2082ac_have_as_ssse3=no
2083AC_MSG_RESULT([no])
2084])
florianc443b962011-10-28 21:37:19 +00002085CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00002086
2087AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2088
2089
sewardj27d176a2011-01-17 11:15:48 +00002090# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2091# Note, this doesn't generate a C-level symbol. It generates a
2092# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00002093AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00002094AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00002095 do {
2096 __asm__ __volatile__(
2097 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2098 while (0)
bart417cf3e2011-10-22 09:21:24 +00002099]])], [
sewardje3ae8a32010-09-28 19:59:47 +00002100ac_have_as_pclmulqdq=yes
2101AC_MSG_RESULT([yes])
2102], [
2103ac_have_as_pclmulqdq=no
2104AC_MSG_RESULT([no])
2105])
2106
2107AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2108
2109
bart9bbe2bb2012-08-03 19:37:02 +00002110# does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2111# Note, this doesn't generate a C-level symbol. It generates a
2112# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2113AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2114AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2115 do {
2116 /*
2117 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2118 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2119 * xmm2 should be used.
2120 */
2121 __asm__ __volatile__(
2122 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2123 } while (0)
2124]])], [
2125ac_have_as_vpclmulqdq=yes
2126AC_MSG_RESULT([yes])
2127], [
2128ac_have_as_vpclmulqdq=no
2129AC_MSG_RESULT([no])
2130])
2131
2132AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2133
2134
sewardj27d176a2011-01-17 11:15:48 +00002135# does the x86/amd64 assembler understand the LZCNT instruction?
2136# Note, this doesn't generate a C-level symbol. It generates a
2137# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00002138AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2139
bart417cf3e2011-10-22 09:21:24 +00002140AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00002141 do {
sewardjc62291c2012-07-22 11:10:08 +00002142 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
bart55e438b2010-09-14 10:53:57 +00002143 } while (0)
bart417cf3e2011-10-22 09:21:24 +00002144]])], [
bart55e438b2010-09-14 10:53:57 +00002145 ac_have_as_lzcnt=yes
2146 AC_MSG_RESULT([yes])
2147], [
2148 ac_have_as_lzcnt=no
2149 AC_MSG_RESULT([no])
2150])
2151
2152AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2153
sewardj27d176a2011-01-17 11:15:48 +00002154
florian3df02112013-10-04 11:35:50 +00002155# does the x86/amd64 assembler understand the LOOPNEL instruction?
2156# Note, this doesn't generate a C-level symbol. It generates a
2157# automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2158AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2159
2160AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2161 do {
2162 __asm__ __volatile__("1: loopnel 1b\n");
2163 } while (0)
2164]])], [
2165 ac_have_as_loopnel=yes
2166 AC_MSG_RESULT([yes])
2167], [
2168 ac_have_as_loopnel=no
2169 AC_MSG_RESULT([no])
2170])
2171
2172AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2173
2174
2175# does the x86/amd64 assembler understand ADDR32 ?
2176# Note, this doesn't generate a C-level symbol. It generates a
2177# automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2178AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2179
2180AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2181 do {
2182 asm volatile ("addr32 rep movsb");
2183 } while (0)
2184]])], [
2185 ac_have_as_addr32=yes
2186 AC_MSG_RESULT([yes])
2187], [
2188 ac_have_as_addr32=no
2189 AC_MSG_RESULT([no])
2190])
2191
2192AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2193
2194
sewardj27d176a2011-01-17 11:15:48 +00002195# does the x86/amd64 assembler understand SSE 4.2 instructions?
2196# Note, this doesn't generate a C-level symbol. It generates a
2197# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2198AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2199
bart417cf3e2011-10-22 09:21:24 +00002200AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00002201 do { long long int x;
2202 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00002203 "crc32q %%r15,%%r15" : : : "r15" );
2204 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002205 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2206 __asm__ __volatile__(
2207 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
sewardj27d176a2011-01-17 11:15:48 +00002208 while (0)
bart417cf3e2011-10-22 09:21:24 +00002209]])], [
sewardj27d176a2011-01-17 11:15:48 +00002210ac_have_as_sse42=yes
2211AC_MSG_RESULT([yes])
2212], [
2213ac_have_as_sse42=no
2214AC_MSG_RESULT([no])
2215])
2216
2217AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2218
2219
sewardj9fb31ca2012-06-05 00:31:49 +00002220# does the x86/amd64 assembler understand AVX instructions?
2221# Note, this doesn't generate a C-level symbol. It generates a
2222# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2223AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2224
2225AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2226 do { long long int x;
2227 __asm__ __volatile__(
2228 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2229 __asm__ __volatile__(
2230 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2231 while (0)
2232]])], [
2233ac_have_as_avx=yes
2234AC_MSG_RESULT([yes])
2235], [
2236ac_have_as_avx=no
2237AC_MSG_RESULT([no])
2238])
2239
2240AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2241
2242
sewardjfda50af2013-03-27 11:43:20 +00002243# does the x86/amd64 assembler understand AVX2 instructions?
2244# Note, this doesn't generate a C-level symbol. It generates a
2245# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2246AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2247
2248AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2249 do { long long int x;
2250 __asm__ __volatile__(
2251 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2252 __asm__ __volatile__(
2253 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2254 while (0)
2255]])], [
2256ac_have_as_avx2=yes
2257AC_MSG_RESULT([yes])
2258], [
2259ac_have_as_avx2=no
2260AC_MSG_RESULT([no])
2261])
2262
2263AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2264
2265
sewardj9ea080b2013-10-16 08:53:07 +00002266# does the x86/amd64 assembler understand TSX instructions and
2267# the XACQUIRE/XRELEASE prefixes?
florian364c3652013-09-30 16:32:53 +00002268# Note, this doesn't generate a C-level symbol. It generates a
2269# automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2270AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2271
2272AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2273 do {
2274 __asm__ __volatile__(
2275 " xbegin Lfoo \n\t"
sewardj9ea080b2013-10-16 08:53:07 +00002276 "Lfoo: xend \n\t"
2277 " xacquire lock incq 0(%rsp) \n\t"
2278 " xrelease lock incq 0(%rsp) \n"
2279 );
florian364c3652013-09-30 16:32:53 +00002280 } while (0)
2281]])], [
2282ac_have_as_tsx=yes
2283AC_MSG_RESULT([yes])
2284], [
2285ac_have_as_tsx=no
2286AC_MSG_RESULT([no])
2287])
2288
2289AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2290
2291
sewardjfda50af2013-03-27 11:43:20 +00002292# does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2293# Note, this doesn't generate a C-level symbol. It generates a
2294# automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2295AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2296
2297AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2298 do { unsigned int h, l;
2299 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002300 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
sewardjfda50af2013-03-27 11:43:20 +00002301 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002302 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
sewardjfda50af2013-03-27 11:43:20 +00002303 while (0)
2304]])], [
2305ac_have_as_bmi=yes
2306AC_MSG_RESULT([yes])
2307], [
2308ac_have_as_bmi=no
2309AC_MSG_RESULT([no])
2310])
2311
2312AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2313
2314
2315# does the x86/amd64 assembler understand FMA instructions?
2316# Note, this doesn't generate a C-level symbol. It generates a
2317# automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2318AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2319
2320AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2321 do { unsigned int h, l;
2322 __asm__ __volatile__(
2323 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2324 __asm__ __volatile__(
2325 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2326 __asm__ __volatile__(
2327 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2328 while (0)
2329]])], [
2330ac_have_as_fma=yes
2331AC_MSG_RESULT([yes])
2332], [
2333ac_have_as_fma=no
2334AC_MSG_RESULT([no])
2335])
2336
2337AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2338
2339
mjw20bafc22014-05-09 11:41:46 +00002340# does the amd64 assembler understand MPX instructions?
2341# Note, this doesn't generate a C-level symbol. It generates a
2342# automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2343AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2344
2345AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2346 asm ("bndmov %bnd0,(%rsp)")
2347]])], [
2348ac_have_as_mpx=yes
2349AC_MSG_RESULT([yes])
2350], [
2351ac_have_as_mpx=no
2352AC_MSG_RESULT([no])
2353])
2354
2355AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2356
2357
2358# Does the C compiler support the "ifunc" attribute
2359# Note, this doesn't generate a C-level symbol. It generates a
2360# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
sewardjb08d84d2012-07-16 08:23:26 +00002361# does the x86/amd64 assembler understand MOVBE?
2362# Note, this doesn't generate a C-level symbol. It generates a
2363# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2364AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2365
2366AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2367 do { long long int x;
2368 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002369 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
sewardjb08d84d2012-07-16 08:23:26 +00002370 while (0)
2371]])], [
2372ac_have_as_movbe=yes
2373AC_MSG_RESULT([yes])
2374], [
2375ac_have_as_movbe=no
2376AC_MSG_RESULT([no])
2377])
2378
2379AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2380
2381
florian251c2f92012-07-05 21:21:37 +00002382# Does the C compiler support the "ifunc" attribute
2383# Note, this doesn't generate a C-level symbol. It generates a
2384# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2385AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2386
florianf78a5032012-07-06 09:17:29 +00002387AC_LINK_IFELSE([AC_LANG_SOURCE([[
2388static void mytest(void) {}
2389
2390static void (*resolve_test(void))(void)
2391{
2392 return (void (*)(void))&mytest;
2393}
2394
2395void test(void) __attribute__((ifunc("resolve_test")));
2396
2397int main()
2398{
2399 test();
2400 return 0;
2401}
florian251c2f92012-07-05 21:21:37 +00002402]])], [
2403ac_have_ifunc_attr=yes
2404AC_MSG_RESULT([yes])
2405], [
2406ac_have_ifunc_attr=no
2407AC_MSG_RESULT([no])
2408])
2409
2410AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2411
2412
sewardje089f012010-10-13 21:47:29 +00002413# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2414# when building the tool executables. I think we should get rid of it.
2415#
sewardjb5f6f512005-03-10 23:59:00 +00002416# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00002417AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2418 [[return foo;]])],
2419 [vg_cv_linktime_tls=yes],
2420 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00002421# Native compilation: check whether running a program using TLS succeeds.
2422# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2423# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00002424# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00002425AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2426 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2427 [vg_cv_tls=$enableval],
2428 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2429 [[return foo;]])],
2430 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00002431 [vg_cv_tls=no],
2432 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00002433
2434if test "$vg_cv_tls" = yes; then
2435AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2436fi
sewardj5b754b42002-06-03 22:53:35 +00002437
sewardj535c50f2005-06-04 23:14:53 +00002438
njn7fd6d382009-01-22 21:56:32 +00002439#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00002440# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00002441#----------------------------------------------------------------------------
2442
sewardjde4a1d02002-03-22 01:27:54 +00002443AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00002444AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00002445 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00002446 endian.h \
2447 mqueue.h \
2448 sys/endian.h \
2449 sys/epoll.h \
2450 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00002451 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00002452 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00002453 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00002454 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00002455 sys/syscall.h \
2456 sys/time.h \
2457 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00002458 ])
sewardjde4a1d02002-03-22 01:27:54 +00002459
bart818f17e2011-09-17 06:24:49 +00002460# Verify whether the <linux/futex.h> header is usable.
2461AC_MSG_CHECKING([if <linux/futex.h> is usable])
2462
sewardjc12486b2012-12-17 14:46:48 +00002463save_CFLAGS="$CFLAGS"
2464CFLAGS="$CFLAGS -D__user="
bart417cf3e2011-10-22 09:21:24 +00002465AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00002466#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00002467]], [[
bart818f17e2011-09-17 06:24:49 +00002468 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00002469]])], [
bart78bfc712011-12-08 16:14:59 +00002470ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00002471AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2472 [Define to 1 if you have a usable <linux/futex.h> header file.])
2473AC_MSG_RESULT([yes])
2474], [
bart78bfc712011-12-08 16:14:59 +00002475ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00002476AC_MSG_RESULT([no])
2477])
sewardjc12486b2012-12-17 14:46:48 +00002478CFLAGS="$save_CFLAGS"
2479
bart818f17e2011-09-17 06:24:49 +00002480
njn7fd6d382009-01-22 21:56:32 +00002481#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002482# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00002483#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002484AC_TYPE_UID_T
2485AC_TYPE_OFF_T
2486AC_TYPE_SIZE_T
2487AC_HEADER_TIME
2488
sewardj535c50f2005-06-04 23:14:53 +00002489
njn7fd6d382009-01-22 21:56:32 +00002490#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002491# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00002492#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002493AC_FUNC_MEMCMP
2494AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00002495
bart26288e42011-04-03 16:46:01 +00002496AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00002497AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00002498
bartf5ceec82008-04-26 07:45:10 +00002499AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00002500 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00002501 epoll_create \
2502 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00002503 klogctl \
bartf5ceec82008-04-26 07:45:10 +00002504 mallinfo \
2505 memchr \
2506 memset \
2507 mkdir \
njnf76d27a2009-05-28 01:53:07 +00002508 mremap \
bartf5ceec82008-04-26 07:45:10 +00002509 ppoll \
bart6d45e922009-01-20 13:45:38 +00002510 pthread_barrier_init \
2511 pthread_condattr_setclock \
2512 pthread_mutex_timedlock \
2513 pthread_rwlock_timedrdlock \
2514 pthread_rwlock_timedwrlock \
2515 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00002516 pthread_yield \
florianc5325ef2013-09-17 20:15:36 +00002517 pthread_setname_np \
bartd1f724c2009-08-26 18:11:18 +00002518 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00002519 semtimedop \
2520 signalfd \
njn6cc22472009-03-16 03:46:48 +00002521 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00002522 strchr \
2523 strdup \
2524 strpbrk \
2525 strrchr \
2526 strstr \
barta72a27b2010-04-29 06:22:17 +00002527 syscall \
bartf5ceec82008-04-26 07:45:10 +00002528 utimensat \
tom9e4b6362012-02-10 09:39:37 +00002529 process_vm_readv \
2530 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00002531 ])
sewardjde4a1d02002-03-22 01:27:54 +00002532
bart623eec32008-07-29 17:54:49 +00002533# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2534# libraries with any shared object and/or executable. This is NOT what we
2535# want for e.g. vgpreload_core-x86-linux.so
2536LIBS=""
sewardj80637752006-03-02 13:48:21 +00002537
bart6d45e922009-01-20 13:45:38 +00002538AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2539 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00002540AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2541 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00002542AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2543 [test x$ac_cv_func_pthread_spin_lock = xyes])
florianc5325ef2013-09-17 20:15:36 +00002544AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2545 [test x$ac_cv_func_pthread_setname_np = xyes])
bart6d45e922009-01-20 13:45:38 +00002546
petarjc37cea62013-06-02 18:08:04 +00002547if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2548 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
petarj6d79b742012-12-20 18:56:57 +00002549 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
petarjc37cea62013-06-02 18:08:04 +00002550 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
petarj6d79b742012-12-20 18:56:57 +00002551fi
njn7fd6d382009-01-22 21:56:32 +00002552
2553#----------------------------------------------------------------------------
2554# MPI checks
2555#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00002556# Do we have a useable MPI setup on the primary and/or secondary targets?
2557# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00002558# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00002559# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00002560# --with-mpicc=.
mjw46f25042014-08-21 10:04:04 +00002561AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2562 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
sewardj03d86f22006-10-17 00:57:24 +00002563
sewardje9fa5062006-03-12 18:29:18 +00002564mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00002565if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00002566 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj5db15402012-06-07 09:13:21 +00002567 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +00002568 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2569 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002570 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00002571elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002572 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjf0c12502014-01-12 12:54:00 +00002573 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002574 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002575 mflag_primary=$FLAG_M64
philippef7c54332012-05-17 15:32:54 +00002576elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2577 mflag_primary="$FLAG_M32 -arch i386"
2578elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2579 mflag_primary="$FLAG_M64 -arch x86_64"
sewardje9fa5062006-03-12 18:29:18 +00002580fi
2581
sewardj03d86f22006-10-17 00:57:24 +00002582mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00002583if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2584 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00002585 mflag_secondary=$FLAG_M32
philippef7c54332012-05-17 15:32:54 +00002586elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2587 mflag_secondary="$FLAG_M32 -arch i386"
sewardj03d86f22006-10-17 00:57:24 +00002588fi
2589
2590
sewardj0ad46092006-03-02 17:09:16 +00002591AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00002592 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00002593 MPI_CC=$withval
2594)
sewardj03d86f22006-10-17 00:57:24 +00002595AC_SUBST(MPI_CC)
2596
philippef7c54332012-05-17 15:32:54 +00002597## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2598## use these values in the check for a functioning mpicc.
2599##
2600## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2601## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2602AM_COND_IF([VGCONF_OS_IS_LINUX],
2603 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2604 LDFLAGS_MPI="-fpic -shared"])
2605AM_COND_IF([VGCONF_OS_IS_DARWIN],
2606 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2607 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2608
2609AC_SUBST([CFLAGS_MPI])
2610AC_SUBST([LDFLAGS_MPI])
2611
2612
sewardj03d86f22006-10-17 00:57:24 +00002613## See if MPI_CC works for the primary target
2614##
2615AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00002616saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00002617saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00002618CC=$MPI_CC
philippef7c54332012-05-17 15:32:54 +00002619CFLAGS="$CFLAGS_MPI $mflag_primary"
2620saved_LDFLAGS="$LDFLAGS"
2621LDFLAGS="$LDFLAGS_MPI $mflag_primary"
bart417cf3e2011-10-22 09:21:24 +00002622AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00002623#include <mpi.h>
2624#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002625]], [[
philippef7c54332012-05-17 15:32:54 +00002626 int ni, na, nd, comb;
sewardjde4f3842006-03-09 02:41:41 +00002627 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002628 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2629 r |= MPI_Finalize();
sewardjde4f3842006-03-09 02:41:41 +00002630 return r;
bart417cf3e2011-10-22 09:21:24 +00002631]])], [
sewardj03d86f22006-10-17 00:57:24 +00002632ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00002633AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00002634], [
sewardj03d86f22006-10-17 00:57:24 +00002635ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00002636AC_MSG_RESULT([no])
2637])
sewardj0ad46092006-03-02 17:09:16 +00002638CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00002639CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002640LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002641AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00002642
sewardj03d86f22006-10-17 00:57:24 +00002643## See if MPI_CC works for the secondary target. Complication: what if
2644## there is no secondary target? We need this to then fail.
2645## Kludge this by making MPI_CC something which will surely fail in
2646## such a case.
2647##
2648AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2649saved_CC=$CC
2650saved_CFLAGS=$CFLAGS
philippef7c54332012-05-17 15:32:54 +00002651saved_LDFLAGS="$LDFLAGS"
2652LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
njn7fd6d382009-01-22 21:56:32 +00002653if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00002654 CC="$MPI_CC this will surely fail"
2655else
2656 CC=$MPI_CC
2657fi
philippef7c54332012-05-17 15:32:54 +00002658CFLAGS="$CFLAGS_MPI $mflag_secondary"
bart417cf3e2011-10-22 09:21:24 +00002659AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00002660#include <mpi.h>
2661#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002662]], [[
philippef7c54332012-05-17 15:32:54 +00002663 int ni, na, nd, comb;
sewardj03d86f22006-10-17 00:57:24 +00002664 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002665 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2666 r |= MPI_Finalize();
sewardj03d86f22006-10-17 00:57:24 +00002667 return r;
bart417cf3e2011-10-22 09:21:24 +00002668]])], [
sewardj03d86f22006-10-17 00:57:24 +00002669ac_have_mpi2_sec=yes
2670AC_MSG_RESULT([yes, $MPI_CC])
2671], [
2672ac_have_mpi2_sec=no
2673AC_MSG_RESULT([no])
2674])
2675CC=$saved_CC
2676CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002677LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002678AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00002679
2680
njn7fd6d382009-01-22 21:56:32 +00002681#----------------------------------------------------------------------------
2682# Other library checks
2683#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00002684# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00002685# tests are present because Drd has some regression tests that use
2686# these packages. All regression test programs all compiled only
2687# for the primary target. And so it is important that the configure
2688# checks that follow, use the correct -m32 or -m64 flag for the
2689# primary target (called $mflag_primary). Otherwise, we can end up
2690# in a situation (eg) where, on amd64-linux, the test for Boost checks
2691# for usable 64-bit Boost facilities, but because we are doing a 32-bit
2692# only build (meaning, the primary target is x86-linux), the build
2693# of the regtest programs that use Boost fails, because they are
2694# build as 32-bit (IN THIS EXAMPLE).
2695#
2696# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2697# NEEDED BY THE REGRESSION TEST PROGRAMS.
2698
2699
sewardj493c4ef2008-12-13 16:45:19 +00002700# Check whether the boost library 1.35 or later has been installed.
2701# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2702
2703AC_MSG_CHECKING([for boost])
2704
2705AC_LANG(C++)
2706safe_CXXFLAGS=$CXXFLAGS
bart7129c722012-04-18 18:34:22 +00002707CXXFLAGS="$mflag_primary"
2708safe_LIBS="$LIBS"
bartce93f9e2014-06-12 07:45:23 +00002709LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002710
bart128fc522011-03-12 10:36:35 +00002711AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002712#include <boost/thread.hpp>
2713static void thread_func(void)
2714{ }
2715int main(int argc, char** argv)
2716{
2717 boost::thread t(thread_func);
2718 return 0;
2719}
bart128fc522011-03-12 10:36:35 +00002720])],
sewardj493c4ef2008-12-13 16:45:19 +00002721[
2722ac_have_boost_1_35=yes
2723AC_SUBST([BOOST_CFLAGS], [])
bartce93f9e2014-06-12 07:45:23 +00002724AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
sewardj493c4ef2008-12-13 16:45:19 +00002725AC_MSG_RESULT([yes])
2726], [
2727ac_have_boost_1_35=no
2728AC_MSG_RESULT([no])
2729])
2730
bart7129c722012-04-18 18:34:22 +00002731LIBS="$safe_LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002732CXXFLAGS=$safe_CXXFLAGS
2733AC_LANG(C)
2734
2735AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2736
2737
2738# does this compiler support -fopenmp, does it have the include file
2739# <omp.h> and does it have libgomp ?
2740
2741AC_MSG_CHECKING([for OpenMP])
2742
2743safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00002744CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00002745
bart128fc522011-03-12 10:36:35 +00002746AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002747#include <omp.h>
2748int main(int argc, char** argv)
2749{
2750 omp_set_dynamic(0);
2751 return 0;
2752}
bart128fc522011-03-12 10:36:35 +00002753])],
sewardj493c4ef2008-12-13 16:45:19 +00002754[
2755ac_have_openmp=yes
2756AC_MSG_RESULT([yes])
2757], [
2758ac_have_openmp=no
2759AC_MSG_RESULT([no])
2760])
2761CFLAGS=$safe_CFLAGS
2762
2763AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2764
2765
bart78bfc712011-12-08 16:14:59 +00002766# does this compiler have built-in functions for atomic memory access for the
2767# primary target ?
2768AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00002769
2770safe_CFLAGS=$CFLAGS
2771CFLAGS="$mflag_primary"
2772
bart417cf3e2011-10-22 09:21:24 +00002773AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00002774 int variable = 1;
2775 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2776 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002777]])], [
bartb4ff7822011-12-10 19:48:04 +00002778 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00002779 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00002780 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 +00002781], [
bartb4ff7822011-12-10 19:48:04 +00002782 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00002783 AC_MSG_RESULT([no])
2784])
2785
2786CFLAGS=$safe_CFLAGS
2787
bartb4ff7822011-12-10 19:48:04 +00002788AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2789 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00002790
bart78bfc712011-12-08 16:14:59 +00002791
2792# does this compiler have built-in functions for atomic memory access for the
2793# secondary target ?
2794
2795if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2796
2797AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2798
2799safe_CFLAGS=$CFLAGS
2800CFLAGS="$mflag_secondary"
2801
2802AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2803 int variable = 1;
2804 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2805]])], [
2806 ac_have_builtin_atomic_secondary=yes
2807 AC_MSG_RESULT([yes])
2808], [
2809 ac_have_builtin_atomic_secondary=no
2810 AC_MSG_RESULT([no])
2811])
2812
2813CFLAGS=$safe_CFLAGS
2814
2815fi
2816
2817AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2818 [test x$ac_have_builtin_atomic_secondary = xyes])
2819
bart1e856ea2011-12-17 12:53:23 +00002820# does this compiler have built-in functions for atomic memory access on
2821# 64-bit integers for all targets ?
2822
2823AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2824
2825AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2826 #include <stdint.h>
2827]], [[
2828 uint64_t variable = 1;
2829 return __sync_add_and_fetch(&variable, 1)
2830]])], [
2831 ac_have_builtin_atomic64_primary=yes
2832], [
2833 ac_have_builtin_atomic64_primary=no
2834])
2835
2836if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2837
2838safe_CFLAGS=$CFLAGS
2839CFLAGS="$mflag_secondary"
2840
2841AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2842 #include <stdint.h>
2843]], [[
2844 uint64_t variable = 1;
2845 return __sync_add_and_fetch(&variable, 1)
2846]])], [
2847 ac_have_builtin_atomic64_secondary=yes
2848], [
2849 ac_have_builtin_atomic64_secondary=no
2850])
2851
2852CFLAGS=$safe_CFLAGS
2853
2854fi
2855
2856if test x$ac_have_builtin_atomic64_primary = xyes && \
2857 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2858 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2859 AC_MSG_RESULT([yes])
2860 ac_have_builtin_atomic64=yes
2861else
2862 AC_MSG_RESULT([no])
2863 ac_have_builtin_atomic64=no
2864fi
2865
2866AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2867 [test x$ac_have_builtin_atomic64 = xyes])
2868
bart78bfc712011-12-08 16:14:59 +00002869
barte8740422011-03-24 20:27:54 +00002870# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002871AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002872
2873safe_CXXFLAGS=$CXXFLAGS
2874CXXFLAGS="$mflag_primary"
2875
2876AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002877AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002878 int variable = 1;
2879 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2880 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002881]])], [
barte8740422011-03-24 20:27:54 +00002882 ac_have_builtin_atomic_cxx=yes
2883 AC_MSG_RESULT([yes])
2884 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 +00002885], [
barte8740422011-03-24 20:27:54 +00002886 ac_have_builtin_atomic_cxx=no
2887 AC_MSG_RESULT([no])
2888])
2889AC_LANG_POP(C++)
2890
2891CXXFLAGS=$safe_CXXFLAGS
2892
2893AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002894
bart78bfc712011-12-08 16:14:59 +00002895
2896if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002897 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002898 ac_enable_linux_ticket_lock_primary=yes
2899fi
2900AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2901 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2902
2903if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2904 -a x$ac_have_usable_linux_futex_h = xyes \
2905 -a x$ac_have_builtin_atomic_secondary = xyes; then
2906 ac_enable_linux_ticket_lock_secondary=yes
2907fi
2908AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2909 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2910
2911
bartf68af882011-12-10 19:42:05 +00002912# does libstdc++ support annotating shared pointers ?
2913AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2914
floriand79b3bf2013-10-02 15:14:59 +00002915safe_CXXFLAGS=$CXXFLAGS
bartf68af882011-12-10 19:42:05 +00002916CXXFLAGS="-std=c++0x"
2917
2918AC_LANG_PUSH(C++)
2919AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2920 #include <memory>
2921]], [[
2922 std::shared_ptr<int> p
2923]])], [
2924 ac_have_shared_ptr=yes
2925], [
2926 ac_have_shared_ptr=no
2927])
2928if test x$ac_have_shared_ptr = xyes; then
2929 # If compilation of the program below fails because of a syntax error
2930 # triggered by substituting one of the annotation macros then that
2931 # means that libstdc++ supports these macros.
2932 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2933 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2934 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2935 #include <memory>
2936 ]], [[
2937 std::shared_ptr<int> p
2938 ]])], [
2939 ac_have_shared_pointer_annotation=no
2940 AC_MSG_RESULT([no])
2941 ], [
2942 ac_have_shared_pointer_annotation=yes
2943 AC_MSG_RESULT([yes])
2944 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2945 [Define to 1 if libstd++ supports annotating shared pointers])
2946 ])
2947else
2948 ac_have_shared_pointer_annotation=no
2949 AC_MSG_RESULT([no])
2950fi
2951AC_LANG_POP(C++)
2952
2953CXXFLAGS=$safe_CXXFLAGS
2954
2955AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2956 [test x$ac_have_shared_pointer_annotation = xyes])
2957
2958
njn7fd6d382009-01-22 21:56:32 +00002959#----------------------------------------------------------------------------
2960# Ok. We're done checking.
2961#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002962
njn8b68b642009-06-24 00:37:09 +00002963# Nb: VEX/Makefile is generated from Makefile.vex.in.
2964AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002965 Makefile
njn8b68b642009-06-24 00:37:09 +00002966 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002967 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002968 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002969 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002970 docs/Makefile
2971 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002972 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002973 perf/Makefile
2974 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002975 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002976 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002977 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002978 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002979 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002980 memcheck/Makefile
2981 memcheck/tests/Makefile
floriane42cca52013-08-29 17:59:27 +00002982 memcheck/tests/common/Makefile
njnc6168192004-11-29 13:54:10 +00002983 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002984 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002985 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002986 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002987 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002988 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002989 memcheck/tests/ppc32/Makefile
2990 memcheck/tests/ppc64/Makefile
florian0bb707e2012-05-30 20:46:58 +00002991 memcheck/tests/s390x/Makefile
florianbb913cd2012-08-28 16:50:39 +00002992 memcheck/tests/vbit-test/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002993 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002994 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002995 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002996 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002997 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002998 callgrind/Makefile
2999 callgrind/callgrind_annotate
3000 callgrind/callgrind_control
3001 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00003002 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00003003 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00003004 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00003005 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00003006 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00003007 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00003008 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00003009 none/Makefile
3010 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00003011 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00003012 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00003013 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00003014 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00003015 none/tests/arm/Makefile
sewardjf02d2ec2014-08-26 19:28:09 +00003016 none/tests/arm64/Makefile
sewardjb5b87402011-03-07 16:05:35 +00003017 none/tests/s390x/Makefile
sewardj5db15402012-06-07 09:13:21 +00003018 none/tests/mips32/Makefile
petarj8bea8672013-05-10 13:14:54 +00003019 none/tests/mips64/Makefile
njn0458a122009-02-13 06:23:46 +00003020 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00003021 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00003022 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00003023 exp-sgcheck/Makefile
3024 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00003025 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00003026 drd/scripts/download-and-build-splash2
3027 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00003028 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00003029 exp-bbv/tests/Makefile
3030 exp-bbv/tests/x86/Makefile
3031 exp-bbv/tests/x86-linux/Makefile
3032 exp-bbv/tests/amd64-linux/Makefile
3033 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00003034 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00003035 exp-dhat/Makefile
3036 exp-dhat/tests/Makefile
mjwaeacd282014-03-11 19:30:32 +00003037 shared/Makefile
njn8b68b642009-06-24 00:37:09 +00003038])
sewardjd3645802010-06-13 22:13:58 +00003039AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3040 [chmod +x coregrind/link_tool_exe_linux])
3041AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3042 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00003043AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00003044
3045cat<<EOF
3046
njn311303f2009-02-06 03:46:50 +00003047 Maximum build arch: ${ARCH_MAX}
3048 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00003049 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00003050 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00003051 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3052 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00003053 Platform variant: ${VGCONF_PLATVARIANT}
3054 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00003055 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00003056
gobry3b777892002-04-04 09:18:39 +00003057EOF