blob: ece5faaa5ecfe8121b600d7ef68819d0f56268ce [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.
sewardj78795d12013-12-06 15:54:02 +000011AC_INIT([Valgrind],[3.10.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
134case "${is_clang}-${gcc_version}" in
135 notclang-3.*)
136 AC_MSG_RESULT([ok (${gcc_version})])
137 ;;
138 notclang-4.*)
139 AC_MSG_RESULT([ok (${gcc_version})])
140 ;;
sewardjae284e52012-08-02 18:25:04 +0000141 clang-2.9|clang-3.*|clang-4.*)
sewardj3ab7b662011-09-29 17:30:13 +0000142 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000143 ;;
gobrye721a522002-03-22 13:38:30 +0000144 *)
sewardj3ab7b662011-09-29 17:30:13 +0000145 AC_MSG_RESULT([no (${gcc_version})])
146 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000147 ;;
148esac
149
njn7fd6d382009-01-22 21:56:32 +0000150#----------------------------------------------------------------------------
151# Arch/OS/platform tests.
152#----------------------------------------------------------------------------
153# We create a number of arch/OS/platform-related variables. We prefix them
154# all with "VGCONF_" which indicates that they are defined at
155# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
156# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000157
sewardjde4a1d02002-03-22 01:27:54 +0000158AC_CANONICAL_HOST
159
160AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000161
njn7fd6d382009-01-22 21:56:32 +0000162# ARCH_MAX reflects the most that this CPU can do: for example if it
163# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
164# Ditto for amd64. It is used for more configuration below, but is not used
165# outside this file.
gobrye721a522002-03-22 13:38:30 +0000166case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000167 i?86)
168 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000169 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000170 ;;
171
njnfe408942004-11-23 17:52:24 +0000172 x86_64)
173 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000174 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000175 ;;
176
sewardj2c48c7b2005-11-29 13:05:56 +0000177 powerpc64)
178 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000179 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000180 ;;
181
182 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000183 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000184 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000185 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000186 ;;
187
sewardjb5b87402011-03-07 16:05:35 +0000188 s390x)
189 AC_MSG_RESULT([ok (${host_cpu})])
190 ARCH_MAX="s390x"
191 ;;
192
sewardj59570ff2010-01-01 11:59:33 +0000193 armv7*)
194 AC_MSG_RESULT([ok (${host_cpu})])
195 ARCH_MAX="arm"
196 ;;
197
sewardjf0c12502014-01-12 12:54:00 +0000198 aarch64*)
199 AC_MSG_RESULT([ok (${host_cpu})])
200 ARCH_MAX="arm64"
201 ;;
202
sewardj5db15402012-06-07 09:13:21 +0000203 mips)
petarj4df0bfc2013-02-27 23:17:33 +0000204 AC_MSG_RESULT([ok (${host_cpu})])
205 ARCH_MAX="mips32"
206 ;;
sewardj5db15402012-06-07 09:13:21 +0000207
208 mipsel)
petarj4df0bfc2013-02-27 23:17:33 +0000209 AC_MSG_RESULT([ok (${host_cpu})])
210 ARCH_MAX="mips32"
211 ;;
sewardj5db15402012-06-07 09:13:21 +0000212
213 mipsisa32r2)
petarj4df0bfc2013-02-27 23:17:33 +0000214 AC_MSG_RESULT([ok (${host_cpu})])
215 ARCH_MAX="mips32"
216 ;;
sewardj5db15402012-06-07 09:13:21 +0000217
petarj4df0bfc2013-02-27 23:17:33 +0000218 mips64*)
219 AC_MSG_RESULT([ok (${host_cpu})])
220 ARCH_MAX="mips64"
221 ;;
222
223 mipsisa64*)
224 AC_MSG_RESULT([ok (${host_cpu})])
225 ARCH_MAX="mips64"
226 ;;
sewardjde4a1d02002-03-22 01:27:54 +0000227 *)
228 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000229 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000230 ;;
231esac
232
njn7fd6d382009-01-22 21:56:32 +0000233#----------------------------------------------------------------------------
234
sewardj86e992f2006-01-28 18:39:09 +0000235# Sometimes it's convenient to subvert the bi-arch build system and
236# just have a single build even though the underlying platform is
237# capable of both. Hence handle --enable-only64bit and
238# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000239# [Actually, if either of these options are used, I think both get built,
240# but only one gets installed. So if you use an in-place build, both can be
241# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000242
243# Check if a 64-bit only build has been requested
244AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
245 [AC_ARG_ENABLE(only64bit,
246 [ --enable-only64bit do a 64-bit only build],
247 [vg_cv_only64bit=$enableval],
248 [vg_cv_only64bit=no])])
249
250# Check if a 32-bit only build has been requested
251AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
252 [AC_ARG_ENABLE(only32bit,
253 [ --enable-only32bit do a 32-bit only build],
254 [vg_cv_only32bit=$enableval],
255 [vg_cv_only32bit=no])])
256
257# Stay sane
258if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
259 AC_MSG_ERROR(
260 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
261fi
262
njn7fd6d382009-01-22 21:56:32 +0000263#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000264
njn311303f2009-02-06 03:46:50 +0000265# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
266# compilation of many C files via -VGO_$(VGCONF_OS) and
267# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000268AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000269AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000270
njnf76d27a2009-05-28 01:53:07 +0000271DEFAULT_SUPP=""
272
gobrye721a522002-03-22 13:38:30 +0000273case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000274 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000275 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000276 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000277
278 # Ok, this is linux. Check the kernel version
279 AC_MSG_CHECKING([for the kernel version])
280
281 kernel=`uname -r`
282
283 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000284 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000285 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
286 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 +0000287 ;;
288
289 2.4.*)
290 AC_MSG_RESULT([2.4 family (${kernel})])
291 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
292 ;;
293
mueller8c68e042004-01-03 15:21:14 +0000294 *)
295 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000296 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000297 ;;
298 esac
299
300 ;;
301
njnf76d27a2009-05-28 01:53:07 +0000302 *darwin*)
303 AC_MSG_RESULT([ok (${host_os})])
304 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000305 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
306 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
307 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
sewardjae284e52012-08-02 18:25:04 +0000308 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
njnf76d27a2009-05-28 01:53:07 +0000309
310 AC_MSG_CHECKING([for the kernel version])
311 kernel=`uname -r`
312
313 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
314 # has only one relevant version, the OS version. The `uname` check
315 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000316 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
317 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000318 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000319 #
320 # XXX: `uname -r` won't do the right thing for cross-compiles, but
321 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000322 #
323 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
324 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
325 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
326 # time support for 10.5 (the 9.* pattern just below), I'll leave it
327 # in for now, just in case anybody wants to give it a try. But I'm
328 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000329 case "${kernel}" in
330 9.*)
331 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000332 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000333 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000334 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000335 ;;
njnea2d6fd2010-07-01 00:20:20 +0000336 10.*)
337 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
338 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
339 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
340 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
341 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000342 11.*)
343 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
344 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
sewardj731f9cf2011-09-21 08:43:08 +0000345 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
346 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
347 ;;
sewardjae284e52012-08-02 18:25:04 +0000348 12.*)
349 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
350 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
351 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
352 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
353 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000354 *)
njnf76d27a2009-05-28 01:53:07 +0000355 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000356 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000357 ;;
358 esac
359 ;;
360
sewardjde4a1d02002-03-22 01:27:54 +0000361 *)
362 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000363 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000364 ;;
365esac
366
njn7fd6d382009-01-22 21:56:32 +0000367#----------------------------------------------------------------------------
368
tomd6398392006-06-07 17:44:36 +0000369# If we are building on a 64 bit platform test to see if the system
370# supports building 32 bit programs and disable 32 bit support if it
371# does not support building 32 bit programs
372
njn7fd6d382009-01-22 21:56:32 +0000373case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000374 amd64-linux|ppc64-linux)
375 AC_MSG_CHECKING([for 32 bit build support])
376 safe_CFLAGS=$CFLAGS
377 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000378 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000379 return 0;
bart417cf3e2011-10-22 09:21:24 +0000380 ]])], [
tomd6398392006-06-07 17:44:36 +0000381 AC_MSG_RESULT([yes])
382 ], [
383 vg_cv_only64bit="yes"
384 AC_MSG_RESULT([no])
385 ])
386 CFLAGS=$safe_CFLAGS;;
387esac
388
389if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
390 AC_MSG_ERROR(
391 [--enable-only32bit was specified but system does not support 32 bit builds])
392fi
nethercote888ecb72004-08-23 14:54:40 +0000393
njn7fd6d382009-01-22 21:56:32 +0000394#----------------------------------------------------------------------------
395
njn311303f2009-02-06 03:46:50 +0000396# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
397# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
398# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
399# above) will be "amd64" since that reflects the most that this cpu can do,
400# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
401# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000402# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
403# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
404AC_SUBST(VGCONF_ARCH_PRI)
405
njn3f8a6e92009-06-02 00:20:47 +0000406# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
407# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
408# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
409# It is empty if there is no secondary target.
410AC_SUBST(VGCONF_ARCH_SEC)
411
njn311303f2009-02-06 03:46:50 +0000412# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
413# The entire system, including regression and performance tests, will be
414# built for this target. The "_CAPS" indicates that the name is in capital
415# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000416# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000417# convention and cannot contain '-' characters. This is in contrast to
418# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000419AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
420
421# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
422# Valgrind and tools will also be built for this target, but not the
423# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000424#
njn7fd6d382009-01-22 21:56:32 +0000425# By default, the primary arch is the same as the "max" arch, as commented
426# above (at the definition of ARCH_MAX). We may choose to downgrade it in
427# the big case statement just below here, in the case where we're building
428# on a 64 bit machine but have been requested only to do a 32 bit build.
429AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
430
sewardj01262142006-01-04 01:20:28 +0000431AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000432
njnea2d6fd2010-07-01 00:20:20 +0000433# NB. The load address for a given platform may be specified in more
434# than one place, in some cases, depending on whether we're doing a biarch,
435# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
436# Be careful to give consistent values in all subcases. Also, all four
437# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
438# even if it is to "0xUNSET".
439#
njn7fd6d382009-01-22 21:56:32 +0000440case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000441 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000442 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000443 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000444 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
445 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000446 valt_load_address_pri_norml="0x38000000"
447 valt_load_address_pri_inner="0x28000000"
448 valt_load_address_sec_norml="0xUNSET"
449 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000450 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000451 ;;
452 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000453 valt_load_address_sec_norml="0xUNSET"
454 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000455 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000456 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000457 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000458 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
459 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000460 valt_load_address_pri_norml="0x38000000"
461 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000462 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000463 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000464 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000465 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
466 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000467 valt_load_address_pri_norml="0x38000000"
468 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000469 else
njn7fd6d382009-01-22 21:56:32 +0000470 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000471 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000472 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
473 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000474 valt_load_address_pri_norml="0x38000000"
475 valt_load_address_pri_inner="0x28000000"
476 valt_load_address_sec_norml="0x38000000"
477 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000478 fi
njn377c43f2009-05-19 07:39:22 +0000479 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000480 ;;
481 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000482 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000483 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000484 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
485 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000486 valt_load_address_pri_norml="0x38000000"
487 valt_load_address_pri_inner="0x28000000"
488 valt_load_address_sec_norml="0xUNSET"
489 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000490 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000491 ;;
492 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000493 valt_load_address_sec_norml="0xUNSET"
494 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000495 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000496 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000497 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000498 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
499 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000500 valt_load_address_pri_norml="0x38000000"
501 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000502 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000503 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000504 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000505 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
506 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000507 valt_load_address_pri_norml="0x38000000"
508 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000509 else
njn7fd6d382009-01-22 21:56:32 +0000510 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000511 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000512 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
513 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000514 valt_load_address_pri_norml="0x38000000"
515 valt_load_address_pri_inner="0x28000000"
516 valt_load_address_sec_norml="0x38000000"
517 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000518 fi
njn377c43f2009-05-19 07:39:22 +0000519 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000520 ;;
njncc58cea2010-07-05 07:21:22 +0000521 # Darwin gets identified as 32-bit even when it supports 64-bit.
522 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
523 # all Macs support both 32-bit and 64-bit, so we just build both. If
524 # someone has a really old 32-bit only machine they can (hopefully?)
525 # build with --enable-only32bit. See bug 243362.
526 x86-darwin|amd64-darwin)
527 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000528 valt_load_address_sec_norml="0xUNSET"
529 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000530 if test x$vg_cv_only64bit = xyes; then
531 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000532 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000533 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
534 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000535 valt_load_address_pri_norml="0x138000000"
536 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000537 elif test x$vg_cv_only32bit = xyes; then
538 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000539 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000540 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
541 VGCONF_PLATFORM_SEC_CAPS=""
542 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000543 valt_load_address_pri_norml="0x38000000"
544 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000545 else
546 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000547 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000548 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
549 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000550 valt_load_address_pri_norml="0x138000000"
551 valt_load_address_pri_inner="0x128000000"
552 valt_load_address_sec_norml="0x38000000"
553 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000554 fi
njnf76d27a2009-05-28 01:53:07 +0000555 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
556 ;;
sewardj59570ff2010-01-01 11:59:33 +0000557 arm-linux)
558 VGCONF_ARCH_PRI="arm"
559 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
560 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000561 valt_load_address_pri_norml="0x38000000"
562 valt_load_address_pri_inner="0x28000000"
563 valt_load_address_sec_norml="0xUNSET"
564 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000565 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
566 ;;
sewardjf0c12502014-01-12 12:54:00 +0000567 arm64-linux)
568 valt_load_address_sec_norml="0xUNSET"
569 valt_load_address_sec_inner="0xUNSET"
570 if test x$vg_cv_only64bit = xyes; then
571 VGCONF_ARCH_PRI="arm64"
572 VGCONF_ARCH_SEC=""
573 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
574 VGCONF_PLATFORM_SEC_CAPS=""
575 valt_load_address_pri_norml="0x38000000"
576 valt_load_address_pri_inner="0x28000000"
577 elif test x$vg_cv_only32bit = xyes; then
578 VGCONF_ARCH_PRI="arm"
579 VGCONF_ARCH_SEC=""
580 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
581 VGCONF_PLATFORM_SEC_CAPS=""
582 valt_load_address_pri_norml="0x38000000"
583 valt_load_address_pri_inner="0x28000000"
584 else
585 VGCONF_ARCH_PRI="arm64"
586 VGCONF_ARCH_SEC="arm"
587 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
588 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
589 valt_load_address_pri_norml="0x38000000"
590 valt_load_address_pri_inner="0x28000000"
591 valt_load_address_sec_norml="0x38000000"
592 valt_load_address_sec_inner="0x28000000"
593 fi
594 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
595 ;;
sewardjb5b87402011-03-07 16:05:35 +0000596 s390x-linux)
597 VGCONF_ARCH_PRI="s390x"
598 VGCONF_ARCH_SEC=""
599 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
600 VGCONF_PLATFORM_SEC_CAPS=""
cborntraf4c46902013-10-23 16:23:30 +0000601 # To improve branch prediction hit rate we want to have
602 # the generated code close to valgrind (host) code
603 valt_load_address_pri_norml="0x800000000"
604 valt_load_address_pri_inner="0x810000000"
sewardjb5b87402011-03-07 16:05:35 +0000605 valt_load_address_sec_norml="0xUNSET"
606 valt_load_address_sec_inner="0xUNSET"
607 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
608 ;;
sewardj5db15402012-06-07 09:13:21 +0000609 mips32-linux)
610 VGCONF_ARCH_PRI="mips32"
611 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
612 VGCONF_PLATFORM_SEC_CAPS=""
613 valt_load_address_pri_norml="0x38000000"
614 valt_load_address_pri_inner="0x28000000"
615 valt_load_address_sec_norml="0xUNSET"
616 valt_load_address_sec_inner="0xUNSET"
617 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
petarj4df0bfc2013-02-27 23:17:33 +0000618 ;;
619 mips64-linux)
620 VGCONF_ARCH_PRI="mips64"
621 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
622 VGCONF_PLATFORM_SEC_CAPS=""
623 valt_load_address_pri_norml="0x38000000"
624 valt_load_address_pri_inner="0x28000000"
625 valt_load_address_sec_norml="0xUNSET"
626 valt_load_address_sec_inner="0xUNSET"
627 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj5db15402012-06-07 09:13:21 +0000628 ;;
nethercote888ecb72004-08-23 14:54:40 +0000629 *)
njn7fd6d382009-01-22 21:56:32 +0000630 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000631 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000632 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
633 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000634 valt_load_address_pri_norml="0xUNSET"
635 valt_load_address_pri_inner="0xUNSET"
636 valt_load_address_sec_norml="0xUNSET"
637 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000638 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000639 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000640 ;;
641esac
sewardjde4a1d02002-03-22 01:27:54 +0000642
njn7fd6d382009-01-22 21:56:32 +0000643#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000644
njn7fd6d382009-01-22 21:56:32 +0000645# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
646# defined.
647AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
648 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000649 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
650 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
651 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000652AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000653 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
654 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000655AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
656 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000657 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000658AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000659 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000660AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
sewardjf0c12502014-01-12 12:54:00 +0000661 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
662 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
663AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
664 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000665AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
666 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj5db15402012-06-07 09:13:21 +0000667AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
668 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
petarj4df0bfc2013-02-27 23:17:33 +0000669AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
670 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000671
njn7fd6d382009-01-22 21:56:32 +0000672# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
673# become defined.
674AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
675 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
676 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
677AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
678 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
679AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
680 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
681 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
682AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
683 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000684AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
sewardjf0c12502014-01-12 12:54:00 +0000685 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
686 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
687AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
688 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000689AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
690 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
691 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
sewardj5db15402012-06-07 09:13:21 +0000692AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
693 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
petarj4df0bfc2013-02-27 23:17:33 +0000694AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
695 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000696AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
697 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
698 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
699AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
700 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
701
702
sewardj72a2d802010-07-29 05:24:20 +0000703# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000704# Relies on the assumption that the primary and secondary targets are
705# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000706AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
707 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
708 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
709 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000710 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000711 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
sewardjf0c12502014-01-12 12:54:00 +0000712 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardj5db15402012-06-07 09:13:21 +0000713 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +0000714 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
715 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000716AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
717 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
718 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000719
720
njn7fd6d382009-01-22 21:56:32 +0000721# Sometimes, in the Makefile.am files, it's useful to know whether or not
722# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000723AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000724 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000725
philippef32cbe82012-05-18 16:48:20 +0000726dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
727dnl fallback definition
728dnl The macro is courtesy of Dave Hart:
729dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
730m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
731if test -z "$$1_TRUE"; then :
732 m4_n([$2])[]dnl
733m4_ifval([$3],
734[else
735 $3
736])dnl
737fi[]dnl
738])])
tomb637bad2005-11-08 12:28:35 +0000739
njn7fd6d382009-01-22 21:56:32 +0000740#----------------------------------------------------------------------------
741# Inner Valgrind?
742#----------------------------------------------------------------------------
743
njnd74b0ef2009-01-20 06:06:52 +0000744# Check if this should be built as an inner Valgrind, to be run within
745# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000746AC_SUBST(VALT_LOAD_ADDRESS_PRI)
747AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000748AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
749 [AC_ARG_ENABLE(inner,
750 [ --enable-inner enables self-hosting],
751 [vg_cv_inner=$enableval],
752 [vg_cv_inner=no])])
753if test "$vg_cv_inner" = yes; then
754 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000755 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
756 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000757else
njnea2d6fd2010-07-01 00:20:20 +0000758 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
759 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000760fi
761
762
njn7fd6d382009-01-22 21:56:32 +0000763#----------------------------------------------------------------------------
sewardj5db15402012-06-07 09:13:21 +0000764# Define MIPS_PAGE_SHIFT (--with-pagesize)
765#----------------------------------------------------------------------------
766AC_ARG_WITH(pagesize,
767 [ --with-pagesize= override detected page size (4, 16 or 64)],
768 [psize=$withval],
769 [psize=0]
770)
771
772if test "$psize" = "0"; then
773 psizer=`getconf PAGESIZE`
florian62477d22014-02-22 13:24:15 +0000774 psize=$((${psizer}/1024))
sewardj5db15402012-06-07 09:13:21 +0000775fi
776
777if test "$psize" = "4"; then
778 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
779elif test "$psize" = "16"; then
780 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
781elif test "$psize" = "64"; then
782 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
783else
784 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
785fi
786AC_MSG_RESULT([checking for Pagesize... ${psize}k])
787
sewardj5db15402012-06-07 09:13:21 +0000788
789#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000790# Extra fine-tuning of installation directories
791#----------------------------------------------------------------------------
792AC_ARG_WITH(tmpdir,
793 [ --with-tmpdir=PATH Specify path for temporary files],
794 tmpdir="$withval",
795 tmpdir="/tmp")
796AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
797
sewardj0ba37c92011-07-12 11:46:24 +0000798
sewardjcb495c82011-07-11 20:42:34 +0000799#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000800# Libc and suppressions
801#----------------------------------------------------------------------------
802# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000803AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000804
bart12e91122010-05-15 08:37:24 +0000805AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000806
bart12e91122010-05-15 08:37:24 +0000807if test x$ac_cv_header_features_h = xyes; then
808 rm -f conftest.$ac_ext
809 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000810#include <features.h>
bart12e91122010-05-15 08:37:24 +0000811#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
812glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000813#endif
bart12e91122010-05-15 08:37:24 +0000814_ACEOF
815 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
816fi
bartb7c3f082010-05-13 06:32:36 +0000817
njnf76d27a2009-05-28 01:53:07 +0000818# not really a version check
819AC_EGREP_CPP([DARWIN_LIBC], [
820#include <sys/cdefs.h>
821#if defined(__DARWIN_VERS_1050)
822 DARWIN_LIBC
823#endif
824],
825GLIBC_VERSION="darwin")
826
sewardjcb495c82011-07-11 20:42:34 +0000827# not really a version check
828AC_EGREP_CPP([BIONIC_LIBC], [
829#if defined(__ANDROID__)
830 BIONIC_LIBC
831#endif
832],
833GLIBC_VERSION="bionic")
834
835
dirk07596a22008-04-25 11:33:30 +0000836AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000837
dirk07596a22008-04-25 11:33:30 +0000838case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000839 2.2)
840 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000841 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000842 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
843 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000844 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000845 ;;
846
sewardj08c7f012002-10-07 23:56:55 +0000847 2.3)
848 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000849 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000850 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000851 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000852 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000853 ;;
854
njn781dba52005-06-30 04:06:38 +0000855 2.4)
856 AC_MSG_RESULT(2.4 family)
857 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000858 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000859 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000860 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000861 ;;
862
dirkaece45c2006-10-12 08:17:49 +0000863 2.5)
864 AC_MSG_RESULT(2.5 family)
865 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000866 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000867 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000868 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000869 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000870 2.6)
871 AC_MSG_RESULT(2.6 family)
872 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000873 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000874 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000875 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000876 ;;
877 2.7)
878 AC_MSG_RESULT(2.7 family)
879 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000880 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000881 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000882 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000883 ;;
dirk07596a22008-04-25 11:33:30 +0000884 2.8)
885 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000886 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000887 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
888 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
889 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
890 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000891 2.9)
892 AC_MSG_RESULT(2.9 family)
893 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
894 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
895 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
896 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
897 ;;
sewardj5d425e82009-02-01 19:01:11 +0000898 2.10)
899 AC_MSG_RESULT(2.10 family)
900 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
901 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
902 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
903 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
904 ;;
bart0fac7ff2009-11-15 19:11:19 +0000905 2.11)
906 AC_MSG_RESULT(2.11 family)
907 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
908 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
909 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
910 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000911 ;;
912 2.12)
913 AC_MSG_RESULT(2.12 family)
914 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
915 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
916 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
917 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000918 ;;
tomebd619b2011-02-10 09:09:09 +0000919 2.13)
920 AC_MSG_RESULT(2.13 family)
921 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
922 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
923 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
924 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
925 ;;
tomcc077412011-06-07 21:52:26 +0000926 2.14)
927 AC_MSG_RESULT(2.14 family)
928 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
929 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
930 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
931 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
932 ;;
dirke75fdeb2011-12-29 08:24:55 +0000933 2.15)
934 AC_MSG_RESULT(2.15 family)
935 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
936 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
937 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
938 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
939 ;;
sewardjc7188be2012-07-14 10:07:06 +0000940 2.16)
941 AC_MSG_RESULT(2.16 family)
942 AC_DEFINE([GLIBC_2_16], 1, [Define to 1 if you're using glibc 2.16.x])
943 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
944 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
945 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
946 ;;
tom3781ac12013-01-14 09:48:49 +0000947 2.17)
948 AC_MSG_RESULT(2.17 family)
949 AC_DEFINE([GLIBC_2_17], 1, [Define to 1 if you're using glibc 2.17.x])
950 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
951 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
952 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
953 ;;
mjw317f01b2013-08-21 14:47:52 +0000954 2.18)
955 AC_MSG_RESULT(2.18 family)
956 AC_DEFINE([GLIBC_2_18], 1, [Define to 1 if you're using glibc 2.18.x])
957 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
958 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
959 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
960 ;;
mjw28ae1992014-02-21 21:13:55 +0000961 2.19)
962 AC_MSG_RESULT(2.19 family)
963 AC_DEFINE([GLIBC_2_19], 1, [Define to 1 if you're using glibc 2.19.x])
964 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
965 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
966 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
967 ;;
njnf76d27a2009-05-28 01:53:07 +0000968 darwin)
969 AC_MSG_RESULT(Darwin)
970 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
971 # DEFAULT_SUPP set by kernel version check above.
972 ;;
sewardjcb495c82011-07-11 20:42:34 +0000973 bionic)
974 AC_MSG_RESULT(Bionic)
975 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
976 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
977 ;;
dirkaece45c2006-10-12 08:17:49 +0000978
sewardjde4a1d02002-03-22 01:27:54 +0000979 *)
bart12e91122010-05-15 08:37:24 +0000980 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
mjw28ae1992014-02-21 21:13:55 +0000981 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.19])
982 AC_MSG_ERROR([or Darwin or Bionic libc])
sewardjde4a1d02002-03-22 01:27:54 +0000983 ;;
984esac
985
dirk07596a22008-04-25 11:33:30 +0000986AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000987
sewardj414f3582008-07-18 20:46:00 +0000988
989# Add default suppressions for the X client libraries. Make no
990# attempt to detect whether such libraries are installed on the
991# build machine (or even if any X facilities are present); just
992# add the suppressions antidisirregardless.
993DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
994DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000995
sewardjd2f95a02011-05-11 16:04:28 +0000996# Add glibc and X11 suppressions for exp-sgcheck
997DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000998
sewardj2e10a682003-04-07 19:36:41 +0000999
njn7fd6d382009-01-22 21:56:32 +00001000#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +00001001# Platform variants?
1002#----------------------------------------------------------------------------
1003
1004# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1005# But there are times where we need a bit more control. The motivating
philippe5d5dd8e2012-08-05 00:08:25 +00001006# and currently only case is Android: this is almost identical to
dejanj9c6b05d2013-12-27 09:06:55 +00001007# {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1008# platform variant tags, which get passed in the compile as
1009# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
sewardjcb495c82011-07-11 20:42:34 +00001010#
1011# In almost all cases, the <variant> bit is "vanilla". But for Android
1012# it is "android" instead.
1013#
1014# Consequently (eg), plain arm-linux would build with
1015#
1016# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1017#
1018# whilst an Android build would have
1019#
1020# -DVGP_arm_linux -DVGPV_arm_linux_android
1021#
philippe5d5dd8e2012-08-05 00:08:25 +00001022# Same for x86. The setup of the platform variant is pushed relatively far
1023# down this file in order that we can inspect any of the variables set above.
sewardjcb495c82011-07-11 20:42:34 +00001024
1025# In the normal case ..
1026VGCONF_PLATVARIANT="vanilla"
1027
philippe5d5dd8e2012-08-05 00:08:25 +00001028# Android ?
1029if test "$GLIBC_VERSION" = "bionic";
sewardjcb495c82011-07-11 20:42:34 +00001030then
1031 VGCONF_PLATVARIANT="android"
1032fi
1033
1034AC_SUBST(VGCONF_PLATVARIANT)
1035
1036
1037# FIXME: do we also want to define automake variables
1038# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1039# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1040# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1041# do that. Problem is that we can't do and-ing in Makefile.am's, but
1042# that's what we'd need to do to use this, since what we'd want to write
1043# is something like
1044#
1045# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1046#
sewardj0ba37c92011-07-12 11:46:24 +00001047# Hmm. Can't think of a nice clean solution to this.
1048
1049AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1050 test x$VGCONF_PLATVARIANT = xvanilla)
1051AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1052 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +00001053
1054
1055#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +00001056# Checking for various library functions and other definitions
1057#----------------------------------------------------------------------------
1058
florian28db75c2012-12-08 19:26:03 +00001059# Check for AT_FDCWD
1060
1061AC_MSG_CHECKING([for AT_FDCWD])
1062AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1063#define _GNU_SOURCE
1064#include <fcntl.h>
1065#include <unistd.h>
1066]], [[
1067 int a = AT_FDCWD;
1068]])], [
1069ac_have_at_fdcwd=yes
1070AC_MSG_RESULT([yes])
1071], [
1072ac_have_at_fdcwd=no
florian28db75c2012-12-08 19:26:03 +00001073AC_MSG_RESULT([no])
1074])
1075
1076AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1077
sewardj24cf8df2012-12-14 10:30:57 +00001078# Check for stpncpy function definition in string.h
1079# This explicitly checks with _GNU_SOURCE defined since that is also
1080# used in the test case (some systems might define it without anyway
1081# since stpncpy is part of The Open Group Base Specifications Issue 7
1082# IEEE Std 1003.1-2008.
1083AC_MSG_CHECKING([for stpncpy])
1084AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1085#define _GNU_SOURCE
1086#include <string.h>
1087]], [[
1088 char *d;
1089 char *s;
1090 size_t n = 0;
1091 char *r = stpncpy(d, s, n);
1092]])], [
1093ac_have_gnu_stpncpy=yes
1094AC_MSG_RESULT([yes])
1095], [
1096ac_have_gnu_stpncpy=no
1097AC_MSG_RESULT([no])
1098])
1099
1100AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
florian28db75c2012-12-08 19:26:03 +00001101
philippe4e98f7c2013-08-03 20:34:58 +00001102# Check for PTRACE_GETREGS
1103
1104AC_MSG_CHECKING([for PTRACE_GETREGS])
1105AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1106#include <stddef.h>
1107#include <sys/ptrace.h>
1108#include <sys/user.h>
1109]], [[
1110 void *p;
1111 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1112]])], [
1113AC_MSG_RESULT([yes])
1114AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1115 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1116], [
1117AC_MSG_RESULT([no])
1118])
1119
1120
bart59e2f182008-04-28 16:22:53 +00001121# Check for CLOCK_MONOTONIC
1122
1123AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1124
bart417cf3e2011-10-22 09:21:24 +00001125AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +00001126#include <time.h>
bart417cf3e2011-10-22 09:21:24 +00001127]], [[
bart59e2f182008-04-28 16:22:53 +00001128 struct timespec t;
1129 clock_gettime(CLOCK_MONOTONIC, &t);
1130 return 0;
bart417cf3e2011-10-22 09:21:24 +00001131]])], [
bart59e2f182008-04-28 16:22:53 +00001132AC_MSG_RESULT([yes])
1133AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1134 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1135], [
1136AC_MSG_RESULT([no])
1137])
1138
bartfea06922008-05-03 09:12:15 +00001139
sewardj0c09bf02011-07-11 22:11:58 +00001140# Check for PTHREAD_RWLOCK_T
1141
1142AC_MSG_CHECKING([for pthread_rwlock_t])
1143
bart417cf3e2011-10-22 09:21:24 +00001144AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +00001145#define _GNU_SOURCE
1146#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001147]], [[
sewardj0c09bf02011-07-11 22:11:58 +00001148 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +00001149]])], [
sewardj0c09bf02011-07-11 22:11:58 +00001150AC_MSG_RESULT([yes])
1151AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1152 [Define to 1 if you have the `pthread_rwlock_t' type.])
1153], [
1154AC_MSG_RESULT([no])
1155])
1156
1157
bartfea06922008-05-03 09:12:15 +00001158# Check for PTHREAD_MUTEX_ADAPTIVE_NP
1159
1160AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1161
bart417cf3e2011-10-22 09:21:24 +00001162AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001163#define _GNU_SOURCE
1164#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001165]], [[
bartfea06922008-05-03 09:12:15 +00001166 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001167]])], [
bartfea06922008-05-03 09:12:15 +00001168AC_MSG_RESULT([yes])
1169AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1170 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1171], [
1172AC_MSG_RESULT([no])
1173])
1174
1175
1176# Check for PTHREAD_MUTEX_ERRORCHECK_NP
1177
1178AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1179
bart417cf3e2011-10-22 09:21:24 +00001180AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001181#define _GNU_SOURCE
1182#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001183]], [[
bartfea06922008-05-03 09:12:15 +00001184 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +00001185]])], [
bartfea06922008-05-03 09:12:15 +00001186AC_MSG_RESULT([yes])
1187AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1188 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1189], [
1190AC_MSG_RESULT([no])
1191])
1192
1193
1194# Check for PTHREAD_MUTEX_RECURSIVE_NP
1195
1196AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1197
bart417cf3e2011-10-22 09:21:24 +00001198AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001199#define _GNU_SOURCE
1200#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001201]], [[
bartfea06922008-05-03 09:12:15 +00001202 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001203]])], [
bartfea06922008-05-03 09:12:15 +00001204AC_MSG_RESULT([yes])
1205AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1206 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1207], [
1208AC_MSG_RESULT([no])
1209])
1210
1211
1212# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1213
1214AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1215
bart417cf3e2011-10-22 09:21:24 +00001216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001217#define _GNU_SOURCE
1218#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001219]], [[
bartfea06922008-05-03 09:12:15 +00001220 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1221 return 0;
bart417cf3e2011-10-22 09:21:24 +00001222]])], [
bartfea06922008-05-03 09:12:15 +00001223AC_MSG_RESULT([yes])
1224AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1225 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1226], [
1227AC_MSG_RESULT([no])
1228])
1229
1230
bart5e389f12008-04-05 12:53:15 +00001231# Check whether pthread_mutex_t has a member called __m_kind.
1232
bartb11355c2010-04-29 16:37:26 +00001233AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1234 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1235 1,
1236 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1237 ],
1238 [],
1239 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001240
1241
1242# Check whether pthread_mutex_t has a member called __data.__kind.
1243
bartb11355c2010-04-29 16:37:26 +00001244AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1245 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1246 1,
1247 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1248 ],
1249 [],
1250 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001251
1252
bart62c370e2008-05-12 18:50:51 +00001253# does this compiler support -maltivec and does it have the include file
1254# <altivec.h> ?
1255
1256AC_MSG_CHECKING([for Altivec])
1257
1258safe_CFLAGS=$CFLAGS
1259CFLAGS="-maltivec"
1260
bart417cf3e2011-10-22 09:21:24 +00001261AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001262#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001263]], [[
bart62c370e2008-05-12 18:50:51 +00001264 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001265]])], [
bart62c370e2008-05-12 18:50:51 +00001266ac_have_altivec=yes
1267AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001268AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001269 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001270], [
1271ac_have_altivec=no
1272AC_MSG_RESULT([no])
1273])
1274CFLAGS=$safe_CFLAGS
1275
sewardj0e342a02010-09-03 23:49:33 +00001276AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001277
1278
sewardjf34eb492011-04-15 11:57:05 +00001279# Check that both: the compiler supports -mvsx and that the assembler
1280# understands VSX instructions. If either of those doesn't work,
1281# conclude that we can't do VSX. NOTE: basically this is a kludge
1282# in that it conflates two things that should be separate -- whether
1283# the compiler understands the flag vs whether the assembler
1284# understands the opcodes. This really ought to be cleaned up
1285# and done properly, like it is for x86/x86_64.
1286
1287AC_MSG_CHECKING([for VSX])
1288
1289safe_CFLAGS=$CFLAGS
1290CFLAGS="-mvsx"
1291
bart417cf3e2011-10-22 09:21:24 +00001292AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001293#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001294]], [[
sewardjf34eb492011-04-15 11:57:05 +00001295 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001296 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001297]])], [
sewardjf34eb492011-04-15 11:57:05 +00001298ac_have_vsx=yes
1299AC_MSG_RESULT([yes])
1300], [
1301ac_have_vsx=no
1302AC_MSG_RESULT([no])
1303])
1304CFLAGS=$safe_CFLAGS
1305
1306AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1307
sewardj4e1c1912012-08-08 22:22:26 +00001308
sewardjb0ccb4d2012-04-02 10:22:05 +00001309AC_MSG_CHECKING([that assembler knows DFP])
1310
1311AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1312]], [[
1313 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001314 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001315]])], [
1316ac_asm_have_dfp=yes
1317AC_MSG_RESULT([yes])
1318], [
1319ac_asm_have_dfp=no
1320AC_MSG_RESULT([no])
1321])
1322
sewardj4e1c1912012-08-08 22:22:26 +00001323
sewardjb0ccb4d2012-04-02 10:22:05 +00001324AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1325safe_CFLAGS=$CFLAGS
1326CFLAGS="-mhard-dfp"
1327AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1328]], [[
1329 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001330 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001331]])], [
1332ac_gcc_have_dfp=yes
1333AC_MSG_RESULT([yes])
1334], [
1335ac_gcc_have_dfp=no
1336AC_MSG_RESULT([no])
1337])
1338
sewardjb0ccb4d2012-04-02 10:22:05 +00001339CFLAGS=$safe_CFLAGS
1340
1341AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001342
sewardj4e1c1912012-08-08 22:22:26 +00001343
florian46825982012-11-10 22:35:24 +00001344AC_MSG_CHECKING([that compiler knows DFP datatypes])
1345AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1346]], [[
1347 _Decimal64 x = 0.0DD;
1348]])], [
1349ac_gcc_have_dfp_type=yes
1350AC_MSG_RESULT([yes])
1351], [
1352ac_gcc_have_dfp_type=no
1353AC_MSG_RESULT([no])
1354])
1355
1356AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1357
carlldfbf2942013-08-12 18:04:22 +00001358# isa 2.07 checking
1359AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1360
1361AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1362]], [[
1363 __asm__ __volatile__("mtvsrd 1,2 ");
1364]])], [
1365ac_asm_have_isa_2_07=yes
1366AC_MSG_RESULT([yes])
1367], [
1368ac_asm_have_isa_2_07=no
1369AC_MSG_RESULT([no])
1370])
1371
1372AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
florian46825982012-11-10 22:35:24 +00001373
bart36dd85a2009-04-26 07:11:48 +00001374# Check for pthread_create@GLIBC2.0
1375AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1376
bart16e1c5a2009-04-26 07:38:53 +00001377safe_CFLAGS=$CFLAGS
1378CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001379AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001380extern int pthread_create_glibc_2_0(void*, const void*,
1381 void *(*)(void*), void*);
1382__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001383]], [[
bart276ed3a2009-05-10 15:41:45 +00001384#ifdef __powerpc__
1385/*
1386 * Apparently on PowerPC linking this program succeeds and generates an
1387 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1388 */
1389#error This test does not work properly on PowerPC.
1390#else
bart16e1c5a2009-04-26 07:38:53 +00001391 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001392#endif
bart16e1c5a2009-04-26 07:38:53 +00001393 return 0;
bart417cf3e2011-10-22 09:21:24 +00001394]])], [
bart36dd85a2009-04-26 07:11:48 +00001395ac_have_pthread_create_glibc_2_0=yes
1396AC_MSG_RESULT([yes])
1397AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1398 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1399], [
1400ac_have_pthread_create_glibc_2_0=no
1401AC_MSG_RESULT([no])
1402])
bart16e1c5a2009-04-26 07:38:53 +00001403CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001404
1405AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001406 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001407
1408
barta50aa8a2008-04-27 06:06:57 +00001409# Check for eventfd_t, eventfd() and eventfd_read()
1410AC_MSG_CHECKING([for eventfd()])
1411
bart417cf3e2011-10-22 09:21:24 +00001412AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001413#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001414]], [[
barta50aa8a2008-04-27 06:06:57 +00001415 eventfd_t ev;
1416 int fd;
1417
1418 fd = eventfd(5, 0);
1419 eventfd_read(fd, &ev);
1420 return 0;
bart417cf3e2011-10-22 09:21:24 +00001421]])], [
barta50aa8a2008-04-27 06:06:57 +00001422AC_MSG_RESULT([yes])
1423AC_DEFINE([HAVE_EVENTFD], 1,
1424 [Define to 1 if you have the `eventfd' function.])
1425AC_DEFINE([HAVE_EVENTFD_READ], 1,
1426 [Define to 1 if you have the `eventfd_read' function.])
1427], [
1428AC_MSG_RESULT([no])
1429])
1430
1431
florian24fefb62013-10-08 13:04:00 +00001432# Check whether compiler can process #include <thread> without errors
1433# clang 3.3 cannot process <thread> from e.g.
1434# gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1435
1436AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1437AC_LANG(C++)
1438safe_CXXFLAGS=$CXXFLAGS
1439CXXFLAGS=-std=c++0x
1440
1441AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1442#include <thread>
1443])],
1444[
1445ac_cxx_can_include_thread_header=yes
1446AC_MSG_RESULT([yes])
1447], [
1448ac_cxx_can_include_thread_header=no
1449AC_MSG_RESULT([no])
1450])
1451CXXFLAGS=$safe_CXXFLAGS
1452AC_LANG(C)
1453
1454AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1455
njn7fd6d382009-01-22 21:56:32 +00001456#----------------------------------------------------------------------------
1457# Checking for supported compiler flags.
1458#----------------------------------------------------------------------------
1459
sewardj535c50f2005-06-04 23:14:53 +00001460# does this compiler support -m32 ?
1461AC_MSG_CHECKING([if gcc accepts -m32])
1462
1463safe_CFLAGS=$CFLAGS
1464CFLAGS="-m32"
1465
bart417cf3e2011-10-22 09:21:24 +00001466AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001467 return 0;
bart417cf3e2011-10-22 09:21:24 +00001468]])], [
sewardj535c50f2005-06-04 23:14:53 +00001469FLAG_M32="-m32"
1470AC_MSG_RESULT([yes])
1471], [
1472FLAG_M32=""
1473AC_MSG_RESULT([no])
1474])
1475CFLAGS=$safe_CFLAGS
1476
1477AC_SUBST(FLAG_M32)
1478
1479
sewardj01262142006-01-04 01:20:28 +00001480# does this compiler support -m64 ?
1481AC_MSG_CHECKING([if gcc accepts -m64])
1482
1483safe_CFLAGS=$CFLAGS
1484CFLAGS="-m64"
1485
bart417cf3e2011-10-22 09:21:24 +00001486AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001487 return 0;
bart417cf3e2011-10-22 09:21:24 +00001488]])], [
sewardj01262142006-01-04 01:20:28 +00001489FLAG_M64="-m64"
1490AC_MSG_RESULT([yes])
1491], [
1492FLAG_M64=""
1493AC_MSG_RESULT([no])
1494])
1495CFLAGS=$safe_CFLAGS
1496
1497AC_SUBST(FLAG_M64)
1498
1499
dejanjf674e382014-02-18 16:40:25 +00001500# does this compiler support -march=mips32 (mips32 default) ?
1501AC_MSG_CHECKING([if gcc accepts -march=mips32])
1502
1503safe_CFLAGS=$CFLAGS
1504CFLAGS="$CFLAGS -march=mips32"
1505
1506AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1507 return 0;
1508]])], [
1509FLAG_MIPS32="-march=mips32"
1510AC_MSG_RESULT([yes])
1511], [
1512FLAG_MIPS32=""
1513AC_MSG_RESULT([no])
1514])
1515CFLAGS=$safe_CFLAGS
1516
1517AC_SUBST(FLAG_MIPS32)
1518
1519
1520# does this compiler support -march=mips64 (mips64 default) ?
1521AC_MSG_CHECKING([if gcc accepts -march=mips64])
1522
1523safe_CFLAGS=$CFLAGS
1524CFLAGS="$CFLAGS -march=mips64"
1525
1526AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1527 return 0;
1528]])], [
1529FLAG_MIPS64="-march=mips64"
1530AC_MSG_RESULT([yes])
1531], [
1532FLAG_MIPS64=""
1533AC_MSG_RESULT([no])
1534])
1535CFLAGS=$safe_CFLAGS
1536
1537AC_SUBST(FLAG_MIPS64)
1538
1539
petarj1546c7a2014-01-29 18:08:50 +00001540# does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1541AC_MSG_CHECKING([if gcc accepts -march=octeon])
1542
1543safe_CFLAGS=$CFLAGS
1544CFLAGS="$CFLAGS -march=octeon"
1545
1546AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1547 return 0;
1548]])], [
1549FLAG_OCTEON="-march=octeon"
1550AC_MSG_RESULT([yes])
1551], [
1552FLAG_OCTEON=""
1553AC_MSG_RESULT([no])
1554])
1555CFLAGS=$safe_CFLAGS
1556
1557AC_SUBST(FLAG_OCTEON)
1558
dejanjf674e382014-02-18 16:40:25 +00001559
petarj1546c7a2014-01-29 18:08:50 +00001560# does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1561AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1562
1563safe_CFLAGS=$CFLAGS
1564CFLAGS="$CFLAGS -march=octeon2"
1565
1566AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1567 return 0;
1568]])], [
1569FLAG_OCTEON2="-march=octeon2"
1570AC_MSG_RESULT([yes])
1571], [
1572FLAG_OCTEON2=""
1573AC_MSG_RESULT([no])
1574])
1575CFLAGS=$safe_CFLAGS
1576
1577AC_SUBST(FLAG_OCTEON2)
1578
1579
sewardj67f1fcc2005-07-03 10:41:02 +00001580# does this compiler support -mmmx ?
1581AC_MSG_CHECKING([if gcc accepts -mmmx])
1582
1583safe_CFLAGS=$CFLAGS
1584CFLAGS="-mmmx"
1585
bart417cf3e2011-10-22 09:21:24 +00001586AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001587 return 0;
bart417cf3e2011-10-22 09:21:24 +00001588]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001589FLAG_MMMX="-mmmx"
1590AC_MSG_RESULT([yes])
1591], [
1592FLAG_MMMX=""
1593AC_MSG_RESULT([no])
1594])
1595CFLAGS=$safe_CFLAGS
1596
1597AC_SUBST(FLAG_MMMX)
1598
1599
1600# does this compiler support -msse ?
1601AC_MSG_CHECKING([if gcc accepts -msse])
1602
1603safe_CFLAGS=$CFLAGS
1604CFLAGS="-msse"
1605
bart417cf3e2011-10-22 09:21:24 +00001606AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001607 return 0;
bart417cf3e2011-10-22 09:21:24 +00001608]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001609FLAG_MSSE="-msse"
1610AC_MSG_RESULT([yes])
1611], [
1612FLAG_MSSE=""
1613AC_MSG_RESULT([no])
1614])
1615CFLAGS=$safe_CFLAGS
1616
1617AC_SUBST(FLAG_MSSE)
1618
1619
sewardj5b754b42002-06-03 22:53:35 +00001620# does this compiler support -mpreferred-stack-boundary=2 ?
1621AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1622
daywalker3664f562003-10-17 13:43:46 +00001623safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001624CFLAGS="-mpreferred-stack-boundary=2"
1625
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]])], [
sewardj5b754b42002-06-03 22:53:35 +00001629PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001630AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001631], [
1632PREFERRED_STACK_BOUNDARY=""
1633AC_MSG_RESULT([no])
1634])
daywalker3664f562003-10-17 13:43:46 +00001635CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001636
1637AC_SUBST(PREFERRED_STACK_BOUNDARY)
1638
sewardj535c50f2005-06-04 23:14:53 +00001639
florianda8c1262012-11-18 14:39:11 +00001640# does this compiler support -Wno-pointer-sign ?
1641AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
1642
1643safe_CFLAGS=$CFLAGS
1644CFLAGS="-Wno-pointer-sign"
1645
1646AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1647 return 0;
1648]])], [
1649no_pointer_sign=yes
1650AC_MSG_RESULT([yes])
1651], [
1652no_pointer_sign=no
1653AC_MSG_RESULT([no])
1654])
1655CFLAGS=$safe_CFLAGS
1656
1657AM_CONDITIONAL(HAS_POINTER_SIGN_WARNING, test x$no_pointer_sign = xyes)
1658
1659
florian6bd9dc12012-11-23 16:17:43 +00001660# does this compiler support -Wno-write-strings ?
1661AC_MSG_CHECKING([if gcc accepts -Wwrite-strings])
1662
1663safe_CFLAGS=$CFLAGS
1664CFLAGS="-Wwrite-strings"
1665
1666AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1667 return 0;
1668]])], [
1669no_write_strings=yes
1670AC_MSG_RESULT([yes])
1671], [
1672no_write_strings=no
1673AC_MSG_RESULT([no])
1674])
1675CFLAGS=$safe_CFLAGS
1676
1677if test x$no_write_strings = xyes; then
1678 CFLAGS="$CFLAGS -Wwrite-strings"
floriand79b3bf2013-10-02 15:14:59 +00001679 CXXFLAGS="$CXXFLAGS -Wwrite-strings"
florian6bd9dc12012-11-23 16:17:43 +00001680fi
1681
1682AM_CONDITIONAL(HAS_WRITE_STRINGS_WARNING, test x$no_write_strings = xyes)
1683
barte026bd22009-07-04 12:17:07 +00001684# does this compiler support -Wno-empty-body ?
1685
1686AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1687
1688safe_CFLAGS=$CFLAGS
1689CFLAGS="-Wno-empty-body"
1690
bart417cf3e2011-10-22 09:21:24 +00001691AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001692 return 0;
bart417cf3e2011-10-22 09:21:24 +00001693]])], [
barte026bd22009-07-04 12:17:07 +00001694AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1695AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001696], [
barte026bd22009-07-04 12:17:07 +00001697AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1698AC_MSG_RESULT([no])
1699])
1700CFLAGS=$safe_CFLAGS
1701
1702
bart9d865fa2008-06-23 12:11:49 +00001703# does this compiler support -Wno-format-zero-length ?
1704
1705AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1706
1707safe_CFLAGS=$CFLAGS
1708CFLAGS="-Wno-format-zero-length"
1709
bart417cf3e2011-10-22 09:21:24 +00001710AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001711 return 0;
bart417cf3e2011-10-22 09:21:24 +00001712]])], [
bart9d865fa2008-06-23 12:11:49 +00001713AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1714AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001715], [
bart9d865fa2008-06-23 12:11:49 +00001716AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1717AC_MSG_RESULT([no])
1718])
1719CFLAGS=$safe_CFLAGS
1720
1721
bart8e216312011-05-15 17:05:36 +00001722# does this compiler support -Wno-nonnull ?
1723
1724AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1725
1726safe_CFLAGS=$CFLAGS
1727CFLAGS="-Wno-nonnull"
1728
bart417cf3e2011-10-22 09:21:24 +00001729AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001730 return 0;
bart417cf3e2011-10-22 09:21:24 +00001731]])], [
bart8e216312011-05-15 17:05:36 +00001732AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1733AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001734], [
bart8e216312011-05-15 17:05:36 +00001735AC_SUBST([FLAG_W_NO_NONNULL], [])
1736AC_MSG_RESULT([no])
1737])
1738CFLAGS=$safe_CFLAGS
1739
1740
1741# does this compiler support -Wno-overflow ?
1742
1743AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1744
1745safe_CFLAGS=$CFLAGS
1746CFLAGS="-Wno-overflow"
1747
bart417cf3e2011-10-22 09:21:24 +00001748AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001749 return 0;
bart417cf3e2011-10-22 09:21:24 +00001750]])], [
bart8e216312011-05-15 17:05:36 +00001751AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1752AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001753], [
bart8e216312011-05-15 17:05:36 +00001754AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1755AC_MSG_RESULT([no])
1756])
1757CFLAGS=$safe_CFLAGS
1758
1759
bartbf9b85c2009-08-12 12:55:56 +00001760# does this compiler support -Wno-uninitialized ?
1761
1762AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1763
1764safe_CFLAGS=$CFLAGS
1765CFLAGS="-Wno-uninitialized"
1766
bart417cf3e2011-10-22 09:21:24 +00001767AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001768 return 0;
bart417cf3e2011-10-22 09:21:24 +00001769]])], [
bartbf9b85c2009-08-12 12:55:56 +00001770AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1771AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001772], [
bartbf9b85c2009-08-12 12:55:56 +00001773AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1774AC_MSG_RESULT([no])
1775])
1776CFLAGS=$safe_CFLAGS
1777
1778
bart56730cd2008-05-11 06:41:46 +00001779# does this compiler support -Wextra or the older -W ?
1780
1781AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1782
1783safe_CFLAGS=$CFLAGS
1784CFLAGS="-Wextra"
1785
bart417cf3e2011-10-22 09:21:24 +00001786AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001787 return 0;
bart417cf3e2011-10-22 09:21:24 +00001788]])], [
bart56730cd2008-05-11 06:41:46 +00001789AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1790AC_MSG_RESULT([-Wextra])
1791], [
1792 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001794 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001795 ]])], [
bart56730cd2008-05-11 06:41:46 +00001796 AC_SUBST([FLAG_W_EXTRA], [-W])
1797 AC_MSG_RESULT([-W])
1798 ], [
1799 AC_SUBST([FLAG_W_EXTRA], [])
1800 AC_MSG_RESULT([not supported])
1801 ])
1802])
1803CFLAGS=$safe_CFLAGS
1804
1805
sewardja72c26d2007-05-01 13:44:08 +00001806# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001807AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001808
1809safe_CFLAGS=$CFLAGS
1810CFLAGS="-fno-stack-protector"
1811
bart417cf3e2011-10-22 09:21:24 +00001812AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001813 return 0;
bart417cf3e2011-10-22 09:21:24 +00001814]])], [
sewardja72c26d2007-05-01 13:44:08 +00001815no_stack_protector=yes
1816FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1817AC_MSG_RESULT([yes])
1818], [
1819no_stack_protector=no
1820FLAG_FNO_STACK_PROTECTOR=""
1821AC_MSG_RESULT([no])
1822])
1823CFLAGS=$safe_CFLAGS
1824
1825AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1826
1827if test x$no_stack_protector = xyes; then
1828 CFLAGS="$CFLAGS -fno-stack-protector"
floriand79b3bf2013-10-02 15:14:59 +00001829 CXXFLAGS="$CXXFLAGS -fno-stack-protector"
sewardja72c26d2007-05-01 13:44:08 +00001830fi
1831
1832
bart56730cd2008-05-11 06:41:46 +00001833# does this compiler support --param inline-unit-growth=... ?
1834
1835AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1836
1837safe_CFLAGS=$CFLAGS
1838CFLAGS="--param inline-unit-growth=900"
1839
bart417cf3e2011-10-22 09:21:24 +00001840AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001841 return 0;
bart417cf3e2011-10-22 09:21:24 +00001842]])], [
bart56730cd2008-05-11 06:41:46 +00001843AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1844 ["--param inline-unit-growth=900"])
1845AC_MSG_RESULT([yes])
1846], [
1847AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1848AC_MSG_RESULT([no])
1849])
1850CFLAGS=$safe_CFLAGS
1851
1852
sewardjd9350682012-04-05 07:55:47 +00001853# does this compiler support -gdwarf-4 -fdebug-types-section ?
1854
1855AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1856
1857safe_CFLAGS=$CFLAGS
1858CFLAGS="-gdwarf-4 -fdebug-types-section"
1859
1860AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1861 return 0;
1862]])], [
1863ac_have_dwarf4=yes
1864AC_MSG_RESULT([yes])
1865], [
1866ac_have_dwarf4=no
1867AC_MSG_RESULT([no])
1868])
1869AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1870CFLAGS=$safe_CFLAGS
1871
1872
florian3df02112013-10-04 11:35:50 +00001873# does this compiler support -gstabs ?
1874
1875AC_MSG_CHECKING([if gcc accepts -gstabs])
1876
1877safe_CFLAGS=$CFLAGS
1878CFLAGS="-gstabs"
1879AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1880 return 0;
1881]])], [
1882ac_have_gstabs=yes
1883AC_MSG_RESULT([yes])
1884], [
1885ac_have_gstabs=no
1886AC_MSG_RESULT([no])
1887])
1888CFLAGS=$safe_CFLAGS
1889AM_CONDITIONAL([HAVE_GSTABS], [test x$ac_have_gstabs = xyes])
1890
1891
1892# does this compiler support nested functions ?
1893
1894AC_MSG_CHECKING([if gcc accepts nested functions])
1895
1896AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1897 int foo() { return 1; }
1898 return foo();
1899]])], [
1900ac_have_nested_functions=yes
1901AC_MSG_RESULT([yes])
1902], [
1903ac_have_nested_functions=no
1904AC_MSG_RESULT([no])
1905])
1906AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1907
1908
1909# does this compiler support the 'p' constraint in ASM statements ?
1910
1911AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1912
1913AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1914 char *p;
1915 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1916]])], [
1917ac_have_asm_constraint_p=yes
1918AC_MSG_RESULT([yes])
1919], [
1920ac_have_asm_constraint_p=no
1921AC_MSG_RESULT([no])
1922])
1923AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1924
1925
sewardje4bc7032013-03-22 11:49:46 +00001926# We want to use use the -Ttext-segment option to the linker.
1927# GNU (bfd) ld supports this directly. Newer GNU gold linkers
1928# support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1929# semantics are NOT what we want (GNU gold -Ttext is fine).
1930#
1931# For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1932# will reside. -Ttext aligns just the .text section start (but not any
1933# other section).
1934#
1935# So test for -Ttext-segment which is supported by all bfd ld versions
1936# and use that if it exists. If it doesn't exist it must be an older
1937# version of gold and we can fall back to using -Ttext which has the
1938# right semantics.
bart699fbac2010-06-08 18:23:59 +00001939
sewardje4bc7032013-03-22 11:49:46 +00001940AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
bart699fbac2010-06-08 18:23:59 +00001941
1942safe_CFLAGS=$CFLAGS
mjw941277a2013-04-17 19:11:05 +00001943CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
bart699fbac2010-06-08 18:23:59 +00001944
bart8508c752010-06-10 06:26:21 +00001945AC_LINK_IFELSE(
mjw941277a2013-04-17 19:11:05 +00001946[AC_LANG_SOURCE([int _start () { return 0; }])],
bart699fbac2010-06-08 18:23:59 +00001947[
tom04ce9f52013-03-28 15:53:21 +00001948 linker_using_t_text="no"
sewardje4bc7032013-03-22 11:49:46 +00001949 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
bart699fbac2010-06-08 18:23:59 +00001950 AC_MSG_RESULT([yes])
1951], [
tom04ce9f52013-03-28 15:53:21 +00001952 linker_using_t_text="yes"
sewardje4bc7032013-03-22 11:49:46 +00001953 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
bart699fbac2010-06-08 18:23:59 +00001954 AC_MSG_RESULT([no])
1955])
1956CFLAGS=$safe_CFLAGS
1957
tom04ce9f52013-03-28 15:53:21 +00001958# If the linker only supports -Ttext (not -Ttext-segment) then we will
1959# have to strip any build-id ELF NOTEs from the staticly linked tools.
1960# Otherwise the build-id NOTE might end up at the default load address.
1961# (Pedantically if the linker is gold then -Ttext is fine, but newer
1962# gold versions also support -Ttext-segment. So just assume that unless
1963# we can use -Ttext-segment we need to strip the build-id NOTEs.
florian51b14ee2014-02-22 18:38:32 +00001964if test "x${linker_using_t_text}" = "xyes"; then
tom04ce9f52013-03-28 15:53:21 +00001965AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1966# does the linker support -Wl,--build-id=none ? Note, it's
1967# important that we test indirectly via whichever C compiler
1968# is selected, rather than testing /usr/bin/ld or whatever
1969# directly.
1970AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1971safe_CFLAGS=$CFLAGS
1972CFLAGS="-Wl,--build-id=none"
1973
1974AC_LINK_IFELSE(
1975[AC_LANG_PROGRAM([ ], [return 0;])],
1976[
1977 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1978 AC_MSG_RESULT([yes])
1979], [
1980 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1981 AC_MSG_RESULT([no])
1982])
1983else
1984AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
1985AC_SUBST([FLAG_NO_BUILD_ID], [""])
1986fi
1987CFLAGS=$safe_CFLAGS
bart699fbac2010-06-08 18:23:59 +00001988
sewardj00f1e622006-03-12 16:47:10 +00001989# does the ppc assembler support "mtocrf" et al?
1990AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1991
bart417cf3e2011-10-22 09:21:24 +00001992AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001993__asm__ __volatile__("mtocrf 4,0");
1994__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001995]])], [
sewardj00f1e622006-03-12 16:47:10 +00001996ac_have_as_ppc_mftocrf=yes
1997AC_MSG_RESULT([yes])
1998], [
1999ac_have_as_ppc_mftocrf=no
2000AC_MSG_RESULT([no])
2001])
2002if test x$ac_have_as_ppc_mftocrf = xyes ; then
2003 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2004fi
2005
2006
carll1e5fa2f2013-08-09 21:55:45 +00002007# does the ppc assembler support "lfdp" and other phased out floating point insns?
2008AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2009
2010AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2011 do { typedef struct {
2012 double hi;
2013 double lo;
2014 } dbl_pair_t;
2015 dbl_pair_t dbl_pair[3];
2016 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2017 } while (0)
2018]])], [
2019ac_have_as_ppc_fpPO=yes
2020AC_MSG_RESULT([yes])
2021], [
2022ac_have_as_ppc_fpPO=no
2023AC_MSG_RESULT([no])
2024])
2025if test x$ac_have_as_ppc_fpPO = xyes ; then
2026 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2027fi
2028
sewardjb5b87402011-03-07 16:05:35 +00002029CFLAGS=$safe_CFLAGS
2030
sewardjf0aabf82007-03-22 00:24:21 +00002031# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00002032# Note, this doesn't generate a C-level symbol. It generates a
2033# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00002034AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2035
bart417cf3e2011-10-22 09:21:24 +00002036AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00002037 do { long long int x;
2038 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2039 while (0)
bart417cf3e2011-10-22 09:21:24 +00002040]])], [
sewardjf0aabf82007-03-22 00:24:21 +00002041ac_have_as_sse3=yes
2042AC_MSG_RESULT([yes])
2043], [
2044ac_have_as_sse3=no
2045AC_MSG_RESULT([no])
2046])
sewardjfa18a262007-03-22 12:13:13 +00002047
2048AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00002049
2050
sewardj6d6da5b2008-02-09 12:07:40 +00002051# Ditto for SSSE3 instructions (note extra S)
2052# Note, this doesn't generate a C-level symbol. It generates a
2053# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2054AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2055
florianc443b962011-10-28 21:37:19 +00002056save_CFLAGS="$CFLAGS"
2057CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00002058AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00002059 do { long long int x;
2060 __asm__ __volatile__(
2061 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2062 while (0)
bart417cf3e2011-10-22 09:21:24 +00002063]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00002064ac_have_as_ssse3=yes
2065AC_MSG_RESULT([yes])
2066], [
2067ac_have_as_ssse3=no
2068AC_MSG_RESULT([no])
2069])
florianc443b962011-10-28 21:37:19 +00002070CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00002071
2072AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2073
2074
sewardj27d176a2011-01-17 11:15:48 +00002075# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2076# Note, this doesn't generate a C-level symbol. It generates a
2077# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00002078AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00002079AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00002080 do {
2081 __asm__ __volatile__(
2082 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2083 while (0)
bart417cf3e2011-10-22 09:21:24 +00002084]])], [
sewardje3ae8a32010-09-28 19:59:47 +00002085ac_have_as_pclmulqdq=yes
2086AC_MSG_RESULT([yes])
2087], [
2088ac_have_as_pclmulqdq=no
2089AC_MSG_RESULT([no])
2090])
2091
2092AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2093
2094
bart9bbe2bb2012-08-03 19:37:02 +00002095# does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2096# Note, this doesn't generate a C-level symbol. It generates a
2097# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2098AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2099AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2100 do {
2101 /*
2102 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2103 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2104 * xmm2 should be used.
2105 */
2106 __asm__ __volatile__(
2107 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2108 } while (0)
2109]])], [
2110ac_have_as_vpclmulqdq=yes
2111AC_MSG_RESULT([yes])
2112], [
2113ac_have_as_vpclmulqdq=no
2114AC_MSG_RESULT([no])
2115])
2116
2117AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2118
2119
sewardj27d176a2011-01-17 11:15:48 +00002120# does the x86/amd64 assembler understand the LZCNT instruction?
2121# Note, this doesn't generate a C-level symbol. It generates a
2122# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00002123AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2124
bart417cf3e2011-10-22 09:21:24 +00002125AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00002126 do {
sewardjc62291c2012-07-22 11:10:08 +00002127 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
bart55e438b2010-09-14 10:53:57 +00002128 } while (0)
bart417cf3e2011-10-22 09:21:24 +00002129]])], [
bart55e438b2010-09-14 10:53:57 +00002130 ac_have_as_lzcnt=yes
2131 AC_MSG_RESULT([yes])
2132], [
2133 ac_have_as_lzcnt=no
2134 AC_MSG_RESULT([no])
2135])
2136
2137AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2138
sewardj27d176a2011-01-17 11:15:48 +00002139
florian3df02112013-10-04 11:35:50 +00002140# does the x86/amd64 assembler understand the LOOPNEL instruction?
2141# Note, this doesn't generate a C-level symbol. It generates a
2142# automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2143AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2144
2145AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2146 do {
2147 __asm__ __volatile__("1: loopnel 1b\n");
2148 } while (0)
2149]])], [
2150 ac_have_as_loopnel=yes
2151 AC_MSG_RESULT([yes])
2152], [
2153 ac_have_as_loopnel=no
2154 AC_MSG_RESULT([no])
2155])
2156
2157AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2158
2159
2160# does the x86/amd64 assembler understand ADDR32 ?
2161# Note, this doesn't generate a C-level symbol. It generates a
2162# automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2163AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2164
2165AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2166 do {
2167 asm volatile ("addr32 rep movsb");
2168 } while (0)
2169]])], [
2170 ac_have_as_addr32=yes
2171 AC_MSG_RESULT([yes])
2172], [
2173 ac_have_as_addr32=no
2174 AC_MSG_RESULT([no])
2175])
2176
2177AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2178
2179
sewardj27d176a2011-01-17 11:15:48 +00002180# does the x86/amd64 assembler understand SSE 4.2 instructions?
2181# Note, this doesn't generate a C-level symbol. It generates a
2182# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2183AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2184
bart417cf3e2011-10-22 09:21:24 +00002185AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00002186 do { long long int x;
2187 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00002188 "crc32q %%r15,%%r15" : : : "r15" );
2189 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002190 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2191 __asm__ __volatile__(
2192 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
sewardj27d176a2011-01-17 11:15:48 +00002193 while (0)
bart417cf3e2011-10-22 09:21:24 +00002194]])], [
sewardj27d176a2011-01-17 11:15:48 +00002195ac_have_as_sse42=yes
2196AC_MSG_RESULT([yes])
2197], [
2198ac_have_as_sse42=no
2199AC_MSG_RESULT([no])
2200])
2201
2202AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2203
2204
sewardj9fb31ca2012-06-05 00:31:49 +00002205# does the x86/amd64 assembler understand AVX instructions?
2206# Note, this doesn't generate a C-level symbol. It generates a
2207# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2208AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2209
2210AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2211 do { long long int x;
2212 __asm__ __volatile__(
2213 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2214 __asm__ __volatile__(
2215 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2216 while (0)
2217]])], [
2218ac_have_as_avx=yes
2219AC_MSG_RESULT([yes])
2220], [
2221ac_have_as_avx=no
2222AC_MSG_RESULT([no])
2223])
2224
2225AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2226
2227
sewardjfda50af2013-03-27 11:43:20 +00002228# does the x86/amd64 assembler understand AVX2 instructions?
2229# Note, this doesn't generate a C-level symbol. It generates a
2230# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2231AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2232
2233AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2234 do { long long int x;
2235 __asm__ __volatile__(
2236 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2237 __asm__ __volatile__(
2238 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2239 while (0)
2240]])], [
2241ac_have_as_avx2=yes
2242AC_MSG_RESULT([yes])
2243], [
2244ac_have_as_avx2=no
2245AC_MSG_RESULT([no])
2246])
2247
2248AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2249
2250
sewardj9ea080b2013-10-16 08:53:07 +00002251# does the x86/amd64 assembler understand TSX instructions and
2252# the XACQUIRE/XRELEASE prefixes?
florian364c3652013-09-30 16:32:53 +00002253# Note, this doesn't generate a C-level symbol. It generates a
2254# automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2255AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2256
2257AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2258 do {
2259 __asm__ __volatile__(
2260 " xbegin Lfoo \n\t"
sewardj9ea080b2013-10-16 08:53:07 +00002261 "Lfoo: xend \n\t"
2262 " xacquire lock incq 0(%rsp) \n\t"
2263 " xrelease lock incq 0(%rsp) \n"
2264 );
florian364c3652013-09-30 16:32:53 +00002265 } while (0)
2266]])], [
2267ac_have_as_tsx=yes
2268AC_MSG_RESULT([yes])
2269], [
2270ac_have_as_tsx=no
2271AC_MSG_RESULT([no])
2272])
2273
2274AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2275
2276
sewardjfda50af2013-03-27 11:43:20 +00002277# does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2278# Note, this doesn't generate a C-level symbol. It generates a
2279# automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2280AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2281
2282AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2283 do { unsigned int h, l;
2284 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002285 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
sewardjfda50af2013-03-27 11:43:20 +00002286 __asm__ __volatile__(
sewardje222efc2013-03-27 21:59:21 +00002287 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
sewardjfda50af2013-03-27 11:43:20 +00002288 while (0)
2289]])], [
2290ac_have_as_bmi=yes
2291AC_MSG_RESULT([yes])
2292], [
2293ac_have_as_bmi=no
2294AC_MSG_RESULT([no])
2295])
2296
2297AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2298
2299
2300# does the x86/amd64 assembler understand FMA instructions?
2301# Note, this doesn't generate a C-level symbol. It generates a
2302# automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2303AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2304
2305AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2306 do { unsigned int h, l;
2307 __asm__ __volatile__(
2308 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2309 __asm__ __volatile__(
2310 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2311 __asm__ __volatile__(
2312 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2313 while (0)
2314]])], [
2315ac_have_as_fma=yes
2316AC_MSG_RESULT([yes])
2317], [
2318ac_have_as_fma=no
2319AC_MSG_RESULT([no])
2320])
2321
2322AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2323
2324
sewardjb08d84d2012-07-16 08:23:26 +00002325# does the x86/amd64 assembler understand MOVBE?
2326# Note, this doesn't generate a C-level symbol. It generates a
2327# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2328AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2329
2330AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2331 do { long long int x;
2332 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00002333 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
sewardjb08d84d2012-07-16 08:23:26 +00002334 while (0)
2335]])], [
2336ac_have_as_movbe=yes
2337AC_MSG_RESULT([yes])
2338], [
2339ac_have_as_movbe=no
2340AC_MSG_RESULT([no])
2341])
2342
2343AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2344
2345
florian251c2f92012-07-05 21:21:37 +00002346# Does the C compiler support the "ifunc" attribute
2347# Note, this doesn't generate a C-level symbol. It generates a
2348# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2349AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2350
florianf78a5032012-07-06 09:17:29 +00002351AC_LINK_IFELSE([AC_LANG_SOURCE([[
2352static void mytest(void) {}
2353
2354static void (*resolve_test(void))(void)
2355{
2356 return (void (*)(void))&mytest;
2357}
2358
2359void test(void) __attribute__((ifunc("resolve_test")));
2360
2361int main()
2362{
2363 test();
2364 return 0;
2365}
florian251c2f92012-07-05 21:21:37 +00002366]])], [
2367ac_have_ifunc_attr=yes
2368AC_MSG_RESULT([yes])
2369], [
2370ac_have_ifunc_attr=no
2371AC_MSG_RESULT([no])
2372])
2373
2374AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2375
2376
sewardje089f012010-10-13 21:47:29 +00002377# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2378# when building the tool executables. I think we should get rid of it.
2379#
sewardjb5f6f512005-03-10 23:59:00 +00002380# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00002381AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2382 [[return foo;]])],
2383 [vg_cv_linktime_tls=yes],
2384 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00002385# Native compilation: check whether running a program using TLS succeeds.
2386# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2387# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00002388# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00002389AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2390 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2391 [vg_cv_tls=$enableval],
2392 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2393 [[return foo;]])],
2394 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00002395 [vg_cv_tls=no],
2396 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00002397
2398if test "$vg_cv_tls" = yes; then
2399AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2400fi
sewardj5b754b42002-06-03 22:53:35 +00002401
sewardj535c50f2005-06-04 23:14:53 +00002402
njn7fd6d382009-01-22 21:56:32 +00002403#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00002404# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00002405#----------------------------------------------------------------------------
2406
sewardjde4a1d02002-03-22 01:27:54 +00002407AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00002408AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00002409 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00002410 endian.h \
2411 mqueue.h \
2412 sys/endian.h \
2413 sys/epoll.h \
2414 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00002415 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00002416 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00002417 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00002418 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00002419 sys/syscall.h \
2420 sys/time.h \
2421 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00002422 ])
sewardjde4a1d02002-03-22 01:27:54 +00002423
bart818f17e2011-09-17 06:24:49 +00002424# Verify whether the <linux/futex.h> header is usable.
2425AC_MSG_CHECKING([if <linux/futex.h> is usable])
2426
sewardjc12486b2012-12-17 14:46:48 +00002427save_CFLAGS="$CFLAGS"
2428CFLAGS="$CFLAGS -D__user="
bart417cf3e2011-10-22 09:21:24 +00002429AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00002430#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00002431]], [[
bart818f17e2011-09-17 06:24:49 +00002432 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00002433]])], [
bart78bfc712011-12-08 16:14:59 +00002434ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00002435AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2436 [Define to 1 if you have a usable <linux/futex.h> header file.])
2437AC_MSG_RESULT([yes])
2438], [
bart78bfc712011-12-08 16:14:59 +00002439ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00002440AC_MSG_RESULT([no])
2441])
sewardjc12486b2012-12-17 14:46:48 +00002442CFLAGS="$save_CFLAGS"
2443
bart818f17e2011-09-17 06:24:49 +00002444
njn7fd6d382009-01-22 21:56:32 +00002445#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002446# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00002447#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002448AC_TYPE_UID_T
2449AC_TYPE_OFF_T
2450AC_TYPE_SIZE_T
2451AC_HEADER_TIME
2452
sewardj535c50f2005-06-04 23:14:53 +00002453
njn7fd6d382009-01-22 21:56:32 +00002454#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002455# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00002456#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00002457AC_FUNC_MEMCMP
2458AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00002459
bart26288e42011-04-03 16:46:01 +00002460AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00002461AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00002462
bartf5ceec82008-04-26 07:45:10 +00002463AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00002464 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00002465 epoll_create \
2466 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00002467 klogctl \
bartf5ceec82008-04-26 07:45:10 +00002468 mallinfo \
2469 memchr \
2470 memset \
2471 mkdir \
njnf76d27a2009-05-28 01:53:07 +00002472 mremap \
bartf5ceec82008-04-26 07:45:10 +00002473 ppoll \
bart6d45e922009-01-20 13:45:38 +00002474 pthread_barrier_init \
2475 pthread_condattr_setclock \
2476 pthread_mutex_timedlock \
2477 pthread_rwlock_timedrdlock \
2478 pthread_rwlock_timedwrlock \
2479 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00002480 pthread_yield \
florianc5325ef2013-09-17 20:15:36 +00002481 pthread_setname_np \
bartd1f724c2009-08-26 18:11:18 +00002482 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00002483 semtimedop \
2484 signalfd \
njn6cc22472009-03-16 03:46:48 +00002485 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00002486 strchr \
2487 strdup \
2488 strpbrk \
2489 strrchr \
2490 strstr \
barta72a27b2010-04-29 06:22:17 +00002491 syscall \
bartf5ceec82008-04-26 07:45:10 +00002492 utimensat \
tom9e4b6362012-02-10 09:39:37 +00002493 process_vm_readv \
2494 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00002495 ])
sewardjde4a1d02002-03-22 01:27:54 +00002496
bart623eec32008-07-29 17:54:49 +00002497# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2498# libraries with any shared object and/or executable. This is NOT what we
2499# want for e.g. vgpreload_core-x86-linux.so
2500LIBS=""
sewardj80637752006-03-02 13:48:21 +00002501
bart6d45e922009-01-20 13:45:38 +00002502AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2503 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00002504AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2505 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00002506AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2507 [test x$ac_cv_func_pthread_spin_lock = xyes])
florianc5325ef2013-09-17 20:15:36 +00002508AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2509 [test x$ac_cv_func_pthread_setname_np = xyes])
bart6d45e922009-01-20 13:45:38 +00002510
petarjc37cea62013-06-02 18:08:04 +00002511if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2512 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
petarj6d79b742012-12-20 18:56:57 +00002513 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
petarjc37cea62013-06-02 18:08:04 +00002514 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
petarj6d79b742012-12-20 18:56:57 +00002515fi
njn7fd6d382009-01-22 21:56:32 +00002516
2517#----------------------------------------------------------------------------
2518# MPI checks
2519#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00002520# Do we have a useable MPI setup on the primary and/or secondary targets?
2521# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00002522# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00002523# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00002524# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00002525MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00002526
sewardje9fa5062006-03-12 18:29:18 +00002527mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00002528if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00002529 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj5db15402012-06-07 09:13:21 +00002530 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
petarj4df0bfc2013-02-27 23:17:33 +00002531 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2532 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002533 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00002534elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002535 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjf0c12502014-01-12 12:54:00 +00002536 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00002537 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00002538 mflag_primary=$FLAG_M64
philippef7c54332012-05-17 15:32:54 +00002539elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2540 mflag_primary="$FLAG_M32 -arch i386"
2541elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2542 mflag_primary="$FLAG_M64 -arch x86_64"
sewardje9fa5062006-03-12 18:29:18 +00002543fi
2544
sewardj03d86f22006-10-17 00:57:24 +00002545mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00002546if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2547 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00002548 mflag_secondary=$FLAG_M32
philippef7c54332012-05-17 15:32:54 +00002549elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2550 mflag_secondary="$FLAG_M32 -arch i386"
sewardj03d86f22006-10-17 00:57:24 +00002551fi
2552
2553
sewardj0ad46092006-03-02 17:09:16 +00002554AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00002555 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00002556 MPI_CC=$withval
2557)
sewardj03d86f22006-10-17 00:57:24 +00002558AC_SUBST(MPI_CC)
2559
philippef7c54332012-05-17 15:32:54 +00002560## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2561## use these values in the check for a functioning mpicc.
2562##
2563## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2564## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2565AM_COND_IF([VGCONF_OS_IS_LINUX],
2566 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2567 LDFLAGS_MPI="-fpic -shared"])
2568AM_COND_IF([VGCONF_OS_IS_DARWIN],
2569 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2570 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2571
2572AC_SUBST([CFLAGS_MPI])
2573AC_SUBST([LDFLAGS_MPI])
2574
2575
sewardj03d86f22006-10-17 00:57:24 +00002576## See if MPI_CC works for the primary target
2577##
2578AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00002579saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00002580saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00002581CC=$MPI_CC
philippef7c54332012-05-17 15:32:54 +00002582CFLAGS="$CFLAGS_MPI $mflag_primary"
2583saved_LDFLAGS="$LDFLAGS"
2584LDFLAGS="$LDFLAGS_MPI $mflag_primary"
bart417cf3e2011-10-22 09:21:24 +00002585AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00002586#include <mpi.h>
2587#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002588]], [[
philippef7c54332012-05-17 15:32:54 +00002589 int ni, na, nd, comb;
sewardjde4f3842006-03-09 02:41:41 +00002590 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002591 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2592 r |= MPI_Finalize();
sewardjde4f3842006-03-09 02:41:41 +00002593 return r;
bart417cf3e2011-10-22 09:21:24 +00002594]])], [
sewardj03d86f22006-10-17 00:57:24 +00002595ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00002596AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00002597], [
sewardj03d86f22006-10-17 00:57:24 +00002598ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00002599AC_MSG_RESULT([no])
2600])
sewardj0ad46092006-03-02 17:09:16 +00002601CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00002602CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002603LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002604AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00002605
sewardj03d86f22006-10-17 00:57:24 +00002606## See if MPI_CC works for the secondary target. Complication: what if
2607## there is no secondary target? We need this to then fail.
2608## Kludge this by making MPI_CC something which will surely fail in
2609## such a case.
2610##
2611AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2612saved_CC=$CC
2613saved_CFLAGS=$CFLAGS
philippef7c54332012-05-17 15:32:54 +00002614saved_LDFLAGS="$LDFLAGS"
2615LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
njn7fd6d382009-01-22 21:56:32 +00002616if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00002617 CC="$MPI_CC this will surely fail"
2618else
2619 CC=$MPI_CC
2620fi
philippef7c54332012-05-17 15:32:54 +00002621CFLAGS="$CFLAGS_MPI $mflag_secondary"
bart417cf3e2011-10-22 09:21:24 +00002622AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00002623#include <mpi.h>
2624#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002625]], [[
philippef7c54332012-05-17 15:32:54 +00002626 int ni, na, nd, comb;
sewardj03d86f22006-10-17 00:57:24 +00002627 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002628 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2629 r |= MPI_Finalize();
sewardj03d86f22006-10-17 00:57:24 +00002630 return r;
bart417cf3e2011-10-22 09:21:24 +00002631]])], [
sewardj03d86f22006-10-17 00:57:24 +00002632ac_have_mpi2_sec=yes
2633AC_MSG_RESULT([yes, $MPI_CC])
2634], [
2635ac_have_mpi2_sec=no
2636AC_MSG_RESULT([no])
2637])
2638CC=$saved_CC
2639CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002640LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002641AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00002642
2643
njn7fd6d382009-01-22 21:56:32 +00002644#----------------------------------------------------------------------------
2645# Other library checks
2646#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00002647# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00002648# tests are present because Drd has some regression tests that use
2649# these packages. All regression test programs all compiled only
2650# for the primary target. And so it is important that the configure
2651# checks that follow, use the correct -m32 or -m64 flag for the
2652# primary target (called $mflag_primary). Otherwise, we can end up
2653# in a situation (eg) where, on amd64-linux, the test for Boost checks
2654# for usable 64-bit Boost facilities, but because we are doing a 32-bit
2655# only build (meaning, the primary target is x86-linux), the build
2656# of the regtest programs that use Boost fails, because they are
2657# build as 32-bit (IN THIS EXAMPLE).
2658#
2659# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2660# NEEDED BY THE REGRESSION TEST PROGRAMS.
2661
2662
sewardj493c4ef2008-12-13 16:45:19 +00002663# Check whether the boost library 1.35 or later has been installed.
2664# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2665
2666AC_MSG_CHECKING([for boost])
2667
2668AC_LANG(C++)
2669safe_CXXFLAGS=$CXXFLAGS
bart7129c722012-04-18 18:34:22 +00002670CXXFLAGS="$mflag_primary"
2671safe_LIBS="$LIBS"
2672LIBS="-lboost_thread-mt $LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002673
bart128fc522011-03-12 10:36:35 +00002674AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002675#include <boost/thread.hpp>
2676static void thread_func(void)
2677{ }
2678int main(int argc, char** argv)
2679{
2680 boost::thread t(thread_func);
2681 return 0;
2682}
bart128fc522011-03-12 10:36:35 +00002683])],
sewardj493c4ef2008-12-13 16:45:19 +00002684[
2685ac_have_boost_1_35=yes
2686AC_SUBST([BOOST_CFLAGS], [])
bartbb31f2d2012-04-18 18:42:34 +00002687AC_SUBST([BOOST_LIBS], [-lboost_thread-mt])
sewardj493c4ef2008-12-13 16:45:19 +00002688AC_MSG_RESULT([yes])
2689], [
2690ac_have_boost_1_35=no
2691AC_MSG_RESULT([no])
2692])
2693
bart7129c722012-04-18 18:34:22 +00002694LIBS="$safe_LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002695CXXFLAGS=$safe_CXXFLAGS
2696AC_LANG(C)
2697
2698AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2699
2700
2701# does this compiler support -fopenmp, does it have the include file
2702# <omp.h> and does it have libgomp ?
2703
2704AC_MSG_CHECKING([for OpenMP])
2705
2706safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00002707CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00002708
bart128fc522011-03-12 10:36:35 +00002709AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002710#include <omp.h>
2711int main(int argc, char** argv)
2712{
2713 omp_set_dynamic(0);
2714 return 0;
2715}
bart128fc522011-03-12 10:36:35 +00002716])],
sewardj493c4ef2008-12-13 16:45:19 +00002717[
2718ac_have_openmp=yes
2719AC_MSG_RESULT([yes])
2720], [
2721ac_have_openmp=no
2722AC_MSG_RESULT([no])
2723])
2724CFLAGS=$safe_CFLAGS
2725
2726AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2727
2728
bart78bfc712011-12-08 16:14:59 +00002729# does this compiler have built-in functions for atomic memory access for the
2730# primary target ?
2731AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00002732
2733safe_CFLAGS=$CFLAGS
2734CFLAGS="$mflag_primary"
2735
bart417cf3e2011-10-22 09:21:24 +00002736AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00002737 int variable = 1;
2738 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2739 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002740]])], [
bartb4ff7822011-12-10 19:48:04 +00002741 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00002742 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00002743 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 +00002744], [
bartb4ff7822011-12-10 19:48:04 +00002745 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00002746 AC_MSG_RESULT([no])
2747])
2748
2749CFLAGS=$safe_CFLAGS
2750
bartb4ff7822011-12-10 19:48:04 +00002751AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2752 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00002753
bart78bfc712011-12-08 16:14:59 +00002754
2755# does this compiler have built-in functions for atomic memory access for the
2756# secondary target ?
2757
2758if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2759
2760AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2761
2762safe_CFLAGS=$CFLAGS
2763CFLAGS="$mflag_secondary"
2764
2765AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2766 int variable = 1;
2767 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2768]])], [
2769 ac_have_builtin_atomic_secondary=yes
2770 AC_MSG_RESULT([yes])
2771], [
2772 ac_have_builtin_atomic_secondary=no
2773 AC_MSG_RESULT([no])
2774])
2775
2776CFLAGS=$safe_CFLAGS
2777
2778fi
2779
2780AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2781 [test x$ac_have_builtin_atomic_secondary = xyes])
2782
bart1e856ea2011-12-17 12:53:23 +00002783# does this compiler have built-in functions for atomic memory access on
2784# 64-bit integers for all targets ?
2785
2786AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2787
2788AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2789 #include <stdint.h>
2790]], [[
2791 uint64_t variable = 1;
2792 return __sync_add_and_fetch(&variable, 1)
2793]])], [
2794 ac_have_builtin_atomic64_primary=yes
2795], [
2796 ac_have_builtin_atomic64_primary=no
2797])
2798
2799if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2800
2801safe_CFLAGS=$CFLAGS
2802CFLAGS="$mflag_secondary"
2803
2804AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2805 #include <stdint.h>
2806]], [[
2807 uint64_t variable = 1;
2808 return __sync_add_and_fetch(&variable, 1)
2809]])], [
2810 ac_have_builtin_atomic64_secondary=yes
2811], [
2812 ac_have_builtin_atomic64_secondary=no
2813])
2814
2815CFLAGS=$safe_CFLAGS
2816
2817fi
2818
2819if test x$ac_have_builtin_atomic64_primary = xyes && \
2820 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2821 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2822 AC_MSG_RESULT([yes])
2823 ac_have_builtin_atomic64=yes
2824else
2825 AC_MSG_RESULT([no])
2826 ac_have_builtin_atomic64=no
2827fi
2828
2829AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2830 [test x$ac_have_builtin_atomic64 = xyes])
2831
bart78bfc712011-12-08 16:14:59 +00002832
barte8740422011-03-24 20:27:54 +00002833# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002834AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002835
2836safe_CXXFLAGS=$CXXFLAGS
2837CXXFLAGS="$mflag_primary"
2838
2839AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002840AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002841 int variable = 1;
2842 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2843 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002844]])], [
barte8740422011-03-24 20:27:54 +00002845 ac_have_builtin_atomic_cxx=yes
2846 AC_MSG_RESULT([yes])
2847 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 +00002848], [
barte8740422011-03-24 20:27:54 +00002849 ac_have_builtin_atomic_cxx=no
2850 AC_MSG_RESULT([no])
2851])
2852AC_LANG_POP(C++)
2853
2854CXXFLAGS=$safe_CXXFLAGS
2855
2856AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002857
bart78bfc712011-12-08 16:14:59 +00002858
2859if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002860 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002861 ac_enable_linux_ticket_lock_primary=yes
2862fi
2863AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2864 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2865
2866if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2867 -a x$ac_have_usable_linux_futex_h = xyes \
2868 -a x$ac_have_builtin_atomic_secondary = xyes; then
2869 ac_enable_linux_ticket_lock_secondary=yes
2870fi
2871AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2872 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2873
2874
bartf68af882011-12-10 19:42:05 +00002875# does libstdc++ support annotating shared pointers ?
2876AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2877
floriand79b3bf2013-10-02 15:14:59 +00002878safe_CXXFLAGS=$CXXFLAGS
bartf68af882011-12-10 19:42:05 +00002879CXXFLAGS="-std=c++0x"
2880
2881AC_LANG_PUSH(C++)
2882AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2883 #include <memory>
2884]], [[
2885 std::shared_ptr<int> p
2886]])], [
2887 ac_have_shared_ptr=yes
2888], [
2889 ac_have_shared_ptr=no
2890])
2891if test x$ac_have_shared_ptr = xyes; then
2892 # If compilation of the program below fails because of a syntax error
2893 # triggered by substituting one of the annotation macros then that
2894 # means that libstdc++ supports these macros.
2895 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2896 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2897 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2898 #include <memory>
2899 ]], [[
2900 std::shared_ptr<int> p
2901 ]])], [
2902 ac_have_shared_pointer_annotation=no
2903 AC_MSG_RESULT([no])
2904 ], [
2905 ac_have_shared_pointer_annotation=yes
2906 AC_MSG_RESULT([yes])
2907 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2908 [Define to 1 if libstd++ supports annotating shared pointers])
2909 ])
2910else
2911 ac_have_shared_pointer_annotation=no
2912 AC_MSG_RESULT([no])
2913fi
2914AC_LANG_POP(C++)
2915
2916CXXFLAGS=$safe_CXXFLAGS
2917
2918AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2919 [test x$ac_have_shared_pointer_annotation = xyes])
2920
2921
njn7fd6d382009-01-22 21:56:32 +00002922#----------------------------------------------------------------------------
2923# Ok. We're done checking.
2924#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002925
njn8b68b642009-06-24 00:37:09 +00002926# Nb: VEX/Makefile is generated from Makefile.vex.in.
2927AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002928 Makefile
njn8b68b642009-06-24 00:37:09 +00002929 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002930 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002931 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002932 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002933 docs/Makefile
2934 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002935 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002936 perf/Makefile
2937 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002938 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002939 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002940 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002941 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002942 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002943 memcheck/Makefile
2944 memcheck/tests/Makefile
floriane42cca52013-08-29 17:59:27 +00002945 memcheck/tests/common/Makefile
njnc6168192004-11-29 13:54:10 +00002946 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002947 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002948 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002949 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002950 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002951 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002952 memcheck/tests/ppc32/Makefile
2953 memcheck/tests/ppc64/Makefile
florian0bb707e2012-05-30 20:46:58 +00002954 memcheck/tests/s390x/Makefile
florianbb913cd2012-08-28 16:50:39 +00002955 memcheck/tests/vbit-test/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002956 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002957 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002958 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002959 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002960 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002961 callgrind/Makefile
2962 callgrind/callgrind_annotate
2963 callgrind/callgrind_control
2964 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002965 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002966 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002967 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002968 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002969 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002970 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002971 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002972 none/Makefile
2973 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002974 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002975 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002976 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002977 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002978 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002979 none/tests/s390x/Makefile
sewardj5db15402012-06-07 09:13:21 +00002980 none/tests/mips32/Makefile
petarj8bea8672013-05-10 13:14:54 +00002981 none/tests/mips64/Makefile
njn0458a122009-02-13 06:23:46 +00002982 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002983 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002984 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002985 exp-sgcheck/Makefile
2986 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002987 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002988 drd/scripts/download-and-build-splash2
2989 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002990 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002991 exp-bbv/tests/Makefile
2992 exp-bbv/tests/x86/Makefile
2993 exp-bbv/tests/x86-linux/Makefile
2994 exp-bbv/tests/amd64-linux/Makefile
2995 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002996 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002997 exp-dhat/Makefile
2998 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002999])
sewardjd3645802010-06-13 22:13:58 +00003000AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3001 [chmod +x coregrind/link_tool_exe_linux])
3002AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3003 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00003004AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00003005
3006cat<<EOF
3007
njn311303f2009-02-06 03:46:50 +00003008 Maximum build arch: ${ARCH_MAX}
3009 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00003010 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00003011 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00003012 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3013 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00003014 Platform variant: ${VGCONF_PLATVARIANT}
3015 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00003016 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00003017
gobry3b777892002-04-04 09:18:39 +00003018EOF