blob: 2aeed78e6a74f1a0993a941ee917098690300941 [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.
sewardja19c8182014-09-12 09:31:13 +000011AC_INIT([Valgrind],[3.11.0.SVN],[valgrind-users@lists.sourceforge.net])
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
bart417cf3e2011-10-22 09:21:24 +000013AC_CONFIG_HEADERS([config.h])
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
bartfec24472014-09-13 09:42:29 +0000134# Note: m4 arguments are quoted with [ and ] so square brackets in shell
135# statements have to be quoted.
sewardj3ab7b662011-09-29 17:30:13 +0000136case "${is_clang}-${gcc_version}" in
bartfec24472014-09-13 09:42:29 +0000137 notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
sewardj3ab7b662011-09-29 17:30:13 +0000138 AC_MSG_RESULT([ok (${gcc_version})])
139 ;;
bartfec24472014-09-13 09:42:29 +0000140 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
sewardj3ab7b662011-09-29 17:30:13 +0000141 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000142 ;;
gobrye721a522002-03-22 13:38:30 +0000143 *)
sewardj3ab7b662011-09-29 17:30:13 +0000144 AC_MSG_RESULT([no (${gcc_version})])
145 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000146 ;;
147esac
148
njn7fd6d382009-01-22 21:56:32 +0000149#----------------------------------------------------------------------------
150# Arch/OS/platform tests.
151#----------------------------------------------------------------------------
152# We create a number of arch/OS/platform-related variables. We prefix them
153# all with "VGCONF_" which indicates that they are defined at
154# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
155# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000156
sewardjde4a1d02002-03-22 01:27:54 +0000157AC_CANONICAL_HOST
158
159AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000160
njn7fd6d382009-01-22 21:56:32 +0000161# ARCH_MAX reflects the most that this CPU can do: for example if it
162# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
163# Ditto for amd64. It is used for more configuration below, but is not used
164# outside this file.
carllcae0cc22014-08-07 23:17:29 +0000165#
166# Power PC returns powerpc for Big Endian. This was not changed when Little
167# Endian support was added to the 64-bit architecture. The 64-bit Little
168# Endian systems explicitly state le in the host_cpu. For clarity in the
169# Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of
170# the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
171# The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
172# Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess.
173# The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
174# Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
175# Little Endian.
176
gobrye721a522002-03-22 13:38:30 +0000177case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000178 i?86)
179 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000180 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000181 ;;
182
njnfe408942004-11-23 17:52:24 +0000183 x86_64)
184 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000185 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000186 ;;
187
sewardj2c48c7b2005-11-29 13:05:56 +0000188 powerpc64)
carllcae0cc22014-08-07 23:17:29 +0000189 # this only referrs to 64-bit Big Endian
sewardj2c48c7b2005-11-29 13:05:56 +0000190 AC_MSG_RESULT([ok (${host_cpu})])
carllcae0cc22014-08-07 23:17:29 +0000191 ARCH_MAX="ppc64be"
192 ;;
193
194 powerpc64le)
195 # this only referrs to 64-bit Little Endian
196 AC_MSG_RESULT([ok (${host_cpu})])
197 ARCH_MAX="ppc64le"
sewardj2c48c7b2005-11-29 13:05:56 +0000198 ;;
199
200 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000201 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000202 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000203 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000204 ;;
205
sewardjb5b87402011-03-07 16:05:35 +0000206 s390x)
207 AC_MSG_RESULT([ok (${host_cpu})])
208 ARCH_MAX="s390x"
209 ;;
210
sewardj59570ff2010-01-01 11:59:33 +0000211 armv7*)
212 AC_MSG_RESULT([ok (${host_cpu})])
213 ARCH_MAX="arm"
214 ;;
215
sewardjf0c12502014-01-12 12:54:00 +0000216 aarch64*)
217 AC_MSG_RESULT([ok (${host_cpu})])
218 ARCH_MAX="arm64"
219 ;;
220
sewardj5db15402012-06-07 09:13:21 +0000221 mips)
petarj4df0bfc2013-02-27 23:17:33 +0000222 AC_MSG_RESULT([ok (${host_cpu})])
223 ARCH_MAX="mips32"
224 ;;
sewardj5db15402012-06-07 09:13:21 +0000225
226 mipsel)
petarj4df0bfc2013-02-27 23:17:33 +0000227 AC_MSG_RESULT([ok (${host_cpu})])
228 ARCH_MAX="mips32"
229 ;;
sewardj5db15402012-06-07 09:13:21 +0000230
231 mipsisa32r2)
petarj4df0bfc2013-02-27 23:17:33 +0000232 AC_MSG_RESULT([ok (${host_cpu})])
233 ARCH_MAX="mips32"
234 ;;
sewardj5db15402012-06-07 09:13:21 +0000235
petarj4df0bfc2013-02-27 23:17:33 +0000236 mips64*)
237 AC_MSG_RESULT([ok (${host_cpu})])
238 ARCH_MAX="mips64"
239 ;;
240
241 mipsisa64*)
242 AC_MSG_RESULT([ok (${host_cpu})])
243 ARCH_MAX="mips64"
244 ;;
sewardjde4a1d02002-03-22 01:27:54 +0000245 *)
246 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000247 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000248 ;;
249esac
250
njn7fd6d382009-01-22 21:56:32 +0000251#----------------------------------------------------------------------------
252
sewardj86e992f2006-01-28 18:39:09 +0000253# Sometimes it's convenient to subvert the bi-arch build system and
254# just have a single build even though the underlying platform is
255# capable of both. Hence handle --enable-only64bit and
256# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000257# [Actually, if either of these options are used, I think both get built,
258# but only one gets installed. So if you use an in-place build, both can be
259# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000260
261# Check if a 64-bit only build has been requested
262AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
263 [AC_ARG_ENABLE(only64bit,
264 [ --enable-only64bit do a 64-bit only build],
265 [vg_cv_only64bit=$enableval],
266 [vg_cv_only64bit=no])])
267
268# Check if a 32-bit only build has been requested
269AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
270 [AC_ARG_ENABLE(only32bit,
271 [ --enable-only32bit do a 32-bit only build],
272 [vg_cv_only32bit=$enableval],
273 [vg_cv_only32bit=no])])
274
275# Stay sane
276if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
277 AC_MSG_ERROR(
278 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
279fi
280
njn7fd6d382009-01-22 21:56:32 +0000281#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000282
njn311303f2009-02-06 03:46:50 +0000283# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
284# compilation of many C files via -VGO_$(VGCONF_OS) and
285# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000286AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000287AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000288
njnf76d27a2009-05-28 01:53:07 +0000289DEFAULT_SUPP=""
290
gobrye721a522002-03-22 13:38:30 +0000291case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000292 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000293 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000294 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000295
296 # Ok, this is linux. Check the kernel version
297 AC_MSG_CHECKING([for the kernel version])
298
299 kernel=`uname -r`
300
301 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000302 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000303 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
304 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 +0000305 ;;
306
307 2.4.*)
308 AC_MSG_RESULT([2.4 family (${kernel})])
309 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
310 ;;
311
mueller8c68e042004-01-03 15:21:14 +0000312 *)
313 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000314 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000315 ;;
316 esac
317
318 ;;
319
njnf76d27a2009-05-28 01:53:07 +0000320 *darwin*)
321 AC_MSG_RESULT([ok (${host_os})])
322 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000323 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
324 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
325 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
sewardjae284e52012-08-02 18:25:04 +0000326 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
sewardjec66ad52014-06-20 11:48:38 +0000327 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
njnf76d27a2009-05-28 01:53:07 +0000328
329 AC_MSG_CHECKING([for the kernel version])
330 kernel=`uname -r`
331
332 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
333 # has only one relevant version, the OS version. The `uname` check
334 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000335 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
336 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000337 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000338 #
339 # XXX: `uname -r` won't do the right thing for cross-compiles, but
340 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000341 #
342 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
343 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
344 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
345 # time support for 10.5 (the 9.* pattern just below), I'll leave it
346 # in for now, just in case anybody wants to give it a try. But I'm
347 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000348 case "${kernel}" in
349 9.*)
350 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000351 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000352 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000353 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000354 ;;
njnea2d6fd2010-07-01 00:20:20 +0000355 10.*)
356 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
357 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
358 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
359 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
360 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000361 11.*)
362 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
363 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
sewardj731f9cf2011-09-21 08:43:08 +0000364 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
365 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
366 ;;
sewardjae284e52012-08-02 18:25:04 +0000367 12.*)
368 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
369 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
370 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
371 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
372 ;;
sewardjec66ad52014-06-20 11:48:38 +0000373 13.*)
374 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
375 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
376 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
377 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
378 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000379 *)
njnf76d27a2009-05-28 01:53:07 +0000380 AC_MSG_RESULT([unsupported (${kernel})])
sewardjec66ad52014-06-20 11:48:38 +0000381 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 +0000382 ;;
383 esac
384 ;;
385
sewardjde4a1d02002-03-22 01:27:54 +0000386 *)
387 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000388 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000389 ;;
390esac
391
njn7fd6d382009-01-22 21:56:32 +0000392#----------------------------------------------------------------------------
393
tomd6398392006-06-07 17:44:36 +0000394# If we are building on a 64 bit platform test to see if the system
395# supports building 32 bit programs and disable 32 bit support if it
396# does not support building 32 bit programs
397
njn7fd6d382009-01-22 21:56:32 +0000398case "$ARCH_MAX-$VGCONF_OS" in
mjw676bf0d2014-08-27 18:29:34 +0000399 amd64-linux|ppc64be-linux|arm64-linux)
tomd6398392006-06-07 17:44:36 +0000400 AC_MSG_CHECKING([for 32 bit build support])
401 safe_CFLAGS=$CFLAGS
402 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000403 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000404 return 0;
bart417cf3e2011-10-22 09:21:24 +0000405 ]])], [
tomd6398392006-06-07 17:44:36 +0000406 AC_MSG_RESULT([yes])
407 ], [
408 vg_cv_only64bit="yes"
409 AC_MSG_RESULT([no])
410 ])
411 CFLAGS=$safe_CFLAGS;;
412esac
413
414if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
415 AC_MSG_ERROR(
416 [--enable-only32bit was specified but system does not support 32 bit builds])
417fi
nethercote888ecb72004-08-23 14:54:40 +0000418
njn7fd6d382009-01-22 21:56:32 +0000419#----------------------------------------------------------------------------
420
njn311303f2009-02-06 03:46:50 +0000421# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
422# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
423# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
424# above) will be "amd64" since that reflects the most that this cpu can do,
425# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
426# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000427# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
428# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
429AC_SUBST(VGCONF_ARCH_PRI)
430
njn3f8a6e92009-06-02 00:20:47 +0000431# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
432# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
433# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
434# It is empty if there is no secondary target.
435AC_SUBST(VGCONF_ARCH_SEC)
436
njn311303f2009-02-06 03:46:50 +0000437# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
438# The entire system, including regression and performance tests, will be
439# built for this target. The "_CAPS" indicates that the name is in capital
440# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000441# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000442# convention and cannot contain '-' characters. This is in contrast to
443# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000444AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
445
446# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
447# Valgrind and tools will also be built for this target, but not the
448# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000449#
njn7fd6d382009-01-22 21:56:32 +0000450# By default, the primary arch is the same as the "max" arch, as commented
451# above (at the definition of ARCH_MAX). We may choose to downgrade it in
452# the big case statement just below here, in the case where we're building
453# on a 64 bit machine but have been requested only to do a 32 bit build.
454AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
455
sewardj01262142006-01-04 01:20:28 +0000456AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000457
njnea2d6fd2010-07-01 00:20:20 +0000458# NB. The load address for a given platform may be specified in more
459# than one place, in some cases, depending on whether we're doing a biarch,
460# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
461# Be careful to give consistent values in all subcases. Also, all four
462# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
463# even if it is to "0xUNSET".
464#
njn7fd6d382009-01-22 21:56:32 +0000465case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000466 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000467 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000468 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000469 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
470 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000471 valt_load_address_pri_norml="0x38000000"
472 valt_load_address_pri_inner="0x28000000"
473 valt_load_address_sec_norml="0xUNSET"
474 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000475 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000476 ;;
477 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000478 valt_load_address_sec_norml="0xUNSET"
479 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000480 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000481 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000482 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000483 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
484 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000485 valt_load_address_pri_norml="0x38000000"
486 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000487 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000488 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000489 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000490 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
491 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000492 valt_load_address_pri_norml="0x38000000"
493 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000494 else
njn7fd6d382009-01-22 21:56:32 +0000495 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000496 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000497 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
498 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000499 valt_load_address_pri_norml="0x38000000"
500 valt_load_address_pri_inner="0x28000000"
501 valt_load_address_sec_norml="0x38000000"
502 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000503 fi
njn377c43f2009-05-19 07:39:22 +0000504 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000505 ;;
506 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000507 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000508 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000509 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
510 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000511 valt_load_address_pri_norml="0x38000000"
512 valt_load_address_pri_inner="0x28000000"
513 valt_load_address_sec_norml="0xUNSET"
514 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000515 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000516 ;;
carllcae0cc22014-08-07 23:17:29 +0000517 ppc64be-linux)
njnea2d6fd2010-07-01 00:20:20 +0000518 valt_load_address_sec_norml="0xUNSET"
519 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000520 if test x$vg_cv_only64bit = xyes; then
carllcae0cc22014-08-07 23:17:29 +0000521 VGCONF_ARCH_PRI="ppc64be"
njn3f8a6e92009-06-02 00:20:47 +0000522 VGCONF_ARCH_SEC=""
carllcae0cc22014-08-07 23:17:29 +0000523 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
njn7fd6d382009-01-22 21:56:32 +0000524 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000525 valt_load_address_pri_norml="0x38000000"
526 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000527 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000528 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000529 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000530 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
531 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000532 valt_load_address_pri_norml="0x38000000"
533 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000534 else
carllcae0cc22014-08-07 23:17:29 +0000535 VGCONF_ARCH_PRI="ppc64be"
njn3f8a6e92009-06-02 00:20:47 +0000536 VGCONF_ARCH_SEC="ppc32"
carllcae0cc22014-08-07 23:17:29 +0000537 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
njn7fd6d382009-01-22 21:56:32 +0000538 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000539 valt_load_address_pri_norml="0x38000000"
540 valt_load_address_pri_inner="0x28000000"
541 valt_load_address_sec_norml="0x38000000"
542 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000543 fi
njn377c43f2009-05-19 07:39:22 +0000544 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000545 ;;
carllcae0cc22014-08-07 23:17:29 +0000546 ppc64le-linux)
547 # Little Endian is only supported on PPC64
548 valt_load_address_sec_norml="0xUNSET"
549 valt_load_address_sec_inner="0xUNSET"
550 VGCONF_ARCH_PRI="ppc64le"
551 VGCONF_ARCH_SEC=""
552 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
553 VGCONF_PLATFORM_SEC_CAPS=""
554 valt_load_address_pri_norml="0x38000000"
555 valt_load_address_pri_inner="0x28000000"
556 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
557 ;;
njncc58cea2010-07-05 07:21:22 +0000558 # Darwin gets identified as 32-bit even when it supports 64-bit.
559 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
560 # all Macs support both 32-bit and 64-bit, so we just build both. If
561 # someone has a really old 32-bit only machine they can (hopefully?)
562 # build with --enable-only32bit. See bug 243362.
563 x86-darwin|amd64-darwin)
564 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000565 valt_load_address_sec_norml="0xUNSET"
566 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000567 if test x$vg_cv_only64bit = xyes; then
568 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000569 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000570 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
571 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000572 valt_load_address_pri_norml="0x138000000"
573 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000574 elif test x$vg_cv_only32bit = xyes; then
575 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000576 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000577 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
578 VGCONF_PLATFORM_SEC_CAPS=""
579 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000580 valt_load_address_pri_norml="0x38000000"
581 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000582 else
583 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000584 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000585 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
586 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000587 valt_load_address_pri_norml="0x138000000"
588 valt_load_address_pri_inner="0x128000000"
589 valt_load_address_sec_norml="0x38000000"
590 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000591 fi
njnf76d27a2009-05-28 01:53:07 +0000592 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
593 ;;
sewardj59570ff2010-01-01 11:59:33 +0000594 arm-linux)
595 VGCONF_ARCH_PRI="arm"
596 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
597 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000598 valt_load_address_pri_norml="0x38000000"
599 valt_load_address_pri_inner="0x28000000"
600 valt_load_address_sec_norml="0xUNSET"
601 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000602 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
603 ;;
sewardjf0c12502014-01-12 12:54:00 +0000604 arm64-linux)
605 valt_load_address_sec_norml="0xUNSET"
606 valt_load_address_sec_inner="0xUNSET"
607 if test x$vg_cv_only64bit = xyes; then
608 VGCONF_ARCH_PRI="arm64"
609 VGCONF_ARCH_SEC=""
610 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
611 VGCONF_PLATFORM_SEC_CAPS=""
612 valt_load_address_pri_norml="0x38000000"
613 valt_load_address_pri_inner="0x28000000"
614 elif test x$vg_cv_only32bit = xyes; then
615 VGCONF_ARCH_PRI="arm"
616 VGCONF_ARCH_SEC=""
617 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
618 VGCONF_PLATFORM_SEC_CAPS=""
619 valt_load_address_pri_norml="0x38000000"
620 valt_load_address_pri_inner="0x28000000"
621 else
622 VGCONF_ARCH_PRI="arm64"
623 VGCONF_ARCH_SEC="arm"
624 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
625 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
626 valt_load_address_pri_norml="0x38000000"
627 valt_load_address_pri_inner="0x28000000"
628 valt_load_address_sec_norml="0x38000000"
629 valt_load_address_sec_inner="0x28000000"
630 fi
631 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
632 ;;
sewardjb5b87402011-03-07 16:05:35 +0000633 s390x-linux)
634 VGCONF_ARCH_PRI="s390x"
635 VGCONF_ARCH_SEC=""
636 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
637 VGCONF_PLATFORM_SEC_CAPS=""
cborntraf4c46902013-10-23 16:23:30 +0000638 # To improve branch prediction hit rate we want to have
639 # the generated code close to valgrind (host) code
640 valt_load_address_pri_norml="0x800000000"
641 valt_load_address_pri_inner="0x810000000"
sewardjb5b87402011-03-07 16:05:35 +0000642 valt_load_address_sec_norml="0xUNSET"
643 valt_load_address_sec_inner="0xUNSET"
644 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
645 ;;
sewardj5db15402012-06-07 09:13:21 +0000646 mips32-linux)
647 VGCONF_ARCH_PRI="mips32"
648 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
649 VGCONF_PLATFORM_SEC_CAPS=""
650 valt_load_address_pri_norml="0x38000000"
651 valt_load_address_pri_inner="0x28000000"
652 valt_load_address_sec_norml="0xUNSET"
653 valt_load_address_sec_inner="0xUNSET"
654 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
petarj4df0bfc2013-02-27 23:17:33 +0000655 ;;
656 mips64-linux)
657 VGCONF_ARCH_PRI="mips64"
658 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
659 VGCONF_PLATFORM_SEC_CAPS=""
660 valt_load_address_pri_norml="0x38000000"
661 valt_load_address_pri_inner="0x28000000"
662 valt_load_address_sec_norml="0xUNSET"
663 valt_load_address_sec_inner="0xUNSET"
664 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj5db15402012-06-07 09:13:21 +0000665 ;;
nethercote888ecb72004-08-23 14:54:40 +0000666 *)
njn7fd6d382009-01-22 21:56:32 +0000667 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000668 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000669 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
670 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000671 valt_load_address_pri_norml="0xUNSET"
672 valt_load_address_pri_inner="0xUNSET"
673 valt_load_address_sec_norml="0xUNSET"
674 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000675 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000676 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000677 ;;
678esac
sewardjde4a1d02002-03-22 01:27:54 +0000679
njn7fd6d382009-01-22 21:56:32 +0000680#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000681
njn7fd6d382009-01-22 21:56:32 +0000682# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
683# defined.
684AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
685 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000686 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
687 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
688 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000689AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000690 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
691 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000692AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
693 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000694 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000695AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
carllcae0cc22014-08-07 23:17:29 +0000696 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
697 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000698AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
sewardjf0c12502014-01-12 12:54:00 +0000699 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
700 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
701AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
702 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000703AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
704 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj5db15402012-06-07 09:13:21 +0000705AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
706 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
petarj4df0bfc2013-02-27 23:17:33 +0000707AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
708 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000709
njn7fd6d382009-01-22 21:56:32 +0000710# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
711# become defined.
712AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
713 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
714 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
715AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
716 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
717AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
718 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
719 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
carllcae0cc22014-08-07 23:17:29 +0000720AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
721 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
722AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
723 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000724AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
sewardjf0c12502014-01-12 12:54:00 +0000725 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
726 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
727AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
728 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000729AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
730 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
731 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
sewardj5db15402012-06-07 09:13:21 +0000732AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
733 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
petarj4df0bfc2013-02-27 23:17:33 +0000734AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
735 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000736AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
737 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
738 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
739AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
740 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
741
742
sewardj72a2d802010-07-29 05:24:20 +0000743# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000744# Relies on the assumption that the primary and secondary targets are
745# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000746AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
747 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
748 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
749 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
carllcae0cc22014-08-07 23:17:29 +0000750 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
751 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000752 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
sewardjf0c12502014-01-12 12:54:00 +0000753 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardj5db15402012-06-07 09:13:21 +0000754 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +0000755 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
756 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000757AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
758 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
759 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000760
761
njn7fd6d382009-01-22 21:56:32 +0000762# Sometimes, in the Makefile.am files, it's useful to know whether or not
763# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000764AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000765 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000766
philippef32cbe82012-05-18 16:48:20 +0000767dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
768dnl fallback definition
769dnl The macro is courtesy of Dave Hart:
770dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
771m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
772if test -z "$$1_TRUE"; then :
773 m4_n([$2])[]dnl
774m4_ifval([$3],
775[else
776 $3
777])dnl
778fi[]dnl
779])])
tomb637bad2005-11-08 12:28:35 +0000780
njn7fd6d382009-01-22 21:56:32 +0000781#----------------------------------------------------------------------------
782# Inner Valgrind?
783#----------------------------------------------------------------------------
784
njnd74b0ef2009-01-20 06:06:52 +0000785# Check if this should be built as an inner Valgrind, to be run within
786# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000787AC_SUBST(VALT_LOAD_ADDRESS_PRI)
788AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000789AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
790 [AC_ARG_ENABLE(inner,
791 [ --enable-inner enables self-hosting],
792 [vg_cv_inner=$enableval],
793 [vg_cv_inner=no])])
794if test "$vg_cv_inner" = yes; then
795 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000796 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
797 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000798else
njnea2d6fd2010-07-01 00:20:20 +0000799 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
800 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000801fi
802
803
njn7fd6d382009-01-22 21:56:32 +0000804#----------------------------------------------------------------------------
sewardj5db15402012-06-07 09:13:21 +0000805# Define MIPS_PAGE_SHIFT (--with-pagesize)
806#----------------------------------------------------------------------------
807AC_ARG_WITH(pagesize,
808 [ --with-pagesize= override detected page size (4, 16 or 64)],
809 [psize=$withval],
810 [psize=0]
811)
812
813if test "$psize" = "0"; then
814 psizer=`getconf PAGESIZE`
florian62477d22014-02-22 13:24:15 +0000815 psize=$((${psizer}/1024))
sewardj5db15402012-06-07 09:13:21 +0000816fi
817
818if test "$psize" = "4"; then
819 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
820elif test "$psize" = "16"; then
821 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
822elif test "$psize" = "64"; then
823 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
824else
825 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
826fi
827AC_MSG_RESULT([checking for Pagesize... ${psize}k])
828
sewardj5db15402012-06-07 09:13:21 +0000829
830#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000831# Extra fine-tuning of installation directories
832#----------------------------------------------------------------------------
833AC_ARG_WITH(tmpdir,
834 [ --with-tmpdir=PATH Specify path for temporary files],
835 tmpdir="$withval",
836 tmpdir="/tmp")
837AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
florian7fd2ec32014-06-21 20:25:30 +0000838AC_SUBST(VG_TMPDIR, [$tmpdir])
sewardjcb495c82011-07-11 20:42:34 +0000839
sewardj0ba37c92011-07-12 11:46:24 +0000840
sewardjcb495c82011-07-11 20:42:34 +0000841#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000842# Libc and suppressions
843#----------------------------------------------------------------------------
844# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000845AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000846
bart12e91122010-05-15 08:37:24 +0000847AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000848
bart12e91122010-05-15 08:37:24 +0000849if test x$ac_cv_header_features_h = xyes; then
850 rm -f conftest.$ac_ext
851 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000852#include <features.h>
bart12e91122010-05-15 08:37:24 +0000853#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
854glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000855#endif
bart12e91122010-05-15 08:37:24 +0000856_ACEOF
mjwa384c3f2014-09-10 00:52:30 +0000857 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
bart12e91122010-05-15 08:37:24 +0000858fi
bartb7c3f082010-05-13 06:32:36 +0000859
njnf76d27a2009-05-28 01:53:07 +0000860# not really a version check
861AC_EGREP_CPP([DARWIN_LIBC], [
862#include <sys/cdefs.h>
863#if defined(__DARWIN_VERS_1050)
864 DARWIN_LIBC
865#endif
866],
867GLIBC_VERSION="darwin")
868
sewardjcb495c82011-07-11 20:42:34 +0000869# not really a version check
870AC_EGREP_CPP([BIONIC_LIBC], [
871#if defined(__ANDROID__)
872 BIONIC_LIBC
873#endif
874],
875GLIBC_VERSION="bionic")
876
877
bart8219bff2014-09-13 10:53:00 +0000878AC_MSG_CHECKING([the glibc version])
sewardj03d86f22006-10-17 00:57:24 +0000879
dirk07596a22008-04-25 11:33:30 +0000880case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000881 2.2)
bart8219bff2014-09-13 10:53:00 +0000882 AC_MSG_RESULT(${GLIBC_VERSION} family)
sewardj2c4f3dd2007-11-11 06:13:01 +0000883 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
884 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000885 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000886 ;;
bart8219bff2014-09-13 10:53:00 +0000887 2.[[3-6]])
888 AC_MSG_RESULT(${GLIBC_VERSION} family)
889 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000890 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000891 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000892 ;;
bart8219bff2014-09-13 10:53:00 +0000893 2.[[7-9]])
894 AC_MSG_RESULT(${GLIBC_VERSION} family)
dirk07596a22008-04-25 11:33:30 +0000895 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000896 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000897 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000898 ;;
bart8219bff2014-09-13 10:53:00 +0000899 2.10|2.11)
900 AC_MSG_RESULT(${GLIBC_VERSION} family)
901 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
902 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
dirk07596a22008-04-25 11:33:30 +0000903 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
904 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
905 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
906 ;;
bart8219bff2014-09-13 10:53:00 +0000907 2.*)
908 AC_MSG_RESULT(${GLIBC_VERSION} family)
909 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
910 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
911 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
912 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
mjwedd30332014-09-08 23:41:31 +0000913 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
914 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
915 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
916 ;;
njnf76d27a2009-05-28 01:53:07 +0000917 darwin)
918 AC_MSG_RESULT(Darwin)
919 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
920 # DEFAULT_SUPP set by kernel version check above.
921 ;;
sewardjcb495c82011-07-11 20:42:34 +0000922 bionic)
923 AC_MSG_RESULT(Bionic)
924 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
925 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
926 ;;
bart8219bff2014-09-13 10:53:00 +0000927 2.0|2.1|*)
bart12e91122010-05-15 08:37:24 +0000928 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
bart8219bff2014-09-13 10:53:00 +0000929 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later])
mjw28ae1992014-02-21 21:13:55 +0000930 AC_MSG_ERROR([or Darwin or Bionic libc])
sewardjde4a1d02002-03-22 01:27:54 +0000931 ;;
932esac
933
dirk07596a22008-04-25 11:33:30 +0000934AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000935
sewardj414f3582008-07-18 20:46:00 +0000936
937# Add default suppressions for the X client libraries. Make no
938# attempt to detect whether such libraries are installed on the
939# build machine (or even if any X facilities are present); just
940# add the suppressions antidisirregardless.
941DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
942DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000943
sewardjd2f95a02011-05-11 16:04:28 +0000944# Add glibc and X11 suppressions for exp-sgcheck
945DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000946
sewardj2e10a682003-04-07 19:36:41 +0000947
njn7fd6d382009-01-22 21:56:32 +0000948#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000949# Platform variants?
950#----------------------------------------------------------------------------
951
952# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
953# But there are times where we need a bit more control. The motivating
philippe5d5dd8e2012-08-05 00:08:25 +0000954# and currently only case is Android: this is almost identical to
dejanj9c6b05d2013-12-27 09:06:55 +0000955# {x86,arm,mips}-linux, but not quite. So this introduces the concept of
956# platform variant tags, which get passed in the compile as
957# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
sewardjcb495c82011-07-11 20:42:34 +0000958#
959# In almost all cases, the <variant> bit is "vanilla". But for Android
960# it is "android" instead.
961#
962# Consequently (eg), plain arm-linux would build with
963#
964# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
965#
966# whilst an Android build would have
967#
968# -DVGP_arm_linux -DVGPV_arm_linux_android
969#
philippe5d5dd8e2012-08-05 00:08:25 +0000970# Same for x86. The setup of the platform variant is pushed relatively far
971# down this file in order that we can inspect any of the variables set above.
sewardjcb495c82011-07-11 20:42:34 +0000972
973# In the normal case ..
974VGCONF_PLATVARIANT="vanilla"
975
philippe5d5dd8e2012-08-05 00:08:25 +0000976# Android ?
977if test "$GLIBC_VERSION" = "bionic";
sewardjcb495c82011-07-11 20:42:34 +0000978then
979 VGCONF_PLATVARIANT="android"
980fi
981
982AC_SUBST(VGCONF_PLATVARIANT)
983
984
985# FIXME: do we also want to define automake variables
986# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
987# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
988# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
989# do that. Problem is that we can't do and-ing in Makefile.am's, but
990# that's what we'd need to do to use this, since what we'd want to write
991# is something like
992#
993# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
994#
sewardj0ba37c92011-07-12 11:46:24 +0000995# Hmm. Can't think of a nice clean solution to this.
996
997AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
998 test x$VGCONF_PLATVARIANT = xvanilla)
999AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1000 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +00001001
1002
1003#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +00001004# Checking for various library functions and other definitions
1005#----------------------------------------------------------------------------
1006
florian28db75c2012-12-08 19:26:03 +00001007# Check for AT_FDCWD
1008
1009AC_MSG_CHECKING([for AT_FDCWD])
1010AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1011#define _GNU_SOURCE
1012#include <fcntl.h>
1013#include <unistd.h>
1014]], [[
1015 int a = AT_FDCWD;
1016]])], [
1017ac_have_at_fdcwd=yes
1018AC_MSG_RESULT([yes])
1019], [
1020ac_have_at_fdcwd=no
florian28db75c2012-12-08 19:26:03 +00001021AC_MSG_RESULT([no])
1022])
1023
1024AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1025
sewardj24cf8df2012-12-14 10:30:57 +00001026# Check for stpncpy function definition in string.h
1027# This explicitly checks with _GNU_SOURCE defined since that is also
1028# used in the test case (some systems might define it without anyway
1029# since stpncpy is part of The Open Group Base Specifications Issue 7
1030# IEEE Std 1003.1-2008.
1031AC_MSG_CHECKING([for stpncpy])
1032AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1033#define _GNU_SOURCE
1034#include <string.h>
1035]], [[
1036 char *d;
1037 char *s;
1038 size_t n = 0;
1039 char *r = stpncpy(d, s, n);
1040]])], [
1041ac_have_gnu_stpncpy=yes
1042AC_MSG_RESULT([yes])
1043], [
1044ac_have_gnu_stpncpy=no
1045AC_MSG_RESULT([no])
1046])
1047
1048AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
florian28db75c2012-12-08 19:26:03 +00001049
philippe4e98f7c2013-08-03 20:34:58 +00001050# Check for PTRACE_GETREGS
1051
1052AC_MSG_CHECKING([for PTRACE_GETREGS])
1053AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1054#include <stddef.h>
1055#include <sys/ptrace.h>
1056#include <sys/user.h>
1057]], [[
1058 void *p;
1059 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1060]])], [
1061AC_MSG_RESULT([yes])
1062AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1063 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1064], [
1065AC_MSG_RESULT([no])
1066])
1067
1068
bart59e2f182008-04-28 16:22:53 +00001069# Check for CLOCK_MONOTONIC
1070
1071AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1072
bart417cf3e2011-10-22 09:21:24 +00001073AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +00001074#include <time.h>
bart417cf3e2011-10-22 09:21:24 +00001075]], [[
bart59e2f182008-04-28 16:22:53 +00001076 struct timespec t;
1077 clock_gettime(CLOCK_MONOTONIC, &t);
1078 return 0;
bart417cf3e2011-10-22 09:21:24 +00001079]])], [
bart59e2f182008-04-28 16:22:53 +00001080AC_MSG_RESULT([yes])
1081AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1082 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1083], [
1084AC_MSG_RESULT([no])
1085])
1086
bartfea06922008-05-03 09:12:15 +00001087
sewardj0c09bf02011-07-11 22:11:58 +00001088# Check for PTHREAD_RWLOCK_T
1089
1090AC_MSG_CHECKING([for pthread_rwlock_t])
1091
bart417cf3e2011-10-22 09:21:24 +00001092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +00001093#define _GNU_SOURCE
1094#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001095]], [[
sewardj0c09bf02011-07-11 22:11:58 +00001096 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +00001097]])], [
sewardj0c09bf02011-07-11 22:11:58 +00001098AC_MSG_RESULT([yes])
1099AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1100 [Define to 1 if you have the `pthread_rwlock_t' type.])
1101], [
1102AC_MSG_RESULT([no])
1103])
1104
1105
bartfea06922008-05-03 09:12:15 +00001106# Check for PTHREAD_MUTEX_ADAPTIVE_NP
1107
1108AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1109
bart417cf3e2011-10-22 09:21:24 +00001110AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001111#define _GNU_SOURCE
1112#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001113]], [[
bartfea06922008-05-03 09:12:15 +00001114 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001115]])], [
bartfea06922008-05-03 09:12:15 +00001116AC_MSG_RESULT([yes])
1117AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1118 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1119], [
1120AC_MSG_RESULT([no])
1121])
1122
1123
1124# Check for PTHREAD_MUTEX_ERRORCHECK_NP
1125
1126AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1127
bart417cf3e2011-10-22 09:21:24 +00001128AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001129#define _GNU_SOURCE
1130#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001131]], [[
bartfea06922008-05-03 09:12:15 +00001132 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +00001133]])], [
bartfea06922008-05-03 09:12:15 +00001134AC_MSG_RESULT([yes])
1135AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1136 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1137], [
1138AC_MSG_RESULT([no])
1139])
1140
1141
1142# Check for PTHREAD_MUTEX_RECURSIVE_NP
1143
1144AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1145
bart417cf3e2011-10-22 09:21:24 +00001146AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001147#define _GNU_SOURCE
1148#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001149]], [[
bartfea06922008-05-03 09:12:15 +00001150 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001151]])], [
bartfea06922008-05-03 09:12:15 +00001152AC_MSG_RESULT([yes])
1153AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1154 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1155], [
1156AC_MSG_RESULT([no])
1157])
1158
1159
1160# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1161
1162AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1163
bart417cf3e2011-10-22 09:21:24 +00001164AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001165#define _GNU_SOURCE
1166#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001167]], [[
bartfea06922008-05-03 09:12:15 +00001168 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1169 return 0;
bart417cf3e2011-10-22 09:21:24 +00001170]])], [
bartfea06922008-05-03 09:12:15 +00001171AC_MSG_RESULT([yes])
1172AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1173 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1174], [
1175AC_MSG_RESULT([no])
1176])
1177
1178
bart5e389f12008-04-05 12:53:15 +00001179# Check whether pthread_mutex_t has a member called __m_kind.
1180
bartb11355c2010-04-29 16:37:26 +00001181AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1182 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1183 1,
1184 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1185 ],
1186 [],
1187 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001188
1189
1190# Check whether pthread_mutex_t has a member called __data.__kind.
1191
bartb11355c2010-04-29 16:37:26 +00001192AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1193 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1194 1,
1195 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1196 ],
1197 [],
1198 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001199
1200
bart62c370e2008-05-12 18:50:51 +00001201# does this compiler support -maltivec and does it have the include file
1202# <altivec.h> ?
1203
1204AC_MSG_CHECKING([for Altivec])
1205
1206safe_CFLAGS=$CFLAGS
1207CFLAGS="-maltivec"
1208
bart417cf3e2011-10-22 09:21:24 +00001209AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001210#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001211]], [[
bart62c370e2008-05-12 18:50:51 +00001212 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001213]])], [
bart62c370e2008-05-12 18:50:51 +00001214ac_have_altivec=yes
1215AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001216AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001217 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001218], [
1219ac_have_altivec=no
1220AC_MSG_RESULT([no])
1221])
1222CFLAGS=$safe_CFLAGS
1223
sewardj0e342a02010-09-03 23:49:33 +00001224AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001225
1226
sewardjf34eb492011-04-15 11:57:05 +00001227# Check that both: the compiler supports -mvsx and that the assembler
1228# understands VSX instructions. If either of those doesn't work,
1229# conclude that we can't do VSX. NOTE: basically this is a kludge
1230# in that it conflates two things that should be separate -- whether
1231# the compiler understands the flag vs whether the assembler
1232# understands the opcodes. This really ought to be cleaned up
1233# and done properly, like it is for x86/x86_64.
1234
1235AC_MSG_CHECKING([for VSX])
1236
1237safe_CFLAGS=$CFLAGS
1238CFLAGS="-mvsx"
1239
bart417cf3e2011-10-22 09:21:24 +00001240AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001241#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001242]], [[
sewardjf34eb492011-04-15 11:57:05 +00001243 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001244 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001245]])], [
sewardjf34eb492011-04-15 11:57:05 +00001246ac_have_vsx=yes
1247AC_MSG_RESULT([yes])
1248], [
1249ac_have_vsx=no
1250AC_MSG_RESULT([no])
1251])
1252CFLAGS=$safe_CFLAGS
1253
1254AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1255
sewardj4e1c1912012-08-08 22:22:26 +00001256
sewardjb0ccb4d2012-04-02 10:22:05 +00001257AC_MSG_CHECKING([that assembler knows DFP])
1258
1259AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1260]], [[
1261 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001262 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001263]])], [
1264ac_asm_have_dfp=yes
1265AC_MSG_RESULT([yes])
1266], [
1267ac_asm_have_dfp=no
1268AC_MSG_RESULT([no])
1269])
1270
sewardj4e1c1912012-08-08 22:22:26 +00001271
sewardjb0ccb4d2012-04-02 10:22:05 +00001272AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1273safe_CFLAGS=$CFLAGS
1274CFLAGS="-mhard-dfp"
1275AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1276]], [[
1277 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001278 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001279]])], [
1280ac_gcc_have_dfp=yes
1281AC_MSG_RESULT([yes])
1282], [
1283ac_gcc_have_dfp=no
1284AC_MSG_RESULT([no])
1285])
1286
sewardjb0ccb4d2012-04-02 10:22:05 +00001287CFLAGS=$safe_CFLAGS
1288
1289AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001290
sewardj4e1c1912012-08-08 22:22:26 +00001291
florian46825982012-11-10 22:35:24 +00001292AC_MSG_CHECKING([that compiler knows DFP datatypes])
1293AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1294]], [[
1295 _Decimal64 x = 0.0DD;
1296]])], [
1297ac_gcc_have_dfp_type=yes
1298AC_MSG_RESULT([yes])
1299], [
1300ac_gcc_have_dfp_type=no
1301AC_MSG_RESULT([no])
1302])
1303
1304AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1305
carlldfbf2942013-08-12 18:04:22 +00001306# isa 2.07 checking
1307AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1308
1309AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1310]], [[
1311 __asm__ __volatile__("mtvsrd 1,2 ");
1312]])], [
1313ac_asm_have_isa_2_07=yes
1314AC_MSG_RESULT([yes])
1315], [
1316ac_asm_have_isa_2_07=no
1317AC_MSG_RESULT([no])
1318])
1319
1320AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
florian46825982012-11-10 22:35:24 +00001321
bart36dd85a2009-04-26 07:11:48 +00001322# Check for pthread_create@GLIBC2.0
1323AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1324
bart16e1c5a2009-04-26 07:38:53 +00001325safe_CFLAGS=$CFLAGS
1326CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001327AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001328extern int pthread_create_glibc_2_0(void*, const void*,
1329 void *(*)(void*), void*);
1330__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001331]], [[
bart276ed3a2009-05-10 15:41:45 +00001332#ifdef __powerpc__
1333/*
1334 * Apparently on PowerPC linking this program succeeds and generates an
1335 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1336 */
1337#error This test does not work properly on PowerPC.
1338#else
bart16e1c5a2009-04-26 07:38:53 +00001339 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001340#endif
bart16e1c5a2009-04-26 07:38:53 +00001341 return 0;
bart417cf3e2011-10-22 09:21:24 +00001342]])], [
bart36dd85a2009-04-26 07:11:48 +00001343ac_have_pthread_create_glibc_2_0=yes
1344AC_MSG_RESULT([yes])
1345AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1346 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1347], [
1348ac_have_pthread_create_glibc_2_0=no
1349AC_MSG_RESULT([no])
1350])
bart16e1c5a2009-04-26 07:38:53 +00001351CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001352
1353AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001354 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001355
1356
philippe1670b052014-08-15 10:27:52 +00001357# Check for dlinfo RTLD_DI_TLS_MODID
1358AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1359
1360safe_LIBS="$LIBS"
1361LIBS="-ldl"
1362AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1363#ifndef _GNU_SOURCE
1364#define _GNU_SOURCE
1365#endif
1366#include <link.h>
1367#include <dlfcn.h>
1368]], [[
1369 size_t sizes[10000];
1370 size_t modid_offset;
1371 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1372 return 0;
1373]])], [
1374ac_have_dlinfo_rtld_di_tls_modid=yes
1375AC_MSG_RESULT([yes])
1376AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1377 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1378], [
1379ac_have_dlinfo_rtld_di_tls_modid=no
1380AC_MSG_RESULT([no])
1381])
1382LIBS=$safe_LIBS
1383
1384AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1385 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1386
1387
barta50aa8a2008-04-27 06:06:57 +00001388# Check for eventfd_t, eventfd() and eventfd_read()
1389AC_MSG_CHECKING([for eventfd()])
1390
bart417cf3e2011-10-22 09:21:24 +00001391AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001392#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001393]], [[
barta50aa8a2008-04-27 06:06:57 +00001394 eventfd_t ev;
1395 int fd;
1396
1397 fd = eventfd(5, 0);
1398 eventfd_read(fd, &ev);
1399 return 0;
bart417cf3e2011-10-22 09:21:24 +00001400]])], [
barta50aa8a2008-04-27 06:06:57 +00001401AC_MSG_RESULT([yes])
1402AC_DEFINE([HAVE_EVENTFD], 1,
1403 [Define to 1 if you have the `eventfd' function.])
1404AC_DEFINE([HAVE_EVENTFD_READ], 1,
1405 [Define to 1 if you have the `eventfd_read' function.])
1406], [
1407AC_MSG_RESULT([no])
1408])
1409
1410
florian24fefb62013-10-08 13:04:00 +00001411# Check whether compiler can process #include <thread> without errors
1412# clang 3.3 cannot process <thread> from e.g.
1413# gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1414
1415AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1416AC_LANG(C++)
1417safe_CXXFLAGS=$CXXFLAGS
1418CXXFLAGS=-std=c++0x
1419
1420AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1421#include <thread>
1422])],
1423[
1424ac_cxx_can_include_thread_header=yes
1425AC_MSG_RESULT([yes])
1426], [
1427ac_cxx_can_include_thread_header=no
1428AC_MSG_RESULT([no])
1429])
1430CXXFLAGS=$safe_CXXFLAGS
1431AC_LANG(C)
1432
1433AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1434
mjw2a429f52014-07-18 20:45:37 +00001435
1436# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1437# of the user_regs_struct from sys/user.h. They are structurally the same
1438# but we get either one or the other.
1439
1440AC_CHECK_TYPE([struct user_regs_struct],
1441 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1442 [[#include <sys/ptrace.h>]
1443 [#include <sys/time.h>]
1444 [#include <sys/user.h>]])
1445if test "$sys_user_has_user_regs" = "yes"; then
1446 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1447 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1448fi
1449
1450
njn7fd6d382009-01-22 21:56:32 +00001451#----------------------------------------------------------------------------
1452# Checking for supported compiler flags.
1453#----------------------------------------------------------------------------
1454
sewardj535c50f2005-06-04 23:14:53 +00001455# does this compiler support -m32 ?
1456AC_MSG_CHECKING([if gcc accepts -m32])
1457
1458safe_CFLAGS=$CFLAGS
1459CFLAGS="-m32"
1460
bart417cf3e2011-10-22 09:21:24 +00001461AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001462 return 0;
bart417cf3e2011-10-22 09:21:24 +00001463]])], [
sewardj535c50f2005-06-04 23:14:53 +00001464FLAG_M32="-m32"
1465AC_MSG_RESULT([yes])
1466], [
1467FLAG_M32=""
1468AC_MSG_RESULT([no])
1469])
1470CFLAGS=$safe_CFLAGS
1471
1472AC_SUBST(FLAG_M32)
1473
1474
sewardj01262142006-01-04 01:20:28 +00001475# does this compiler support -m64 ?
1476AC_MSG_CHECKING([if gcc accepts -m64])
1477
1478safe_CFLAGS=$CFLAGS
1479CFLAGS="-m64"
1480
bart417cf3e2011-10-22 09:21:24 +00001481AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001482 return 0;
bart417cf3e2011-10-22 09:21:24 +00001483]])], [
sewardj01262142006-01-04 01:20:28 +00001484FLAG_M64="-m64"
1485AC_MSG_RESULT([yes])
1486], [
1487FLAG_M64=""
1488AC_MSG_RESULT([no])
1489])
1490CFLAGS=$safe_CFLAGS
1491
1492AC_SUBST(FLAG_M64)
1493
1494
dejanjf674e382014-02-18 16:40:25 +00001495# does this compiler support -march=mips32 (mips32 default) ?
1496AC_MSG_CHECKING([if gcc accepts -march=mips32])
1497
1498safe_CFLAGS=$CFLAGS
1499CFLAGS="$CFLAGS -march=mips32"
1500
1501AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1502 return 0;
1503]])], [
1504FLAG_MIPS32="-march=mips32"
1505AC_MSG_RESULT([yes])
1506], [
1507FLAG_MIPS32=""
1508AC_MSG_RESULT([no])
1509])
1510CFLAGS=$safe_CFLAGS
1511
1512AC_SUBST(FLAG_MIPS32)
1513
1514
1515# does this compiler support -march=mips64 (mips64 default) ?
1516AC_MSG_CHECKING([if gcc accepts -march=mips64])
1517
1518safe_CFLAGS=$CFLAGS
1519CFLAGS="$CFLAGS -march=mips64"
1520
1521AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1522 return 0;
1523]])], [
1524FLAG_MIPS64="-march=mips64"
1525AC_MSG_RESULT([yes])
1526], [
1527FLAG_MIPS64=""
1528AC_MSG_RESULT([no])
1529])
1530CFLAGS=$safe_CFLAGS
1531
1532AC_SUBST(FLAG_MIPS64)
1533
1534
petarj1546c7a2014-01-29 18:08:50 +00001535# does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1536AC_MSG_CHECKING([if gcc accepts -march=octeon])
1537
1538safe_CFLAGS=$CFLAGS
1539CFLAGS="$CFLAGS -march=octeon"
1540
1541AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1542 return 0;
1543]])], [
1544FLAG_OCTEON="-march=octeon"
1545AC_MSG_RESULT([yes])
1546], [
1547FLAG_OCTEON=""
1548AC_MSG_RESULT([no])
1549])
1550CFLAGS=$safe_CFLAGS
1551
1552AC_SUBST(FLAG_OCTEON)
1553
dejanjf674e382014-02-18 16:40:25 +00001554
petarj1546c7a2014-01-29 18:08:50 +00001555# does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1556AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1557
1558safe_CFLAGS=$CFLAGS
1559CFLAGS="$CFLAGS -march=octeon2"
1560
1561AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1562 return 0;
1563]])], [
1564FLAG_OCTEON2="-march=octeon2"
1565AC_MSG_RESULT([yes])
1566], [
1567FLAG_OCTEON2=""
1568AC_MSG_RESULT([no])
1569])
1570CFLAGS=$safe_CFLAGS
1571
1572AC_SUBST(FLAG_OCTEON2)
1573
1574
sewardj67f1fcc2005-07-03 10:41:02 +00001575# does this compiler support -mmmx ?
1576AC_MSG_CHECKING([if gcc accepts -mmmx])
1577
1578safe_CFLAGS=$CFLAGS
1579CFLAGS="-mmmx"
1580
bart417cf3e2011-10-22 09:21:24 +00001581AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001582 return 0;
bart417cf3e2011-10-22 09:21:24 +00001583]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001584FLAG_MMMX="-mmmx"
1585AC_MSG_RESULT([yes])
1586], [
1587FLAG_MMMX=""
1588AC_MSG_RESULT([no])
1589])
1590CFLAGS=$safe_CFLAGS
1591
1592AC_SUBST(FLAG_MMMX)
1593
1594
1595# does this compiler support -msse ?
1596AC_MSG_CHECKING([if gcc accepts -msse])
1597
1598safe_CFLAGS=$CFLAGS
1599CFLAGS="-msse"
1600
bart417cf3e2011-10-22 09:21:24 +00001601AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001602 return 0;
bart417cf3e2011-10-22 09:21:24 +00001603]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001604FLAG_MSSE="-msse"
1605AC_MSG_RESULT([yes])
1606], [
1607FLAG_MSSE=""
1608AC_MSG_RESULT([no])
1609])
1610CFLAGS=$safe_CFLAGS
1611
1612AC_SUBST(FLAG_MSSE)
1613
1614
sewardj98977e02014-09-05 20:00:22 +00001615# does this compiler support -mpreferred-stack-boundary=2 when
1616# generating code for a 32-bit target? Note that we only care about
1617# this when generating code for (32-bit) x86, so if the compiler
1618# doesn't recognise -m32 it's no big deal. We'll just get code for
1619# the Memcheck and other helper functions, that is a bit slower than
1620# it could be, on x86; and no difference at all on any other platform.
1621AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
sewardj5b754b42002-06-03 22:53:35 +00001622
daywalker3664f562003-10-17 13:43:46 +00001623safe_CFLAGS=$CFLAGS
sewardj98977e02014-09-05 20:00:22 +00001624CFLAGS="-mpreferred-stack-boundary=2 -m32"
sewardj5b754b42002-06-03 22:53:35 +00001625
bart417cf3e2011-10-22 09:21:24 +00001626AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001627 return 0;
bart417cf3e2011-10-22 09:21:24 +00001628]])], [
sewardj98977e02014-09-05 20:00:22 +00001629PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001630AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001631], [
sewardj98977e02014-09-05 20:00:22 +00001632PREFERRED_STACK_BOUNDARY_2=""
sewardj5b754b42002-06-03 22:53:35 +00001633AC_MSG_RESULT([no])
1634])
daywalker3664f562003-10-17 13:43:46 +00001635CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001636
sewardj98977e02014-09-05 20:00:22 +00001637AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
sewardj5b754b42002-06-03 22:53:35 +00001638
sewardj535c50f2005-06-04 23:14:53 +00001639
mjwab69b4a2014-08-20 16:11:53 +00001640# Convenience function to check whether GCC supports a particular
1641# warning option. Takes two arguments, first the warning flag name
1642# to check (without -W), then the conditional name to set if that
1643# warning flag is supported.
1644AC_DEFUN([AC_GCC_WARNING_COND],[
sewardja3a27fe2014-09-01 21:16:02 +00001645 AC_MSG_CHECKING([if gcc accepts -W$1])
1646 safe_CFLAGS=$CFLAGS
1647 CFLAGS="-W$1"
1648 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1649 has_warning_flag=yes
1650 AC_MSG_RESULT([yes])], [
1651 has_warning_flag=no
1652 AC_MSG_RESULT([no])])
1653 CFLAGS=$safe_CFLAGS
1654 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes)
1655])
florianda8c1262012-11-18 14:39:11 +00001656
mjwab69b4a2014-08-20 16:11:53 +00001657AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING])
1658AC_GCC_WARNING_COND([write-strings], [HAS_WRITE_STRINGS_WARNING])
florian0f90fe12014-09-18 19:39:10 +00001659if test $has_warning_flag = yes; then
1660 CFLAGS="$CFLAGS -Wwrite-strings"
1661 CXXFLAGS="$CXXFLAGS -Wwrite-strings"
1662fi
florianda8c1262012-11-18 14:39:11 +00001663
mjwab69b4a2014-08-20 16:11:53 +00001664# Convenience function to check whether GCC supports a particular
1665# warning option. Similar to AC_GCC_WARNING_COND, but does a
1666# substitution instead of setting an conditional. Takes two arguments,
1667# first the warning flag name to check (without -W), then the
1668# substitution name to set with -Wno-warning-flag if the flag exists,
1669# or the empty string if the compiler doesn't accept the flag. Note
1670# that checking is done against the warning flag itself, but the
1671# substitution is then done to cancel the warning flag.
1672AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
sewardja3a27fe2014-09-01 21:16:02 +00001673 AC_MSG_CHECKING([if gcc accepts -W$1])
1674 safe_CFLAGS=$CFLAGS
1675 CFLAGS="-W$1"
1676 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1677 AC_SUBST([$2], [-Wno-$1])
1678 AC_MSG_RESULT([yes])], [
1679 AC_SUBST([$2], [])
1680 AC_MSG_RESULT([no])])
1681 CFLAGS=$safe_CFLAGS
barte026bd22009-07-04 12:17:07 +00001682])
barte026bd22009-07-04 12:17:07 +00001683
mjwab69b4a2014-08-20 16:11:53 +00001684AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY])
1685AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH])
1686AC_GCC_WARNING_SUBST_NO([tautological-compare], [FLAG_W_NO_TAUTOLOGICAL_COMPARE])
1687AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1688AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1689AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
florian807c4542014-09-05 18:30:05 +00001690AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1691AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
bartbf9b85c2009-08-12 12:55:56 +00001692
sewardja3a27fe2014-09-01 21:16:02 +00001693
bart56730cd2008-05-11 06:41:46 +00001694# does this compiler support -Wextra or the older -W ?
1695
1696AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1697
1698safe_CFLAGS=$CFLAGS
1699CFLAGS="-Wextra"
1700
bart417cf3e2011-10-22 09:21:24 +00001701AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001702 return 0;
bart417cf3e2011-10-22 09:21:24 +00001703]])], [
bart56730cd2008-05-11 06:41:46 +00001704AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1705AC_MSG_RESULT([-Wextra])
1706], [
1707 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001708 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001709 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001710 ]])], [
bart56730cd2008-05-11 06:41:46 +00001711 AC_SUBST([FLAG_W_EXTRA], [-W])
1712 AC_MSG_RESULT([-W])
1713 ], [
1714 AC_SUBST([FLAG_W_EXTRA], [])
1715 AC_MSG_RESULT([not supported])
1716 ])
1717])
1718CFLAGS=$safe_CFLAGS
1719
1720
sewardja72c26d2007-05-01 13:44:08 +00001721# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001722AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001723
1724safe_CFLAGS=$CFLAGS
1725CFLAGS="-fno-stack-protector"
1726
bart417cf3e2011-10-22 09:21:24 +00001727AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001728 return 0;
bart417cf3e2011-10-22 09:21:24 +00001729]])], [
sewardja72c26d2007-05-01 13:44:08 +00001730no_stack_protector=yes
1731FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1732AC_MSG_RESULT([yes])
1733], [
1734no_stack_protector=no
1735FLAG_FNO_STACK_PROTECTOR=""
1736AC_MSG_RESULT([no])
1737])
1738CFLAGS=$safe_CFLAGS
1739
1740AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1741
1742if test x$no_stack_protector = xyes; then
1743 CFLAGS="$CFLAGS -fno-stack-protector"
floriand79b3bf2013-10-02 15:14:59 +00001744 CXXFLAGS="$CXXFLAGS -fno-stack-protector"
sewardja72c26d2007-05-01 13:44:08 +00001745fi
1746
1747
bart56730cd2008-05-11 06:41:46 +00001748# does this compiler support --param inline-unit-growth=... ?
1749
1750AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1751
1752safe_CFLAGS=$CFLAGS
1753CFLAGS="--param inline-unit-growth=900"
1754
bart417cf3e2011-10-22 09:21:24 +00001755AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001756 return 0;
bart417cf3e2011-10-22 09:21:24 +00001757]])], [
bart56730cd2008-05-11 06:41:46 +00001758AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1759 ["--param inline-unit-growth=900"])
1760AC_MSG_RESULT([yes])
1761], [
1762AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1763AC_MSG_RESULT([no])
1764])
1765CFLAGS=$safe_CFLAGS
1766
1767
sewardjd9350682012-04-05 07:55:47 +00001768# does this compiler support -gdwarf-4 -fdebug-types-section ?
1769
1770AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1771
1772safe_CFLAGS=$CFLAGS
1773CFLAGS="-gdwarf-4 -fdebug-types-section"
1774
1775AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1776 return 0;
1777]])], [
1778ac_have_dwarf4=yes
1779AC_MSG_RESULT([yes])
1780], [
1781ac_have_dwarf4=no
1782AC_MSG_RESULT([no])
1783])
1784AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1785CFLAGS=$safe_CFLAGS
1786
1787
florian3df02112013-10-04 11:35:50 +00001788# does this compiler support nested functions ?
1789
1790AC_MSG_CHECKING([if gcc accepts nested functions])
1791
1792AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1793 int foo() { return 1; }
1794 return foo();
1795]])], [
1796ac_have_nested_functions=yes
1797AC_MSG_RESULT([yes])
1798], [
1799ac_have_nested_functions=no
1800AC_MSG_RESULT([no])
1801])
1802AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1803
1804
1805# does this compiler support the 'p' constraint in ASM statements ?
1806
1807AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1808
1809AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1810 char *p;
1811 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1812]])], [
1813ac_have_asm_constraint_p=yes
1814AC_MSG_RESULT([yes])
1815], [
1816ac_have_asm_constraint_p=no
1817AC_MSG_RESULT([no])
1818])
1819AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1820
1821
sewardje4bc7032013-03-22 11:49:46 +00001822# We want to use use the -Ttext-segment option to the linker.
1823# GNU (bfd) ld supports this directly. Newer GNU gold linkers
1824# support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1825# semantics are NOT what we want (GNU gold -Ttext is fine).
1826#
1827# For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1828# will reside. -Ttext aligns just the .text section start (but not any
1829# other section).
1830#
1831# So test for -Ttext-segment which is supported by all bfd ld versions
1832# and use that if it exists. If it doesn't exist it must be an older
1833# version of gold and we can fall back to using -Ttext which has the
1834# right semantics.
bart699fbac2010-06-08 18:23:59 +00001835
sewardje4bc7032013-03-22 11:49:46 +00001836AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
bart699fbac2010-06-08 18:23:59 +00001837
1838safe_CFLAGS=$CFLAGS
mjw941277a2013-04-17 19:11:05 +00001839CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
bart699fbac2010-06-08 18:23:59 +00001840
bart8508c752010-06-10 06:26:21 +00001841AC_LINK_IFELSE(
mjw941277a2013-04-17 19:11:05 +00001842[AC_LANG_SOURCE([int _start () { return 0; }])],
bart699fbac2010-06-08 18:23:59 +00001843[
tom04ce9f52013-03-28 15:53:21 +00001844 linker_using_t_text="no"
sewardje4bc7032013-03-22 11:49:46 +00001845 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
bart699fbac2010-06-08 18:23:59 +00001846 AC_MSG_RESULT([yes])
1847], [
tom04ce9f52013-03-28 15:53:21 +00001848 linker_using_t_text="yes"
sewardje4bc7032013-03-22 11:49:46 +00001849 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
bart699fbac2010-06-08 18:23:59 +00001850 AC_MSG_RESULT([no])
1851])
1852CFLAGS=$safe_CFLAGS
1853
tom04ce9f52013-03-28 15:53:21 +00001854# If the linker only supports -Ttext (not -Ttext-segment) then we will
1855# have to strip any build-id ELF NOTEs from the staticly linked tools.
1856# Otherwise the build-id NOTE might end up at the default load address.
1857# (Pedantically if the linker is gold then -Ttext is fine, but newer
1858# gold versions also support -Ttext-segment. So just assume that unless
1859# we can use -Ttext-segment we need to strip the build-id NOTEs.
florian51b14ee2014-02-22 18:38:32 +00001860if test "x${linker_using_t_text}" = "xyes"; then
tom04ce9f52013-03-28 15:53:21 +00001861AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1862# does the linker support -Wl,--build-id=none ? Note, it's
1863# important that we test indirectly via whichever C compiler
1864# is selected, rather than testing /usr/bin/ld or whatever
1865# directly.
1866AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1867safe_CFLAGS=$CFLAGS
1868CFLAGS="-Wl,--build-id=none"
1869
1870AC_LINK_IFELSE(
1871[AC_LANG_PROGRAM([ ], [return 0;])],
1872[
1873 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1874 AC_MSG_RESULT([yes])
1875], [
1876 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1877 AC_MSG_RESULT([no])
1878])
1879else
1880AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
1881AC_SUBST([FLAG_NO_BUILD_ID], [""])
1882fi
1883CFLAGS=$safe_CFLAGS
bart699fbac2010-06-08 18:23:59 +00001884
sewardj00f1e622006-03-12 16:47:10 +00001885# does the ppc assembler support "mtocrf" et al?
1886AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1887
bart417cf3e2011-10-22 09:21:24 +00001888AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001889__asm__ __volatile__("mtocrf 4,0");
1890__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001891]])], [
sewardj00f1e622006-03-12 16:47:10 +00001892ac_have_as_ppc_mftocrf=yes
1893AC_MSG_RESULT([yes])
1894], [
1895ac_have_as_ppc_mftocrf=no
1896AC_MSG_RESULT([no])
1897])
1898if test x$ac_have_as_ppc_mftocrf = xyes ; then
1899 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1900fi
1901
1902
carll1e5fa2f2013-08-09 21:55:45 +00001903# does the ppc assembler support "lfdp" and other phased out floating point insns?
1904AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
1905
1906AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1907 do { typedef struct {
1908 double hi;
1909 double lo;
1910 } dbl_pair_t;
1911 dbl_pair_t dbl_pair[3];
1912 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
1913 } while (0)
1914]])], [
1915ac_have_as_ppc_fpPO=yes
1916AC_MSG_RESULT([yes])
1917], [
1918ac_have_as_ppc_fpPO=no
1919AC_MSG_RESULT([no])
1920])
1921if test x$ac_have_as_ppc_fpPO = xyes ; then
1922 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
1923fi
1924
sewardjb5b87402011-03-07 16:05:35 +00001925
sewardjf0aabf82007-03-22 00:24:21 +00001926# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001927# Note, this doesn't generate a C-level symbol. It generates a
1928# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001929AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1930
bart417cf3e2011-10-22 09:21:24 +00001931AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001932 do { long long int x;
1933 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1934 while (0)
bart417cf3e2011-10-22 09:21:24 +00001935]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001936ac_have_as_sse3=yes
1937AC_MSG_RESULT([yes])
1938], [
1939ac_have_as_sse3=no
1940AC_MSG_RESULT([no])
1941])
sewardjfa18a262007-03-22 12:13:13 +00001942
1943AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001944
1945
sewardj6d6da5b2008-02-09 12:07:40 +00001946# Ditto for SSSE3 instructions (note extra S)
1947# Note, this doesn't generate a C-level symbol. It generates a
1948# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1949AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1950
florianc443b962011-10-28 21:37:19 +00001951save_CFLAGS="$CFLAGS"
1952CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001953AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001954 do { long long int x;
1955 __asm__ __volatile__(
1956 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1957 while (0)
bart417cf3e2011-10-22 09:21:24 +00001958]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001959ac_have_as_ssse3=yes
1960AC_MSG_RESULT([yes])
1961], [
1962ac_have_as_ssse3=no
1963AC_MSG_RESULT([no])
1964])
florianc443b962011-10-28 21:37:19 +00001965CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001966
1967AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1968
1969
sewardj27d176a2011-01-17 11:15:48 +00001970# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1971# Note, this doesn't generate a C-level symbol. It generates a
1972# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001973AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001975 do {
1976 __asm__ __volatile__(
1977 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1978 while (0)
bart417cf3e2011-10-22 09:21:24 +00001979]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001980ac_have_as_pclmulqdq=yes
1981AC_MSG_RESULT([yes])
1982], [
1983ac_have_as_pclmulqdq=no
1984AC_MSG_RESULT([no])
1985])
1986
1987AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1988
1989
bart9bbe2bb2012-08-03 19:37:02 +00001990# does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
1991# Note, this doesn't generate a C-level symbol. It generates a
1992# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
1993AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
1994AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1995 do {
1996 /*
1997 * Carry-less multiplication of xmm1 with xmm2 and store the result in
1998 * xmm3. The immediate is used to determine which quadwords of xmm1 and
1999 * xmm2 should be used.
2000 */
2001 __asm__ __volatile__(
2002 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2003 } while (0)
2004]])], [
2005ac_have_as_vpclmulqdq=yes
2006AC_MSG_RESULT([yes])
2007], [
2008ac_have_as_vpclmulqdq=no
2009AC_MSG_RESULT([no])
2010])
2011
2012AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2013
2014
sewardj27d176a2011-01-17 11:15:48 +00002015# does the x86/amd64 assembler understand the LZCNT instruction?
2016# Note, this doesn't generate a C-level symbol. It generates a
2017# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00002018AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2019
bart417cf3e2011-10-22 09:21:24 +00002020AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00002021 do {
sewardjc62291c2012-07-22 11:10:08 +00002022 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
bart55e438b2010-09-14 10:53:57 +00002023 } while (0)
bart417cf3e2011-10-22 09:21:24 +00002024]])], [
bart55e438b2010-09-14 10:53:57 +00002025 ac_have_as_lzcnt=yes
2026 AC_MSG_RESULT([yes])
2027], [
2028 ac_have_as_lzcnt=no
2029 AC_MSG_RESULT([no])
2030])
2031
2032AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2033
sewardj27d176a2011-01-17 11:15:48 +00002034
florian3df02112013-10-04 11:35:50 +00002035# does the x86/amd64 assembler understand the LOOPNEL instruction?
2036# Note, this doesn't generate a C-level symbol. It generates a
2037# automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2038AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2039
2040AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2041 do {
2042 __asm__ __volatile__("1: loopnel 1b\n");
2043 } while (0)
2044]])], [
2045 ac_have_as_loopnel=yes
2046 AC_MSG_RESULT([yes])
2047], [
2048 ac_have_as_loopnel=no
2049 AC_MSG_RESULT([no])
2050])
2051
2052AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2053
2054
2055# does the x86/amd64 assembler understand ADDR32 ?
2056# Note, this doesn't generate a C-level symbol. It generates a
2057# automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2058AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2059
2060AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2061 do {
2062 asm volatile ("addr32 rep movsb");
2063 } while (0)
2064]])], [
2065 ac_have_as_addr32=yes
2066 AC_MSG_RESULT([yes])
2067], [
2068 ac_have_as_addr32=no
2069 AC_MSG_RESULT([no])
2070])
2071
2072AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2073
2074
sewardj27d176a2011-01-17 11:15:48 +00002075# does the x86/amd64 assembler understand SSE 4.2 instructions?
2076# Note, this doesn't generate a C-level symbol. It generates a
2077# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2078AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2079
bart417cf3e2011-10-22 09:21:24 +00002080AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00002081 do { long long int x;
2082 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00002083 "crc32q %%r15,%%r15" : : : "r15" );
2084 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002085 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2086 __asm__ __volatile__(
2087 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
sewardj27d176a2011-01-17 11:15:48 +00002088 while (0)
bart417cf3e2011-10-22 09:21:24 +00002089]])], [
sewardj27d176a2011-01-17 11:15:48 +00002090ac_have_as_sse42=yes
2091AC_MSG_RESULT([yes])
2092], [
2093ac_have_as_sse42=no
2094AC_MSG_RESULT([no])
2095])
2096
2097AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2098
2099
sewardj9fb31ca2012-06-05 00:31:49 +00002100# does the x86/amd64 assembler understand AVX instructions?
2101# Note, this doesn't generate a C-level symbol. It generates a
2102# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2103AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2104
2105AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2106 do { long long int x;
2107 __asm__ __volatile__(
2108 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2109 __asm__ __volatile__(
2110 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2111 while (0)
2112]])], [
2113ac_have_as_avx=yes
2114AC_MSG_RESULT([yes])
2115], [
2116ac_have_as_avx=no
2117AC_MSG_RESULT([no])
2118])
2119
2120AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2121
2122
sewardjfda50af2013-03-27 11:43:20 +00002123# does the x86/amd64 assembler understand AVX2 instructions?
2124# Note, this doesn't generate a C-level symbol. It generates a
2125# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2126AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2127
2128AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2129 do { long long int x;
2130 __asm__ __volatile__(
2131 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2132 __asm__ __volatile__(
2133 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2134 while (0)
2135]])], [
2136ac_have_as_avx2=yes
2137AC_MSG_RESULT([yes])
2138], [
2139ac_have_as_avx2=no
2140AC_MSG_RESULT([no])
2141])
2142
2143AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2144
2145
sewardj9ea080b2013-10-16 08:53:07 +00002146# does the x86/amd64 assembler understand TSX instructions and
2147# the XACQUIRE/XRELEASE prefixes?
florian364c3652013-09-30 16:32:53 +00002148# Note, this doesn't generate a C-level symbol. It generates a
2149# automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2150AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2151
2152AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2153 do {
2154 __asm__ __volatile__(
2155 " xbegin Lfoo \n\t"
sewardj9ea080b2013-10-16 08:53:07 +00002156 "Lfoo: xend \n\t"
2157 " xacquire lock incq 0(%rsp) \n\t"
2158 " xrelease lock incq 0(%rsp) \n"
2159 );
florian364c3652013-09-30 16:32:53 +00002160 } while (0)
2161]])], [
2162ac_have_as_tsx=yes
2163AC_MSG_RESULT([yes])
2164], [
2165ac_have_as_tsx=no
2166AC_MSG_RESULT([no])
2167])
2168
2169AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2170
2171
sewardjfda50af2013-03-27 11:43:20 +00002172# does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2173# Note, this doesn't generate a C-level symbol. It generates a
2174# automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2175AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2176
2177AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2178 do { unsigned int h, l;
2179 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002180 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
sewardjfda50af2013-03-27 11:43:20 +00002181 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002182 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
sewardjfda50af2013-03-27 11:43:20 +00002183 while (0)
2184]])], [
2185ac_have_as_bmi=yes
2186AC_MSG_RESULT([yes])
2187], [
2188ac_have_as_bmi=no
2189AC_MSG_RESULT([no])
2190])
2191
2192AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2193
2194
2195# does the x86/amd64 assembler understand FMA instructions?
2196# Note, this doesn't generate a C-level symbol. It generates a
2197# automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2198AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2199
2200AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2201 do { unsigned int h, l;
2202 __asm__ __volatile__(
2203 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2204 __asm__ __volatile__(
2205 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2206 __asm__ __volatile__(
2207 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2208 while (0)
2209]])], [
2210ac_have_as_fma=yes
2211AC_MSG_RESULT([yes])
2212], [
2213ac_have_as_fma=no
2214AC_MSG_RESULT([no])
2215])
2216
2217AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2218
2219
mjw20bafc22014-05-09 11:41:46 +00002220# does the amd64 assembler understand MPX instructions?
2221# Note, this doesn't generate a C-level symbol. It generates a
2222# automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2223AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2224
2225AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2226 asm ("bndmov %bnd0,(%rsp)")
2227]])], [
2228ac_have_as_mpx=yes
2229AC_MSG_RESULT([yes])
2230], [
2231ac_have_as_mpx=no
2232AC_MSG_RESULT([no])
2233])
2234
2235AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2236
2237
2238# Does the C compiler support the "ifunc" attribute
2239# Note, this doesn't generate a C-level symbol. It generates a
2240# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
sewardjb08d84d2012-07-16 08:23:26 +00002241# does the x86/amd64 assembler understand MOVBE?
2242# Note, this doesn't generate a C-level symbol. It generates a
2243# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2244AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2245
2246AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2247 do { long long int x;
2248 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002249 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
sewardjb08d84d2012-07-16 08:23:26 +00002250 while (0)
2251]])], [
2252ac_have_as_movbe=yes
2253AC_MSG_RESULT([yes])
2254], [
2255ac_have_as_movbe=no
2256AC_MSG_RESULT([no])
2257])
2258
2259AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2260
2261
florian251c2f92012-07-05 21:21:37 +00002262# Does the C compiler support the "ifunc" attribute
2263# Note, this doesn't generate a C-level symbol. It generates a
2264# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2265AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2266
florianf78a5032012-07-06 09:17:29 +00002267AC_LINK_IFELSE([AC_LANG_SOURCE([[
2268static void mytest(void) {}
2269
2270static void (*resolve_test(void))(void)
2271{
2272 return (void (*)(void))&mytest;
2273}
2274
2275void test(void) __attribute__((ifunc("resolve_test")));
2276
2277int main()
2278{
2279 test();
2280 return 0;
2281}
florian251c2f92012-07-05 21:21:37 +00002282]])], [
2283ac_have_ifunc_attr=yes
2284AC_MSG_RESULT([yes])
2285], [
2286ac_have_ifunc_attr=no
2287AC_MSG_RESULT([no])
2288])
2289
2290AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2291
2292
sewardje089f012010-10-13 21:47:29 +00002293# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2294# when building the tool executables. I think we should get rid of it.
2295#
sewardjb5f6f512005-03-10 23:59:00 +00002296# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00002297AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2298 [[return foo;]])],
2299 [vg_cv_linktime_tls=yes],
2300 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00002301# Native compilation: check whether running a program using TLS succeeds.
2302# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2303# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00002304# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00002305AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2306 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2307 [vg_cv_tls=$enableval],
2308 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2309 [[return foo;]])],
2310 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00002311 [vg_cv_tls=no],
2312 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00002313
2314if test "$vg_cv_tls" = yes; then
2315AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2316fi
sewardj5b754b42002-06-03 22:53:35 +00002317
sewardj535c50f2005-06-04 23:14:53 +00002318
njn7fd6d382009-01-22 21:56:32 +00002319#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00002320# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00002321#----------------------------------------------------------------------------
2322
sewardjde4a1d02002-03-22 01:27:54 +00002323AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00002324AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00002325 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00002326 endian.h \
2327 mqueue.h \
2328 sys/endian.h \
2329 sys/epoll.h \
2330 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00002331 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00002332 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00002333 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00002334 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00002335 sys/syscall.h \
2336 sys/time.h \
2337 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00002338 ])
sewardjde4a1d02002-03-22 01:27:54 +00002339
bart818f17e2011-09-17 06:24:49 +00002340# Verify whether the <linux/futex.h> header is usable.
2341AC_MSG_CHECKING([if <linux/futex.h> is usable])
2342
sewardjc12486b2012-12-17 14:46:48 +00002343save_CFLAGS="$CFLAGS"
2344CFLAGS="$CFLAGS -D__user="
bart417cf3e2011-10-22 09:21:24 +00002345AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00002346#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00002347]], [[
bart818f17e2011-09-17 06:24:49 +00002348 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00002349]])], [
bart78bfc712011-12-08 16:14:59 +00002350ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00002351AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2352 [Define to 1 if you have a usable <linux/futex.h> header file.])
2353AC_MSG_RESULT([yes])
2354], [
bart78bfc712011-12-08 16:14:59 +00002355ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00002356AC_MSG_RESULT([no])
2357])
sewardjc12486b2012-12-17 14:46:48 +00002358CFLAGS="$save_CFLAGS"
2359
bart818f17e2011-09-17 06:24:49 +00002360
njn7fd6d382009-01-22 21:56:32 +00002361#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002362# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00002363#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002364AC_TYPE_UID_T
2365AC_TYPE_OFF_T
2366AC_TYPE_SIZE_T
2367AC_HEADER_TIME
2368
sewardj535c50f2005-06-04 23:14:53 +00002369
njn7fd6d382009-01-22 21:56:32 +00002370#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002371# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00002372#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002373AC_FUNC_MEMCMP
2374AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00002375
bart26288e42011-04-03 16:46:01 +00002376AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00002377AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00002378
bartf5ceec82008-04-26 07:45:10 +00002379AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00002380 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00002381 epoll_create \
2382 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00002383 klogctl \
bartf5ceec82008-04-26 07:45:10 +00002384 mallinfo \
2385 memchr \
2386 memset \
2387 mkdir \
njnf76d27a2009-05-28 01:53:07 +00002388 mremap \
bartf5ceec82008-04-26 07:45:10 +00002389 ppoll \
bart6d45e922009-01-20 13:45:38 +00002390 pthread_barrier_init \
2391 pthread_condattr_setclock \
2392 pthread_mutex_timedlock \
2393 pthread_rwlock_timedrdlock \
2394 pthread_rwlock_timedwrlock \
2395 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00002396 pthread_yield \
florianc5325ef2013-09-17 20:15:36 +00002397 pthread_setname_np \
bartd1f724c2009-08-26 18:11:18 +00002398 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00002399 semtimedop \
2400 signalfd \
njn6cc22472009-03-16 03:46:48 +00002401 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00002402 strchr \
2403 strdup \
2404 strpbrk \
2405 strrchr \
2406 strstr \
barta72a27b2010-04-29 06:22:17 +00002407 syscall \
bartf5ceec82008-04-26 07:45:10 +00002408 utimensat \
tom9e4b6362012-02-10 09:39:37 +00002409 process_vm_readv \
2410 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00002411 ])
sewardjde4a1d02002-03-22 01:27:54 +00002412
bart623eec32008-07-29 17:54:49 +00002413# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2414# libraries with any shared object and/or executable. This is NOT what we
2415# want for e.g. vgpreload_core-x86-linux.so
2416LIBS=""
sewardj80637752006-03-02 13:48:21 +00002417
bart6d45e922009-01-20 13:45:38 +00002418AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2419 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00002420AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2421 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00002422AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2423 [test x$ac_cv_func_pthread_spin_lock = xyes])
florianc5325ef2013-09-17 20:15:36 +00002424AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2425 [test x$ac_cv_func_pthread_setname_np = xyes])
bart6d45e922009-01-20 13:45:38 +00002426
petarjc37cea62013-06-02 18:08:04 +00002427if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2428 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
petarj6d79b742012-12-20 18:56:57 +00002429 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
petarjc37cea62013-06-02 18:08:04 +00002430 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
petarj6d79b742012-12-20 18:56:57 +00002431fi
njn7fd6d382009-01-22 21:56:32 +00002432
2433#----------------------------------------------------------------------------
2434# MPI checks
2435#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00002436# Do we have a useable MPI setup on the primary and/or secondary targets?
2437# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00002438# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00002439# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00002440# --with-mpicc=.
mjw46f25042014-08-21 10:04:04 +00002441AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2442 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
sewardj03d86f22006-10-17 00:57:24 +00002443
sewardje9fa5062006-03-12 18:29:18 +00002444mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00002445if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00002446 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj5db15402012-06-07 09:13:21 +00002447 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +00002448 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2449 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002450 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00002451elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002452 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjf0c12502014-01-12 12:54:00 +00002453 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002454 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002455 mflag_primary=$FLAG_M64
philippef7c54332012-05-17 15:32:54 +00002456elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2457 mflag_primary="$FLAG_M32 -arch i386"
2458elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2459 mflag_primary="$FLAG_M64 -arch x86_64"
sewardje9fa5062006-03-12 18:29:18 +00002460fi
2461
sewardj03d86f22006-10-17 00:57:24 +00002462mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00002463if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2464 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00002465 mflag_secondary=$FLAG_M32
philippef7c54332012-05-17 15:32:54 +00002466elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2467 mflag_secondary="$FLAG_M32 -arch i386"
sewardj03d86f22006-10-17 00:57:24 +00002468fi
2469
2470
sewardj0ad46092006-03-02 17:09:16 +00002471AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00002472 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00002473 MPI_CC=$withval
2474)
sewardj03d86f22006-10-17 00:57:24 +00002475AC_SUBST(MPI_CC)
2476
philippef7c54332012-05-17 15:32:54 +00002477## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2478## use these values in the check for a functioning mpicc.
2479##
2480## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2481## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2482AM_COND_IF([VGCONF_OS_IS_LINUX],
2483 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2484 LDFLAGS_MPI="-fpic -shared"])
2485AM_COND_IF([VGCONF_OS_IS_DARWIN],
2486 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2487 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2488
2489AC_SUBST([CFLAGS_MPI])
2490AC_SUBST([LDFLAGS_MPI])
2491
2492
sewardj03d86f22006-10-17 00:57:24 +00002493## See if MPI_CC works for the primary target
2494##
2495AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00002496saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00002497saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00002498CC=$MPI_CC
philippef7c54332012-05-17 15:32:54 +00002499CFLAGS="$CFLAGS_MPI $mflag_primary"
2500saved_LDFLAGS="$LDFLAGS"
2501LDFLAGS="$LDFLAGS_MPI $mflag_primary"
bart417cf3e2011-10-22 09:21:24 +00002502AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00002503#include <mpi.h>
2504#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002505]], [[
philippef7c54332012-05-17 15:32:54 +00002506 int ni, na, nd, comb;
sewardjde4f3842006-03-09 02:41:41 +00002507 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002508 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2509 r |= MPI_Finalize();
sewardjde4f3842006-03-09 02:41:41 +00002510 return r;
bart417cf3e2011-10-22 09:21:24 +00002511]])], [
sewardj03d86f22006-10-17 00:57:24 +00002512ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00002513AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00002514], [
sewardj03d86f22006-10-17 00:57:24 +00002515ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00002516AC_MSG_RESULT([no])
2517])
sewardj0ad46092006-03-02 17:09:16 +00002518CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00002519CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002520LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002521AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00002522
sewardj03d86f22006-10-17 00:57:24 +00002523## See if MPI_CC works for the secondary target. Complication: what if
2524## there is no secondary target? We need this to then fail.
2525## Kludge this by making MPI_CC something which will surely fail in
2526## such a case.
2527##
2528AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2529saved_CC=$CC
2530saved_CFLAGS=$CFLAGS
philippef7c54332012-05-17 15:32:54 +00002531saved_LDFLAGS="$LDFLAGS"
2532LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
njn7fd6d382009-01-22 21:56:32 +00002533if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00002534 CC="$MPI_CC this will surely fail"
2535else
2536 CC=$MPI_CC
2537fi
philippef7c54332012-05-17 15:32:54 +00002538CFLAGS="$CFLAGS_MPI $mflag_secondary"
bart417cf3e2011-10-22 09:21:24 +00002539AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00002540#include <mpi.h>
2541#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002542]], [[
philippef7c54332012-05-17 15:32:54 +00002543 int ni, na, nd, comb;
sewardj03d86f22006-10-17 00:57:24 +00002544 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002545 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2546 r |= MPI_Finalize();
sewardj03d86f22006-10-17 00:57:24 +00002547 return r;
bart417cf3e2011-10-22 09:21:24 +00002548]])], [
sewardj03d86f22006-10-17 00:57:24 +00002549ac_have_mpi2_sec=yes
2550AC_MSG_RESULT([yes, $MPI_CC])
2551], [
2552ac_have_mpi2_sec=no
2553AC_MSG_RESULT([no])
2554])
2555CC=$saved_CC
2556CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002557LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002558AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00002559
2560
njn7fd6d382009-01-22 21:56:32 +00002561#----------------------------------------------------------------------------
2562# Other library checks
2563#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00002564# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00002565# tests are present because Drd has some regression tests that use
2566# these packages. All regression test programs all compiled only
2567# for the primary target. And so it is important that the configure
2568# checks that follow, use the correct -m32 or -m64 flag for the
2569# primary target (called $mflag_primary). Otherwise, we can end up
2570# in a situation (eg) where, on amd64-linux, the test for Boost checks
2571# for usable 64-bit Boost facilities, but because we are doing a 32-bit
2572# only build (meaning, the primary target is x86-linux), the build
2573# of the regtest programs that use Boost fails, because they are
2574# build as 32-bit (IN THIS EXAMPLE).
2575#
2576# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2577# NEEDED BY THE REGRESSION TEST PROGRAMS.
2578
2579
sewardj493c4ef2008-12-13 16:45:19 +00002580# Check whether the boost library 1.35 or later has been installed.
2581# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2582
2583AC_MSG_CHECKING([for boost])
2584
2585AC_LANG(C++)
2586safe_CXXFLAGS=$CXXFLAGS
bart7129c722012-04-18 18:34:22 +00002587CXXFLAGS="$mflag_primary"
2588safe_LIBS="$LIBS"
bartce93f9e2014-06-12 07:45:23 +00002589LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002590
bart128fc522011-03-12 10:36:35 +00002591AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002592#include <boost/thread.hpp>
2593static void thread_func(void)
2594{ }
2595int main(int argc, char** argv)
2596{
2597 boost::thread t(thread_func);
2598 return 0;
2599}
bart128fc522011-03-12 10:36:35 +00002600])],
sewardj493c4ef2008-12-13 16:45:19 +00002601[
2602ac_have_boost_1_35=yes
2603AC_SUBST([BOOST_CFLAGS], [])
bartce93f9e2014-06-12 07:45:23 +00002604AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
sewardj493c4ef2008-12-13 16:45:19 +00002605AC_MSG_RESULT([yes])
2606], [
2607ac_have_boost_1_35=no
2608AC_MSG_RESULT([no])
2609])
2610
bart7129c722012-04-18 18:34:22 +00002611LIBS="$safe_LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002612CXXFLAGS=$safe_CXXFLAGS
2613AC_LANG(C)
2614
2615AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2616
2617
2618# does this compiler support -fopenmp, does it have the include file
2619# <omp.h> and does it have libgomp ?
2620
2621AC_MSG_CHECKING([for OpenMP])
2622
2623safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00002624CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00002625
bart128fc522011-03-12 10:36:35 +00002626AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002627#include <omp.h>
2628int main(int argc, char** argv)
2629{
2630 omp_set_dynamic(0);
2631 return 0;
2632}
bart128fc522011-03-12 10:36:35 +00002633])],
sewardj493c4ef2008-12-13 16:45:19 +00002634[
2635ac_have_openmp=yes
2636AC_MSG_RESULT([yes])
2637], [
2638ac_have_openmp=no
2639AC_MSG_RESULT([no])
2640])
2641CFLAGS=$safe_CFLAGS
2642
2643AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2644
2645
bart78bfc712011-12-08 16:14:59 +00002646# does this compiler have built-in functions for atomic memory access for the
2647# primary target ?
2648AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00002649
2650safe_CFLAGS=$CFLAGS
2651CFLAGS="$mflag_primary"
2652
bart417cf3e2011-10-22 09:21:24 +00002653AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00002654 int variable = 1;
2655 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2656 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002657]])], [
bartb4ff7822011-12-10 19:48:04 +00002658 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00002659 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00002660 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 +00002661], [
bartb4ff7822011-12-10 19:48:04 +00002662 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00002663 AC_MSG_RESULT([no])
2664])
2665
2666CFLAGS=$safe_CFLAGS
2667
bartb4ff7822011-12-10 19:48:04 +00002668AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2669 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00002670
bart78bfc712011-12-08 16:14:59 +00002671
2672# does this compiler have built-in functions for atomic memory access for the
2673# secondary target ?
2674
2675if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2676
2677AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2678
2679safe_CFLAGS=$CFLAGS
2680CFLAGS="$mflag_secondary"
2681
2682AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2683 int variable = 1;
2684 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2685]])], [
2686 ac_have_builtin_atomic_secondary=yes
2687 AC_MSG_RESULT([yes])
2688], [
2689 ac_have_builtin_atomic_secondary=no
2690 AC_MSG_RESULT([no])
2691])
2692
2693CFLAGS=$safe_CFLAGS
2694
2695fi
2696
2697AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2698 [test x$ac_have_builtin_atomic_secondary = xyes])
2699
bart1e856ea2011-12-17 12:53:23 +00002700# does this compiler have built-in functions for atomic memory access on
2701# 64-bit integers for all targets ?
2702
2703AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2704
2705AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2706 #include <stdint.h>
2707]], [[
2708 uint64_t variable = 1;
2709 return __sync_add_and_fetch(&variable, 1)
2710]])], [
2711 ac_have_builtin_atomic64_primary=yes
2712], [
2713 ac_have_builtin_atomic64_primary=no
2714])
2715
2716if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2717
2718safe_CFLAGS=$CFLAGS
2719CFLAGS="$mflag_secondary"
2720
2721AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2722 #include <stdint.h>
2723]], [[
2724 uint64_t variable = 1;
2725 return __sync_add_and_fetch(&variable, 1)
2726]])], [
2727 ac_have_builtin_atomic64_secondary=yes
2728], [
2729 ac_have_builtin_atomic64_secondary=no
2730])
2731
2732CFLAGS=$safe_CFLAGS
2733
2734fi
2735
2736if test x$ac_have_builtin_atomic64_primary = xyes && \
2737 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2738 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2739 AC_MSG_RESULT([yes])
2740 ac_have_builtin_atomic64=yes
2741else
2742 AC_MSG_RESULT([no])
2743 ac_have_builtin_atomic64=no
2744fi
2745
2746AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2747 [test x$ac_have_builtin_atomic64 = xyes])
2748
bart78bfc712011-12-08 16:14:59 +00002749
barte8740422011-03-24 20:27:54 +00002750# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002751AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002752
2753safe_CXXFLAGS=$CXXFLAGS
2754CXXFLAGS="$mflag_primary"
2755
2756AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002757AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002758 int variable = 1;
2759 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2760 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002761]])], [
barte8740422011-03-24 20:27:54 +00002762 ac_have_builtin_atomic_cxx=yes
2763 AC_MSG_RESULT([yes])
2764 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 +00002765], [
barte8740422011-03-24 20:27:54 +00002766 ac_have_builtin_atomic_cxx=no
2767 AC_MSG_RESULT([no])
2768])
2769AC_LANG_POP(C++)
2770
2771CXXFLAGS=$safe_CXXFLAGS
2772
2773AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002774
bart78bfc712011-12-08 16:14:59 +00002775
2776if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002777 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002778 ac_enable_linux_ticket_lock_primary=yes
2779fi
2780AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2781 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2782
2783if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2784 -a x$ac_have_usable_linux_futex_h = xyes \
2785 -a x$ac_have_builtin_atomic_secondary = xyes; then
2786 ac_enable_linux_ticket_lock_secondary=yes
2787fi
2788AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2789 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2790
2791
bartf68af882011-12-10 19:42:05 +00002792# does libstdc++ support annotating shared pointers ?
2793AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2794
floriand79b3bf2013-10-02 15:14:59 +00002795safe_CXXFLAGS=$CXXFLAGS
bartf68af882011-12-10 19:42:05 +00002796CXXFLAGS="-std=c++0x"
2797
2798AC_LANG_PUSH(C++)
2799AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2800 #include <memory>
2801]], [[
2802 std::shared_ptr<int> p
2803]])], [
2804 ac_have_shared_ptr=yes
2805], [
2806 ac_have_shared_ptr=no
2807])
2808if test x$ac_have_shared_ptr = xyes; then
2809 # If compilation of the program below fails because of a syntax error
2810 # triggered by substituting one of the annotation macros then that
2811 # means that libstdc++ supports these macros.
2812 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2813 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2814 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2815 #include <memory>
2816 ]], [[
2817 std::shared_ptr<int> p
2818 ]])], [
2819 ac_have_shared_pointer_annotation=no
2820 AC_MSG_RESULT([no])
2821 ], [
2822 ac_have_shared_pointer_annotation=yes
2823 AC_MSG_RESULT([yes])
2824 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2825 [Define to 1 if libstd++ supports annotating shared pointers])
2826 ])
2827else
2828 ac_have_shared_pointer_annotation=no
2829 AC_MSG_RESULT([no])
2830fi
2831AC_LANG_POP(C++)
2832
2833CXXFLAGS=$safe_CXXFLAGS
2834
2835AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2836 [test x$ac_have_shared_pointer_annotation = xyes])
2837
2838
njn7fd6d382009-01-22 21:56:32 +00002839#----------------------------------------------------------------------------
2840# Ok. We're done checking.
2841#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002842
njn8b68b642009-06-24 00:37:09 +00002843# Nb: VEX/Makefile is generated from Makefile.vex.in.
2844AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002845 Makefile
njn8b68b642009-06-24 00:37:09 +00002846 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002847 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002848 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002849 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002850 docs/Makefile
2851 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002852 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002853 perf/Makefile
2854 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002855 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002856 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002857 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002858 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002859 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002860 memcheck/Makefile
2861 memcheck/tests/Makefile
floriane42cca52013-08-29 17:59:27 +00002862 memcheck/tests/common/Makefile
njnc6168192004-11-29 13:54:10 +00002863 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002864 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002865 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002866 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002867 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002868 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002869 memcheck/tests/ppc32/Makefile
2870 memcheck/tests/ppc64/Makefile
florian0bb707e2012-05-30 20:46:58 +00002871 memcheck/tests/s390x/Makefile
florianbb913cd2012-08-28 16:50:39 +00002872 memcheck/tests/vbit-test/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002873 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002874 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002875 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002876 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002877 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002878 callgrind/Makefile
2879 callgrind/callgrind_annotate
2880 callgrind/callgrind_control
2881 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002882 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002883 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002884 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002885 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002886 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002887 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002888 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002889 none/Makefile
2890 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002891 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002892 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002893 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002894 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002895 none/tests/arm/Makefile
sewardjf02d2ec2014-08-26 19:28:09 +00002896 none/tests/arm64/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002897 none/tests/s390x/Makefile
sewardj5db15402012-06-07 09:13:21 +00002898 none/tests/mips32/Makefile
petarj8bea8672013-05-10 13:14:54 +00002899 none/tests/mips64/Makefile
njn0458a122009-02-13 06:23:46 +00002900 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002901 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002902 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002903 exp-sgcheck/Makefile
2904 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002905 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002906 drd/scripts/download-and-build-splash2
2907 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002908 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002909 exp-bbv/tests/Makefile
2910 exp-bbv/tests/x86/Makefile
2911 exp-bbv/tests/x86-linux/Makefile
2912 exp-bbv/tests/amd64-linux/Makefile
2913 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002914 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002915 exp-dhat/Makefile
2916 exp-dhat/tests/Makefile
mjwaeacd282014-03-11 19:30:32 +00002917 shared/Makefile
njn8b68b642009-06-24 00:37:09 +00002918])
sewardjd3645802010-06-13 22:13:58 +00002919AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2920 [chmod +x coregrind/link_tool_exe_linux])
2921AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2922 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002923AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002924
2925cat<<EOF
2926
njn311303f2009-02-06 03:46:50 +00002927 Maximum build arch: ${ARCH_MAX}
2928 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002929 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002930 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002931 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2932 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002933 Platform variant: ${VGCONF_PLATVARIANT}
2934 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002935 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002936
gobry3b777892002-04-04 09:18:39 +00002937EOF