blob: 5e321a3498f6a662aee8d1b6012b6b4d81e2879f [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.
sewardj704deb62012-08-09 15:51:55 +000011AC_INIT([Valgrind],[3.9.0.SVN],[valgrind-users@lists.sourceforge.net])
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
bart417cf3e2011-10-22 09:21:24 +000013AC_CONFIG_HEADERS([config.h])
bart3a2dac02008-03-18 17:40:38 +000014AM_INIT_AUTOMAKE([foreign])
sewardjde4a1d02002-03-22 01:27:54 +000015
gobryb0ed4672002-03-27 20:58:58 +000016AM_MAINTAINER_MODE
17
njn7fd6d382009-01-22 21:56:32 +000018#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +000019# Checks for various programs.
20#----------------------------------------------------------------------------
bartaca399a2010-08-15 18:54:15 +000021CFLAGS="-Wno-long-long $CFLAGS"
gobrye721a522002-03-22 13:38:30 +000022
sewardjde4a1d02002-03-22 01:27:54 +000023AC_PROG_LN_S
24AC_PROG_CC
bart0affa492008-03-18 17:53:09 +000025AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000026AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000027AC_PROG_CXX
njn629a5ec2009-07-14 01:29:39 +000028# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
29# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
30# base (eg. most likely as Darwin-specific tests) we'll need one of the
31# following:
njn0cd26892009-07-12 23:07:13 +000032# - put AC_PROG_OBJC in a Darwin-specific part of this file
33# - Use AC_PROG_OBJC here and up the minimum autoconf version
34# - Use the following, which is apparently equivalent:
35# m4_ifdef([AC_PROG_OBJC],
36# [AC_PROG_OBJC],
37# [AC_CHECK_TOOL([OBJC], [gcc])
38# AC_SUBST([OBJC])
39# AC_SUBST([OBJCFLAGS])
40# ])
sewardjde4a1d02002-03-22 01:27:54 +000041AC_PROG_RANLIB
bart07de2c92010-05-29 06:44:28 +000042# provide a very basic definition for AC_PROG_SED if it's not provided by
43# autoconf (as e.g. in autoconf 2.59).
44m4_ifndef([AC_PROG_SED],
45 [AC_DEFUN([AC_PROG_SED],
46 [AC_ARG_VAR([SED])
47 AC_CHECK_PROGS([SED],[gsed sed])])])
bart12e91122010-05-15 08:37:24 +000048AC_PROG_SED
sewardjde4a1d02002-03-22 01:27:54 +000049
bartcddeaf52008-05-25 15:58:11 +000050# If no AR variable was specified, look up the name of the archiver. Otherwise
51# do not touch the AR variable.
52if test "x$AR" = "x"; then
bart07de2c92010-05-29 06:44:28 +000053 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
bartcddeaf52008-05-25 15:58:11 +000054fi
55AC_ARG_VAR([AR],[Archiver command])
56
gobrye721a522002-03-22 13:38:30 +000057# Check for the compiler support
58if test "${GCC}" != "yes" ; then
59 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
60fi
61
sewardj2f685952002-12-22 19:32:23 +000062# figure out where perl lives
63AC_PATH_PROG(PERL, perl)
64
njn9315df32003-04-16 20:50:50 +000065# figure out where gdb lives
sewardjf8722ca2008-11-17 00:20:45 +000066AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
njnfe408942004-11-23 17:52:24 +000067AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000068
daywalker48ccca52002-04-15 00:31:58 +000069# some older automake's don't have it so try something on our own
70ifdef([AM_PROG_AS],[AM_PROG_AS],
71[
gobry1be19852002-03-26 20:44:55 +000072AS="${CC}"
73AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000074
gobry1be19852002-03-26 20:44:55 +000075ASFLAGS=""
76AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000077])
gobry3b777892002-04-04 09:18:39 +000078
gobry3b777892002-04-04 09:18:39 +000079
njn0d2e58f2009-02-25 04:57:56 +000080# Check if 'diff' supports -u (universal diffs) and use it if possible.
81
82AC_MSG_CHECKING([for diff -u])
83AC_SUBST(DIFF)
84
sewardj6e9de462011-06-28 07:25:29 +000085# Comparing two identical files results in 0.
njn31f665e2009-02-26 21:25:50 +000086tmpfile="tmp-xxx-yyy-zzz"
87touch $tmpfile;
88if diff -u $tmpfile $tmpfile ; then
njn0d2e58f2009-02-25 04:57:56 +000089 AC_MSG_RESULT([yes])
90 DIFF="diff -u"
91else
92 AC_MSG_RESULT([no])
93 DIFF="diff"
94fi
njn31f665e2009-02-26 21:25:50 +000095rm $tmpfile
njn0d2e58f2009-02-25 04:57:56 +000096
97
sewardj535c50f2005-06-04 23:14:53 +000098# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +000099AC_MSG_CHECKING([for a supported version of gcc])
100
bart85037442011-11-22 14:41:31 +0000101# Obtain the compiler version.
sewardja8ca2c52011-09-29 18:18:37 +0000102#
bart85037442011-11-22 14:41:31 +0000103# A few examples of how the ${CC} --version output looks like:
104#
105# Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
106# Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
107# openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
108# Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
bartc5214062012-01-11 11:34:23 +0000109# MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
bart85037442011-11-22 14:41:31 +0000110# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
111# OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
112# Clang: clang version 2.9 (tags/RELEASE_29/final)
bart048081f2012-06-17 05:53:02 +0000113# Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
114# FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
sewardja8ca2c52011-09-29 18:18:37 +0000115#
bartc5214062012-01-11 11:34:23 +0000116[
bart048081f2012-06-17 05:53:02 +0000117if test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ; then
118 is_clang="clang"
119 # Don't use -dumpversion with clang: it will always produce "4.2.1".
120 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
121else
122 is_clang="notclang"
123 gcc_version=`${CC} -dumpversion 2>/dev/null`
124 if test "x$gcc_version" = x; then
125 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
126 fi
sewardj3ab7b662011-09-29 17:30:13 +0000127fi
bart048081f2012-06-17 05:53:02 +0000128]
sewardj3ab7b662011-09-29 17:30:13 +0000129
130case "${is_clang}-${gcc_version}" in
131 notclang-3.*)
132 AC_MSG_RESULT([ok (${gcc_version})])
133 ;;
134 notclang-4.*)
135 AC_MSG_RESULT([ok (${gcc_version})])
136 ;;
sewardjae284e52012-08-02 18:25:04 +0000137 clang-2.9|clang-3.*|clang-4.*)
sewardj3ab7b662011-09-29 17:30:13 +0000138 AC_MSG_RESULT([ok (clang-${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000139 ;;
gobrye721a522002-03-22 13:38:30 +0000140 *)
sewardj3ab7b662011-09-29 17:30:13 +0000141 AC_MSG_RESULT([no (${gcc_version})])
142 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
gobrye721a522002-03-22 13:38:30 +0000143 ;;
144esac
145
njn7fd6d382009-01-22 21:56:32 +0000146#----------------------------------------------------------------------------
147# Arch/OS/platform tests.
148#----------------------------------------------------------------------------
149# We create a number of arch/OS/platform-related variables. We prefix them
150# all with "VGCONF_" which indicates that they are defined at
151# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
152# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000153
sewardjde4a1d02002-03-22 01:27:54 +0000154AC_CANONICAL_HOST
155
156AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000157
njn7fd6d382009-01-22 21:56:32 +0000158# ARCH_MAX reflects the most that this CPU can do: for example if it
159# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
160# Ditto for amd64. It is used for more configuration below, but is not used
161# outside this file.
gobrye721a522002-03-22 13:38:30 +0000162case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000163 i?86)
164 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000165 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000166 ;;
167
njnfe408942004-11-23 17:52:24 +0000168 x86_64)
169 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000170 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000171 ;;
172
sewardj2c48c7b2005-11-29 13:05:56 +0000173 powerpc64)
174 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000175 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000176 ;;
177
178 powerpc)
sewardj6e9de462011-06-28 07:25:29 +0000179 # On Linux this means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000180 AC_MSG_RESULT([ok (${host_cpu})])
sewardj6e9de462011-06-28 07:25:29 +0000181 ARCH_MAX="ppc32"
nethercote9bcc9062004-10-13 13:50:01 +0000182 ;;
183
sewardjb5b87402011-03-07 16:05:35 +0000184 s390x)
185 AC_MSG_RESULT([ok (${host_cpu})])
186 ARCH_MAX="s390x"
187 ;;
188
sewardj59570ff2010-01-01 11:59:33 +0000189 armv7*)
190 AC_MSG_RESULT([ok (${host_cpu})])
191 ARCH_MAX="arm"
192 ;;
193
sewardj5db15402012-06-07 09:13:21 +0000194 mips)
195 AC_MSG_RESULT([ok (${host_cpu})])
196 ARCH_MAX="mips32"
197 ;;
198
199 mipsel)
200 AC_MSG_RESULT([ok (${host_cpu})])
201 ARCH_MAX="mips32"
202 ;;
203
204 mipsisa32r2)
205 AC_MSG_RESULT([ok (${host_cpu})])
206 ARCH_MAX="mips32"
207 ;;
208
sewardjde4a1d02002-03-22 01:27:54 +0000209 *)
210 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000211 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000212 ;;
213esac
214
njn7fd6d382009-01-22 21:56:32 +0000215#----------------------------------------------------------------------------
216
sewardj86e992f2006-01-28 18:39:09 +0000217# Sometimes it's convenient to subvert the bi-arch build system and
218# just have a single build even though the underlying platform is
219# capable of both. Hence handle --enable-only64bit and
220# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000221# [Actually, if either of these options are used, I think both get built,
222# but only one gets installed. So if you use an in-place build, both can be
223# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000224
225# Check if a 64-bit only build has been requested
226AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
227 [AC_ARG_ENABLE(only64bit,
228 [ --enable-only64bit do a 64-bit only build],
229 [vg_cv_only64bit=$enableval],
230 [vg_cv_only64bit=no])])
231
232# Check if a 32-bit only build has been requested
233AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
234 [AC_ARG_ENABLE(only32bit,
235 [ --enable-only32bit do a 32-bit only build],
236 [vg_cv_only32bit=$enableval],
237 [vg_cv_only32bit=no])])
238
239# Stay sane
240if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
241 AC_MSG_ERROR(
242 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
243fi
244
njn7fd6d382009-01-22 21:56:32 +0000245#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000246
njn311303f2009-02-06 03:46:50 +0000247# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
248# compilation of many C files via -VGO_$(VGCONF_OS) and
249# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000250AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000251AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000252
njnf76d27a2009-05-28 01:53:07 +0000253DEFAULT_SUPP=""
254
gobrye721a522002-03-22 13:38:30 +0000255case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000256 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000257 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000258 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000259
260 # Ok, this is linux. Check the kernel version
261 AC_MSG_CHECKING([for the kernel version])
262
263 kernel=`uname -r`
264
265 case "${kernel}" in
bart0419e512011-06-05 08:51:47 +0000266 2.6.*|3.*)
bart2d6e6e72011-06-05 10:01:48 +0000267 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
268 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 +0000269 ;;
270
271 2.4.*)
272 AC_MSG_RESULT([2.4 family (${kernel})])
273 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
274 ;;
275
mueller8c68e042004-01-03 15:21:14 +0000276 *)
277 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000278 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000279 ;;
280 esac
281
282 ;;
283
njnf76d27a2009-05-28 01:53:07 +0000284 *darwin*)
285 AC_MSG_RESULT([ok (${host_os})])
286 VGCONF_OS="darwin"
njnea2d6fd2010-07-01 00:20:20 +0000287 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
288 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
289 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
sewardjae284e52012-08-02 18:25:04 +0000290 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
njnf76d27a2009-05-28 01:53:07 +0000291
292 AC_MSG_CHECKING([for the kernel version])
293 kernel=`uname -r`
294
295 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
296 # has only one relevant version, the OS version. The `uname` check
297 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
sewardj731f9cf2011-09-21 08:43:08 +0000298 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
299 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
njnea2d6fd2010-07-01 00:20:20 +0000300 # and we don't know of an macros similar to __GLIBC__ to get that info.
njnf76d27a2009-05-28 01:53:07 +0000301 #
302 # XXX: `uname -r` won't do the right thing for cross-compiles, but
303 # that's not a problem yet.
sewardj731f9cf2011-09-21 08:43:08 +0000304 #
305 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
306 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
307 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
308 # time support for 10.5 (the 9.* pattern just below), I'll leave it
309 # in for now, just in case anybody wants to give it a try. But I'm
310 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
njnf76d27a2009-05-28 01:53:07 +0000311 case "${kernel}" in
312 9.*)
313 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
njnea2d6fd2010-07-01 00:20:20 +0000314 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
njnf76d27a2009-05-28 01:53:07 +0000315 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
bart6ccda142009-07-23 07:37:32 +0000316 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
njnf76d27a2009-05-28 01:53:07 +0000317 ;;
njnea2d6fd2010-07-01 00:20:20 +0000318 10.*)
319 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
320 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
321 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
322 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
323 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000324 11.*)
325 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
326 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
sewardj731f9cf2011-09-21 08:43:08 +0000327 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
328 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
329 ;;
sewardjae284e52012-08-02 18:25:04 +0000330 12.*)
331 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
332 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
333 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
334 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
335 ;;
sewardj731f9cf2011-09-21 08:43:08 +0000336 *)
njnf76d27a2009-05-28 01:53:07 +0000337 AC_MSG_RESULT([unsupported (${kernel})])
sewardj731f9cf2011-09-21 08:43:08 +0000338 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
njnf76d27a2009-05-28 01:53:07 +0000339 ;;
340 esac
341 ;;
342
sewardjde4a1d02002-03-22 01:27:54 +0000343 *)
344 AC_MSG_RESULT([no (${host_os})])
njncc58cea2010-07-05 07:21:22 +0000345 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
sewardjde4a1d02002-03-22 01:27:54 +0000346 ;;
347esac
348
njn7fd6d382009-01-22 21:56:32 +0000349#----------------------------------------------------------------------------
350
tomd6398392006-06-07 17:44:36 +0000351# If we are building on a 64 bit platform test to see if the system
352# supports building 32 bit programs and disable 32 bit support if it
353# does not support building 32 bit programs
354
njn7fd6d382009-01-22 21:56:32 +0000355case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000356 amd64-linux|ppc64-linux)
357 AC_MSG_CHECKING([for 32 bit build support])
358 safe_CFLAGS=$CFLAGS
359 CFLAGS="-m32"
bart417cf3e2011-10-22 09:21:24 +0000360 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +0000361 return 0;
bart417cf3e2011-10-22 09:21:24 +0000362 ]])], [
tomd6398392006-06-07 17:44:36 +0000363 AC_MSG_RESULT([yes])
364 ], [
365 vg_cv_only64bit="yes"
366 AC_MSG_RESULT([no])
367 ])
368 CFLAGS=$safe_CFLAGS;;
369esac
370
371if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
372 AC_MSG_ERROR(
373 [--enable-only32bit was specified but system does not support 32 bit builds])
374fi
nethercote888ecb72004-08-23 14:54:40 +0000375
njn7fd6d382009-01-22 21:56:32 +0000376#----------------------------------------------------------------------------
377
njn311303f2009-02-06 03:46:50 +0000378# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
379# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
380# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
381# above) will be "amd64" since that reflects the most that this cpu can do,
382# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
383# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000384# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
385# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
386AC_SUBST(VGCONF_ARCH_PRI)
387
njn3f8a6e92009-06-02 00:20:47 +0000388# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
389# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
390# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
391# It is empty if there is no secondary target.
392AC_SUBST(VGCONF_ARCH_SEC)
393
njn311303f2009-02-06 03:46:50 +0000394# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
395# The entire system, including regression and performance tests, will be
396# built for this target. The "_CAPS" indicates that the name is in capital
397# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000398# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000399# convention and cannot contain '-' characters. This is in contrast to
400# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000401AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
402
403# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
404# Valgrind and tools will also be built for this target, but not the
405# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000406#
njn7fd6d382009-01-22 21:56:32 +0000407# By default, the primary arch is the same as the "max" arch, as commented
408# above (at the definition of ARCH_MAX). We may choose to downgrade it in
409# the big case statement just below here, in the case where we're building
410# on a 64 bit machine but have been requested only to do a 32 bit build.
411AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
412
sewardj01262142006-01-04 01:20:28 +0000413AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000414
njnea2d6fd2010-07-01 00:20:20 +0000415# NB. The load address for a given platform may be specified in more
416# than one place, in some cases, depending on whether we're doing a biarch,
417# 32-bit only or 64-bit only build. eg see case for amd64-linux below.
418# Be careful to give consistent values in all subcases. Also, all four
419# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
420# even if it is to "0xUNSET".
421#
njn7fd6d382009-01-22 21:56:32 +0000422case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000423 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000424 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000425 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000426 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
427 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000428 valt_load_address_pri_norml="0x38000000"
429 valt_load_address_pri_inner="0x28000000"
430 valt_load_address_sec_norml="0xUNSET"
431 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000432 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000433 ;;
434 amd64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000435 valt_load_address_sec_norml="0xUNSET"
436 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000437 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000438 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000439 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000440 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
441 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000442 valt_load_address_pri_norml="0x38000000"
443 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000444 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000445 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000446 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000447 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
448 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000449 valt_load_address_pri_norml="0x38000000"
450 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000451 else
njn7fd6d382009-01-22 21:56:32 +0000452 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000453 VGCONF_ARCH_SEC="x86"
njn7fd6d382009-01-22 21:56:32 +0000454 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
455 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000456 valt_load_address_pri_norml="0x38000000"
457 valt_load_address_pri_inner="0x28000000"
458 valt_load_address_sec_norml="0x38000000"
459 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000460 fi
njn377c43f2009-05-19 07:39:22 +0000461 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000462 ;;
463 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000464 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000465 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000466 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
467 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000468 valt_load_address_pri_norml="0x38000000"
469 valt_load_address_pri_inner="0x28000000"
470 valt_load_address_sec_norml="0xUNSET"
471 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000472 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000473 ;;
474 ppc64-linux)
njnea2d6fd2010-07-01 00:20:20 +0000475 valt_load_address_sec_norml="0xUNSET"
476 valt_load_address_sec_inner="0xUNSET"
sewardj86e992f2006-01-28 18:39:09 +0000477 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000478 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000479 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000480 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
481 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000482 valt_load_address_pri_norml="0x38000000"
483 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000484 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000485 VGCONF_ARCH_PRI="ppc32"
njn3f8a6e92009-06-02 00:20:47 +0000486 VGCONF_ARCH_SEC=""
njn7fd6d382009-01-22 21:56:32 +0000487 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
488 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000489 valt_load_address_pri_norml="0x38000000"
490 valt_load_address_pri_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000491 else
njn7fd6d382009-01-22 21:56:32 +0000492 VGCONF_ARCH_PRI="ppc64"
njn3f8a6e92009-06-02 00:20:47 +0000493 VGCONF_ARCH_SEC="ppc32"
njn7fd6d382009-01-22 21:56:32 +0000494 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
495 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
njnea2d6fd2010-07-01 00:20:20 +0000496 valt_load_address_pri_norml="0x38000000"
497 valt_load_address_pri_inner="0x28000000"
498 valt_load_address_sec_norml="0x38000000"
499 valt_load_address_sec_inner="0x28000000"
sewardj86e992f2006-01-28 18:39:09 +0000500 fi
njn377c43f2009-05-19 07:39:22 +0000501 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
sewardj01262142006-01-04 01:20:28 +0000502 ;;
njncc58cea2010-07-05 07:21:22 +0000503 # Darwin gets identified as 32-bit even when it supports 64-bit.
504 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
505 # all Macs support both 32-bit and 64-bit, so we just build both. If
506 # someone has a really old 32-bit only machine they can (hopefully?)
507 # build with --enable-only32bit. See bug 243362.
508 x86-darwin|amd64-darwin)
509 ARCH_MAX="amd64"
njnea2d6fd2010-07-01 00:20:20 +0000510 valt_load_address_sec_norml="0xUNSET"
511 valt_load_address_sec_inner="0xUNSET"
njnf76d27a2009-05-28 01:53:07 +0000512 if test x$vg_cv_only64bit = xyes; then
513 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000514 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000515 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
516 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000517 valt_load_address_pri_norml="0x138000000"
518 valt_load_address_pri_inner="0x128000000"
njnf76d27a2009-05-28 01:53:07 +0000519 elif test x$vg_cv_only32bit = xyes; then
520 VGCONF_ARCH_PRI="x86"
njn3f8a6e92009-06-02 00:20:47 +0000521 VGCONF_ARCH_SEC=""
njnf76d27a2009-05-28 01:53:07 +0000522 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
523 VGCONF_PLATFORM_SEC_CAPS=""
524 VGCONF_ARCH_PRI_CAPS="x86"
njnea2d6fd2010-07-01 00:20:20 +0000525 valt_load_address_pri_norml="0x38000000"
526 valt_load_address_pri_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000527 else
528 VGCONF_ARCH_PRI="amd64"
njn3f8a6e92009-06-02 00:20:47 +0000529 VGCONF_ARCH_SEC="x86"
njnf76d27a2009-05-28 01:53:07 +0000530 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
531 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
njnea2d6fd2010-07-01 00:20:20 +0000532 valt_load_address_pri_norml="0x138000000"
533 valt_load_address_pri_inner="0x128000000"
534 valt_load_address_sec_norml="0x38000000"
535 valt_load_address_sec_inner="0x28000000"
njnf76d27a2009-05-28 01:53:07 +0000536 fi
njnf76d27a2009-05-28 01:53:07 +0000537 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
538 ;;
sewardj59570ff2010-01-01 11:59:33 +0000539 arm-linux)
540 VGCONF_ARCH_PRI="arm"
541 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
542 VGCONF_PLATFORM_SEC_CAPS=""
njnea2d6fd2010-07-01 00:20:20 +0000543 valt_load_address_pri_norml="0x38000000"
544 valt_load_address_pri_inner="0x28000000"
545 valt_load_address_sec_norml="0xUNSET"
546 valt_load_address_sec_inner="0xUNSET"
sewardj59570ff2010-01-01 11:59:33 +0000547 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
548 ;;
sewardjb5b87402011-03-07 16:05:35 +0000549 s390x-linux)
550 VGCONF_ARCH_PRI="s390x"
551 VGCONF_ARCH_SEC=""
552 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
553 VGCONF_PLATFORM_SEC_CAPS=""
554 # we want to have the generated code close to the dispatcher
555 valt_load_address_pri_norml="0x401000000"
556 valt_load_address_pri_inner="0x410000000"
557 valt_load_address_sec_norml="0xUNSET"
558 valt_load_address_sec_inner="0xUNSET"
559 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
560 ;;
sewardj5db15402012-06-07 09:13:21 +0000561 mips32-linux)
562 VGCONF_ARCH_PRI="mips32"
563 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
564 VGCONF_PLATFORM_SEC_CAPS=""
565 valt_load_address_pri_norml="0x38000000"
566 valt_load_address_pri_inner="0x28000000"
567 valt_load_address_sec_norml="0xUNSET"
568 valt_load_address_sec_inner="0xUNSET"
569 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
570 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
571 ;;
nethercote888ecb72004-08-23 14:54:40 +0000572 *)
njn7fd6d382009-01-22 21:56:32 +0000573 VGCONF_ARCH_PRI="unknown"
njn3f8a6e92009-06-02 00:20:47 +0000574 VGCONF_ARCH_SEC="unknown"
njn7fd6d382009-01-22 21:56:32 +0000575 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
576 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
njnea2d6fd2010-07-01 00:20:20 +0000577 valt_load_address_pri_norml="0xUNSET"
578 valt_load_address_pri_inner="0xUNSET"
579 valt_load_address_sec_norml="0xUNSET"
580 valt_load_address_sec_inner="0xUNSET"
njn377c43f2009-05-19 07:39:22 +0000581 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
sewardj3e38ce02004-11-23 01:17:29 +0000582 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000583 ;;
584esac
sewardjde4a1d02002-03-22 01:27:54 +0000585
njn7fd6d382009-01-22 21:56:32 +0000586#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000587
njn7fd6d382009-01-22 21:56:32 +0000588# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
589# defined.
590AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
591 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
njnf76d27a2009-05-28 01:53:07 +0000592 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
593 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
594 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000595AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
njnf76d27a2009-05-28 01:53:07 +0000596 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
597 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
njn7fd6d382009-01-22 21:56:32 +0000598AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
599 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj6e9de462011-06-28 07:25:29 +0000600 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
njn7fd6d382009-01-22 21:56:32 +0000601AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
sewardj6e9de462011-06-28 07:25:29 +0000602 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
sewardj59570ff2010-01-01 11:59:33 +0000603AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
604 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
sewardjb5b87402011-03-07 16:05:35 +0000605AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
606 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
sewardj5db15402012-06-07 09:13:21 +0000607AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
608 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
sewardj03d86f22006-10-17 00:57:24 +0000609
njn7fd6d382009-01-22 21:56:32 +0000610# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
611# become defined.
612AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
613 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
614 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
615AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
616 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
617AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
618 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
619 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
620AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
621 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
sewardj59570ff2010-01-01 11:59:33 +0000622AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
623 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
sewardjb5b87402011-03-07 16:05:35 +0000624AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
625 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
626 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
sewardj5db15402012-06-07 09:13:21 +0000627AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
628 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000629
njnf76d27a2009-05-28 01:53:07 +0000630AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
631 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
632 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
633AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
634 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
635
636
sewardj72a2d802010-07-29 05:24:20 +0000637# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000638# Relies on the assumption that the primary and secondary targets are
639# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000640AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
641 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
642 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
643 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj59570ff2010-01-01 11:59:33 +0000644 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +0000645 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
sewardj5db15402012-06-07 09:13:21 +0000646 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
647 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
njnf76d27a2009-05-28 01:53:07 +0000648AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
649 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
650 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
sewardj03d86f22006-10-17 00:57:24 +0000651
652
njn7fd6d382009-01-22 21:56:32 +0000653# Sometimes, in the Makefile.am files, it's useful to know whether or not
654# there is a secondary target.
njnee0c66a2009-06-01 23:59:20 +0000655AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
njn7fd6d382009-01-22 21:56:32 +0000656 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000657
philippef32cbe82012-05-18 16:48:20 +0000658dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
659dnl fallback definition
660dnl The macro is courtesy of Dave Hart:
661dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
662m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
663if test -z "$$1_TRUE"; then :
664 m4_n([$2])[]dnl
665m4_ifval([$3],
666[else
667 $3
668])dnl
669fi[]dnl
670])])
tomb637bad2005-11-08 12:28:35 +0000671
njn7fd6d382009-01-22 21:56:32 +0000672#----------------------------------------------------------------------------
673# Inner Valgrind?
674#----------------------------------------------------------------------------
675
njnd74b0ef2009-01-20 06:06:52 +0000676# Check if this should be built as an inner Valgrind, to be run within
677# another Valgrind. Choose the load address accordingly.
njnea2d6fd2010-07-01 00:20:20 +0000678AC_SUBST(VALT_LOAD_ADDRESS_PRI)
679AC_SUBST(VALT_LOAD_ADDRESS_SEC)
njnd74b0ef2009-01-20 06:06:52 +0000680AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
681 [AC_ARG_ENABLE(inner,
682 [ --enable-inner enables self-hosting],
683 [vg_cv_inner=$enableval],
684 [vg_cv_inner=no])])
685if test "$vg_cv_inner" = yes; then
686 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
njnea2d6fd2010-07-01 00:20:20 +0000687 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
688 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
njnd74b0ef2009-01-20 06:06:52 +0000689else
njnea2d6fd2010-07-01 00:20:20 +0000690 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
691 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
njnd74b0ef2009-01-20 06:06:52 +0000692fi
693
694
njn7fd6d382009-01-22 21:56:32 +0000695#----------------------------------------------------------------------------
sewardj5db15402012-06-07 09:13:21 +0000696# Define MIPS_PAGE_SHIFT (--with-pagesize)
697#----------------------------------------------------------------------------
698AC_ARG_WITH(pagesize,
699 [ --with-pagesize= override detected page size (4, 16 or 64)],
700 [psize=$withval],
701 [psize=0]
702)
703
704if test "$psize" = "0"; then
705 psizer=`getconf PAGESIZE`
706 let "psize=${psizer}/1024"
707fi
708
709if test "$psize" = "4"; then
710 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
711elif test "$psize" = "16"; then
712 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
713elif test "$psize" = "64"; then
714 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
715else
716 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
717fi
718AC_MSG_RESULT([checking for Pagesize... ${psize}k])
719
720#----------------------------------------------------------------------------
721# Define shm_align for MIPS (--shared-memory-alignment)
722#----------------------------------------------------------------------------
723AC_ARG_WITH(alignment,
724 [ --with-alignment= shared memory alignment for MIPS],
725 [align=$withval],
726 [align=-1]
727)
728
729mod=`expr $align % 1024`
730
731let "psz=psize*1024*2"
732
733if test "$align" = "-1"; then
734 AC_DEFINE([SHM_ALIGNMENT], 2*(1UL << MIPS_PAGE_SHIFT),
735 [configured memory alignment 2*PAGE_SIZE])
736 AC_MSG_RESULT([checking for shared memory alignment... 2*PAGE_SIZE])
737elif test "$mod" = "0"; then
738 if test $align -lt $psz;
739 then
740 AC_MSG_ERROR([Alignment must be >= PAGE_SIZE])
741 else
742 AC_DEFINE_UNQUOTED([SHM_ALIGNMENT], ${align},
743 [configured memory alignment 2*PAGE_SIZE])
744 AC_MSG_RESULT([checking for shared memory alignment... ${align}])
745 fi
746else
747 AC_MSG_ERROR([Alignment % 1024 must be zero])
748fi
749
750
751#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000752# Extra fine-tuning of installation directories
753#----------------------------------------------------------------------------
754AC_ARG_WITH(tmpdir,
755 [ --with-tmpdir=PATH Specify path for temporary files],
756 tmpdir="$withval",
757 tmpdir="/tmp")
758AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
759
sewardj0ba37c92011-07-12 11:46:24 +0000760
sewardjcb495c82011-07-11 20:42:34 +0000761#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000762# Libc and suppressions
763#----------------------------------------------------------------------------
764# This variable will collect the suppression files to be used.
njn7fd6d382009-01-22 21:56:32 +0000765AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000766
bart12e91122010-05-15 08:37:24 +0000767AC_CHECK_HEADER([features.h])
sewardjde4a1d02002-03-22 01:27:54 +0000768
bart12e91122010-05-15 08:37:24 +0000769if test x$ac_cv_header_features_h = xyes; then
770 rm -f conftest.$ac_ext
771 cat <<_ACEOF >conftest.$ac_ext
sewardjde4a1d02002-03-22 01:27:54 +0000772#include <features.h>
bart12e91122010-05-15 08:37:24 +0000773#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
774glibc version is: __GLIBC__ __GLIBC_MINOR__
sewardjde4a1d02002-03-22 01:27:54 +0000775#endif
bart12e91122010-05-15 08:37:24 +0000776_ACEOF
777 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
778fi
bartb7c3f082010-05-13 06:32:36 +0000779
njnf76d27a2009-05-28 01:53:07 +0000780# not really a version check
781AC_EGREP_CPP([DARWIN_LIBC], [
782#include <sys/cdefs.h>
783#if defined(__DARWIN_VERS_1050)
784 DARWIN_LIBC
785#endif
786],
787GLIBC_VERSION="darwin")
788
sewardjcb495c82011-07-11 20:42:34 +0000789# not really a version check
790AC_EGREP_CPP([BIONIC_LIBC], [
791#if defined(__ANDROID__)
792 BIONIC_LIBC
793#endif
794],
795GLIBC_VERSION="bionic")
796
797
dirk07596a22008-04-25 11:33:30 +0000798AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000799
dirk07596a22008-04-25 11:33:30 +0000800case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000801 2.2)
802 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000803 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000804 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
805 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000806 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000807 ;;
808
sewardj08c7f012002-10-07 23:56:55 +0000809 2.3)
810 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000811 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000812 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000813 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000814 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000815 ;;
816
njn781dba52005-06-30 04:06:38 +0000817 2.4)
818 AC_MSG_RESULT(2.4 family)
819 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000820 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000821 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000822 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000823 ;;
824
dirkaece45c2006-10-12 08:17:49 +0000825 2.5)
826 AC_MSG_RESULT(2.5 family)
827 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000828 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000829 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000830 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000831 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000832 2.6)
833 AC_MSG_RESULT(2.6 family)
834 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000835 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000836 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000837 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000838 ;;
839 2.7)
840 AC_MSG_RESULT(2.7 family)
841 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000842 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000843 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000844 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000845 ;;
dirk07596a22008-04-25 11:33:30 +0000846 2.8)
847 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000848 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000849 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
850 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
851 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
852 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000853 2.9)
854 AC_MSG_RESULT(2.9 family)
855 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
856 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
857 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
858 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
859 ;;
sewardj5d425e82009-02-01 19:01:11 +0000860 2.10)
861 AC_MSG_RESULT(2.10 family)
862 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
863 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
864 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
865 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
866 ;;
bart0fac7ff2009-11-15 19:11:19 +0000867 2.11)
868 AC_MSG_RESULT(2.11 family)
869 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
870 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
871 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
872 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bartb7c3f082010-05-13 06:32:36 +0000873 ;;
874 2.12)
875 AC_MSG_RESULT(2.12 family)
876 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
877 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
878 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
879 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
bart0fac7ff2009-11-15 19:11:19 +0000880 ;;
tomebd619b2011-02-10 09:09:09 +0000881 2.13)
882 AC_MSG_RESULT(2.13 family)
883 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
884 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
885 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
886 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
887 ;;
tomcc077412011-06-07 21:52:26 +0000888 2.14)
889 AC_MSG_RESULT(2.14 family)
890 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
891 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
892 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
893 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
894 ;;
dirke75fdeb2011-12-29 08:24:55 +0000895 2.15)
896 AC_MSG_RESULT(2.15 family)
897 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
898 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
899 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
900 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
901 ;;
sewardjc7188be2012-07-14 10:07:06 +0000902 2.16)
903 AC_MSG_RESULT(2.16 family)
904 AC_DEFINE([GLIBC_2_16], 1, [Define to 1 if you're using glibc 2.16.x])
905 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
906 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
907 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
908 ;;
njnf76d27a2009-05-28 01:53:07 +0000909 darwin)
910 AC_MSG_RESULT(Darwin)
911 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
912 # DEFAULT_SUPP set by kernel version check above.
913 ;;
sewardjcb495c82011-07-11 20:42:34 +0000914 bionic)
915 AC_MSG_RESULT(Bionic)
916 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
917 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
918 ;;
dirkaece45c2006-10-12 08:17:49 +0000919
sewardjde4a1d02002-03-22 01:27:54 +0000920 *)
bart12e91122010-05-15 08:37:24 +0000921 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
sewardjc7188be2012-07-14 10:07:06 +0000922 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.16])
njnf76d27a2009-05-28 01:53:07 +0000923 AC_MSG_ERROR([or Darwin libc])
sewardjde4a1d02002-03-22 01:27:54 +0000924 ;;
925esac
926
dirk07596a22008-04-25 11:33:30 +0000927AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000928
sewardj414f3582008-07-18 20:46:00 +0000929
930# Add default suppressions for the X client libraries. Make no
931# attempt to detect whether such libraries are installed on the
932# build machine (or even if any X facilities are present); just
933# add the suppressions antidisirregardless.
934DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
935DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000936
sewardjd2f95a02011-05-11 16:04:28 +0000937# Add glibc and X11 suppressions for exp-sgcheck
938DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
sewardj5744c022008-10-19 18:58:13 +0000939
sewardj2e10a682003-04-07 19:36:41 +0000940
njn7fd6d382009-01-22 21:56:32 +0000941#----------------------------------------------------------------------------
sewardjcb495c82011-07-11 20:42:34 +0000942# Platform variants?
943#----------------------------------------------------------------------------
944
945# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
946# But there are times where we need a bit more control. The motivating
philippe5d5dd8e2012-08-05 00:08:25 +0000947# and currently only case is Android: this is almost identical to
948# {x86,arm}-linux, but not quite. So this introduces the concept of platform
949# variant tags, which get passed in the compile as -DVGPV_<arch>_<os>_<variant>
950# along with the main -DVGP_<arch>_<os> definition.
sewardjcb495c82011-07-11 20:42:34 +0000951#
952# In almost all cases, the <variant> bit is "vanilla". But for Android
953# it is "android" instead.
954#
955# Consequently (eg), plain arm-linux would build with
956#
957# -DVGP_arm_linux -DVGPV_arm_linux_vanilla
958#
959# whilst an Android build would have
960#
961# -DVGP_arm_linux -DVGPV_arm_linux_android
962#
philippe5d5dd8e2012-08-05 00:08:25 +0000963# Same for x86. The setup of the platform variant is pushed relatively far
964# down this file in order that we can inspect any of the variables set above.
sewardjcb495c82011-07-11 20:42:34 +0000965
966# In the normal case ..
967VGCONF_PLATVARIANT="vanilla"
968
philippe5d5dd8e2012-08-05 00:08:25 +0000969# Android ?
970if test "$GLIBC_VERSION" = "bionic";
sewardjcb495c82011-07-11 20:42:34 +0000971then
972 VGCONF_PLATVARIANT="android"
973fi
974
975AC_SUBST(VGCONF_PLATVARIANT)
976
977
978# FIXME: do we also want to define automake variables
979# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
980# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
981# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
982# do that. Problem is that we can't do and-ing in Makefile.am's, but
983# that's what we'd need to do to use this, since what we'd want to write
984# is something like
985#
986# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
987#
sewardj0ba37c92011-07-12 11:46:24 +0000988# Hmm. Can't think of a nice clean solution to this.
989
990AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
991 test x$VGCONF_PLATVARIANT = xvanilla)
992AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
993 test x$VGCONF_PLATVARIANT = xandroid)
sewardjcb495c82011-07-11 20:42:34 +0000994
995
996#----------------------------------------------------------------------------
njn7fd6d382009-01-22 21:56:32 +0000997# Checking for various library functions and other definitions
998#----------------------------------------------------------------------------
999
bart59e2f182008-04-28 16:22:53 +00001000# Check for CLOCK_MONOTONIC
1001
1002AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1003
bart417cf3e2011-10-22 09:21:24 +00001004AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart59e2f182008-04-28 16:22:53 +00001005#include <time.h>
bart417cf3e2011-10-22 09:21:24 +00001006]], [[
bart59e2f182008-04-28 16:22:53 +00001007 struct timespec t;
1008 clock_gettime(CLOCK_MONOTONIC, &t);
1009 return 0;
bart417cf3e2011-10-22 09:21:24 +00001010]])], [
bart59e2f182008-04-28 16:22:53 +00001011AC_MSG_RESULT([yes])
1012AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1013 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1014], [
1015AC_MSG_RESULT([no])
1016])
1017
bartfea06922008-05-03 09:12:15 +00001018
sewardj0c09bf02011-07-11 22:11:58 +00001019# Check for PTHREAD_RWLOCK_T
1020
1021AC_MSG_CHECKING([for pthread_rwlock_t])
1022
bart417cf3e2011-10-22 09:21:24 +00001023AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardj0c09bf02011-07-11 22:11:58 +00001024#define _GNU_SOURCE
1025#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001026]], [[
sewardj0c09bf02011-07-11 22:11:58 +00001027 pthread_rwlock_t rwl;
bart417cf3e2011-10-22 09:21:24 +00001028]])], [
sewardj0c09bf02011-07-11 22:11:58 +00001029AC_MSG_RESULT([yes])
1030AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1031 [Define to 1 if you have the `pthread_rwlock_t' type.])
1032], [
1033AC_MSG_RESULT([no])
1034])
1035
1036
bartfea06922008-05-03 09:12:15 +00001037# Check for PTHREAD_MUTEX_ADAPTIVE_NP
1038
1039AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1040
bart417cf3e2011-10-22 09:21:24 +00001041AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001042#define _GNU_SOURCE
1043#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001044]], [[
bartfea06922008-05-03 09:12:15 +00001045 return (PTHREAD_MUTEX_ADAPTIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001046]])], [
bartfea06922008-05-03 09:12:15 +00001047AC_MSG_RESULT([yes])
1048AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1049 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1050], [
1051AC_MSG_RESULT([no])
1052])
1053
1054
1055# Check for PTHREAD_MUTEX_ERRORCHECK_NP
1056
1057AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1058
bart417cf3e2011-10-22 09:21:24 +00001059AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001060#define _GNU_SOURCE
1061#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001062]], [[
bartfea06922008-05-03 09:12:15 +00001063 return (PTHREAD_MUTEX_ERRORCHECK_NP);
bart417cf3e2011-10-22 09:21:24 +00001064]])], [
bartfea06922008-05-03 09:12:15 +00001065AC_MSG_RESULT([yes])
1066AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1067 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1068], [
1069AC_MSG_RESULT([no])
1070])
1071
1072
1073# Check for PTHREAD_MUTEX_RECURSIVE_NP
1074
1075AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1076
bart417cf3e2011-10-22 09:21:24 +00001077AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001078#define _GNU_SOURCE
1079#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001080]], [[
bartfea06922008-05-03 09:12:15 +00001081 return (PTHREAD_MUTEX_RECURSIVE_NP);
bart417cf3e2011-10-22 09:21:24 +00001082]])], [
bartfea06922008-05-03 09:12:15 +00001083AC_MSG_RESULT([yes])
1084AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1085 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1086], [
1087AC_MSG_RESULT([no])
1088])
1089
1090
1091# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1092
1093AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1094
bart417cf3e2011-10-22 09:21:24 +00001095AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bartfea06922008-05-03 09:12:15 +00001096#define _GNU_SOURCE
1097#include <pthread.h>
bart417cf3e2011-10-22 09:21:24 +00001098]], [[
bartfea06922008-05-03 09:12:15 +00001099 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1100 return 0;
bart417cf3e2011-10-22 09:21:24 +00001101]])], [
bartfea06922008-05-03 09:12:15 +00001102AC_MSG_RESULT([yes])
1103AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1104 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1105], [
1106AC_MSG_RESULT([no])
1107])
1108
1109
bart5e389f12008-04-05 12:53:15 +00001110# Check whether pthread_mutex_t has a member called __m_kind.
1111
bartb11355c2010-04-29 16:37:26 +00001112AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1113 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1114 1,
1115 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1116 ],
1117 [],
1118 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001119
1120
1121# Check whether pthread_mutex_t has a member called __data.__kind.
1122
bartb11355c2010-04-29 16:37:26 +00001123AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1124 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1125 1,
1126 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1127 ],
1128 [],
1129 [#include <pthread.h>])
bart5e389f12008-04-05 12:53:15 +00001130
1131
bart62c370e2008-05-12 18:50:51 +00001132# does this compiler support -maltivec and does it have the include file
1133# <altivec.h> ?
1134
1135AC_MSG_CHECKING([for Altivec])
1136
1137safe_CFLAGS=$CFLAGS
1138CFLAGS="-maltivec"
1139
bart417cf3e2011-10-22 09:21:24 +00001140AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart62c370e2008-05-12 18:50:51 +00001141#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001142]], [[
bart62c370e2008-05-12 18:50:51 +00001143 vector unsigned int v;
bart417cf3e2011-10-22 09:21:24 +00001144]])], [
bart62c370e2008-05-12 18:50:51 +00001145ac_have_altivec=yes
1146AC_MSG_RESULT([yes])
sewardjf9fe6022010-09-03 14:36:50 +00001147AC_DEFINE([HAS_ALTIVEC], 1,
sewardj6467a152010-09-03 14:02:22 +00001148 [Define to 1 if gcc/as can do Altivec.])
bart62c370e2008-05-12 18:50:51 +00001149], [
1150ac_have_altivec=no
1151AC_MSG_RESULT([no])
1152])
1153CFLAGS=$safe_CFLAGS
1154
sewardj0e342a02010-09-03 23:49:33 +00001155AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
bart62c370e2008-05-12 18:50:51 +00001156
1157
sewardjf34eb492011-04-15 11:57:05 +00001158# Check that both: the compiler supports -mvsx and that the assembler
1159# understands VSX instructions. If either of those doesn't work,
1160# conclude that we can't do VSX. NOTE: basically this is a kludge
1161# in that it conflates two things that should be separate -- whether
1162# the compiler understands the flag vs whether the assembler
1163# understands the opcodes. This really ought to be cleaned up
1164# and done properly, like it is for x86/x86_64.
1165
1166AC_MSG_CHECKING([for VSX])
1167
1168safe_CFLAGS=$CFLAGS
1169CFLAGS="-mvsx"
1170
bart417cf3e2011-10-22 09:21:24 +00001171AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
sewardjf34eb492011-04-15 11:57:05 +00001172#include <altivec.h>
bart417cf3e2011-10-22 09:21:24 +00001173]], [[
sewardjf34eb492011-04-15 11:57:05 +00001174 vector unsigned int v;
sewardj9b80ebb2011-04-15 21:16:00 +00001175 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
bart417cf3e2011-10-22 09:21:24 +00001176]])], [
sewardjf34eb492011-04-15 11:57:05 +00001177ac_have_vsx=yes
1178AC_MSG_RESULT([yes])
1179], [
1180ac_have_vsx=no
1181AC_MSG_RESULT([no])
1182])
1183CFLAGS=$safe_CFLAGS
1184
1185AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1186
sewardj4e1c1912012-08-08 22:22:26 +00001187
sewardjb0ccb4d2012-04-02 10:22:05 +00001188AC_MSG_CHECKING([that assembler knows DFP])
1189
1190AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1191]], [[
1192 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001193 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001194]])], [
1195ac_asm_have_dfp=yes
1196AC_MSG_RESULT([yes])
1197], [
1198ac_asm_have_dfp=no
1199AC_MSG_RESULT([no])
1200])
1201
sewardj4e1c1912012-08-08 22:22:26 +00001202
sewardjb0ccb4d2012-04-02 10:22:05 +00001203AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1204safe_CFLAGS=$CFLAGS
1205CFLAGS="-mhard-dfp"
1206AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1207]], [[
1208 __asm__ __volatile__("dadd 1, 2, 3");
sewardj4e1c1912012-08-08 22:22:26 +00001209 __asm__ __volatile__("dcffix 1, 2");
sewardjb0ccb4d2012-04-02 10:22:05 +00001210]])], [
1211ac_gcc_have_dfp=yes
1212AC_MSG_RESULT([yes])
1213], [
1214ac_gcc_have_dfp=no
1215AC_MSG_RESULT([no])
1216])
1217
sewardjb0ccb4d2012-04-02 10:22:05 +00001218CFLAGS=$safe_CFLAGS
1219
1220AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
sewardjf34eb492011-04-15 11:57:05 +00001221
sewardj4e1c1912012-08-08 22:22:26 +00001222
bart36dd85a2009-04-26 07:11:48 +00001223# Check for pthread_create@GLIBC2.0
1224AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1225
bart16e1c5a2009-04-26 07:38:53 +00001226safe_CFLAGS=$CFLAGS
1227CFLAGS="-lpthread"
bart417cf3e2011-10-22 09:21:24 +00001228AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bart36dd85a2009-04-26 07:11:48 +00001229extern int pthread_create_glibc_2_0(void*, const void*,
1230 void *(*)(void*), void*);
1231__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
bart417cf3e2011-10-22 09:21:24 +00001232]], [[
bart276ed3a2009-05-10 15:41:45 +00001233#ifdef __powerpc__
1234/*
1235 * Apparently on PowerPC linking this program succeeds and generates an
1236 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1237 */
1238#error This test does not work properly on PowerPC.
1239#else
bart16e1c5a2009-04-26 07:38:53 +00001240 pthread_create_glibc_2_0(0, 0, 0, 0);
bart276ed3a2009-05-10 15:41:45 +00001241#endif
bart16e1c5a2009-04-26 07:38:53 +00001242 return 0;
bart417cf3e2011-10-22 09:21:24 +00001243]])], [
bart36dd85a2009-04-26 07:11:48 +00001244ac_have_pthread_create_glibc_2_0=yes
1245AC_MSG_RESULT([yes])
1246AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1247 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1248], [
1249ac_have_pthread_create_glibc_2_0=no
1250AC_MSG_RESULT([no])
1251])
bart16e1c5a2009-04-26 07:38:53 +00001252CFLAGS=$safe_CFLAGS
bart36dd85a2009-04-26 07:11:48 +00001253
1254AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
bart24f53902009-04-26 11:29:02 +00001255 test x$ac_have_pthread_create_glibc_2_0 = xyes)
bart36dd85a2009-04-26 07:11:48 +00001256
1257
barta50aa8a2008-04-27 06:06:57 +00001258# Check for eventfd_t, eventfd() and eventfd_read()
1259AC_MSG_CHECKING([for eventfd()])
1260
bart417cf3e2011-10-22 09:21:24 +00001261AC_LINK_IFELSE([AC_LANG_PROGRAM([[
barta50aa8a2008-04-27 06:06:57 +00001262#include <sys/eventfd.h>
bart417cf3e2011-10-22 09:21:24 +00001263]], [[
barta50aa8a2008-04-27 06:06:57 +00001264 eventfd_t ev;
1265 int fd;
1266
1267 fd = eventfd(5, 0);
1268 eventfd_read(fd, &ev);
1269 return 0;
bart417cf3e2011-10-22 09:21:24 +00001270]])], [
barta50aa8a2008-04-27 06:06:57 +00001271AC_MSG_RESULT([yes])
1272AC_DEFINE([HAVE_EVENTFD], 1,
1273 [Define to 1 if you have the `eventfd' function.])
1274AC_DEFINE([HAVE_EVENTFD_READ], 1,
1275 [Define to 1 if you have the `eventfd_read' function.])
1276], [
1277AC_MSG_RESULT([no])
1278])
1279
1280
njn7fd6d382009-01-22 21:56:32 +00001281#----------------------------------------------------------------------------
1282# Checking for supported compiler flags.
1283#----------------------------------------------------------------------------
1284
sewardj535c50f2005-06-04 23:14:53 +00001285# does this compiler support -m32 ?
1286AC_MSG_CHECKING([if gcc accepts -m32])
1287
1288safe_CFLAGS=$CFLAGS
1289CFLAGS="-m32"
1290
bart417cf3e2011-10-22 09:21:24 +00001291AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001292 return 0;
bart417cf3e2011-10-22 09:21:24 +00001293]])], [
sewardj535c50f2005-06-04 23:14:53 +00001294FLAG_M32="-m32"
1295AC_MSG_RESULT([yes])
1296], [
1297FLAG_M32=""
1298AC_MSG_RESULT([no])
1299])
1300CFLAGS=$safe_CFLAGS
1301
1302AC_SUBST(FLAG_M32)
1303
1304
sewardj01262142006-01-04 01:20:28 +00001305# does this compiler support -m64 ?
1306AC_MSG_CHECKING([if gcc accepts -m64])
1307
1308safe_CFLAGS=$CFLAGS
1309CFLAGS="-m64"
1310
bart417cf3e2011-10-22 09:21:24 +00001311AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001312 return 0;
bart417cf3e2011-10-22 09:21:24 +00001313]])], [
sewardj01262142006-01-04 01:20:28 +00001314FLAG_M64="-m64"
1315AC_MSG_RESULT([yes])
1316], [
1317FLAG_M64=""
1318AC_MSG_RESULT([no])
1319])
1320CFLAGS=$safe_CFLAGS
1321
1322AC_SUBST(FLAG_M64)
1323
1324
sewardj67f1fcc2005-07-03 10:41:02 +00001325# does this compiler support -mmmx ?
1326AC_MSG_CHECKING([if gcc accepts -mmmx])
1327
1328safe_CFLAGS=$CFLAGS
1329CFLAGS="-mmmx"
1330
bart417cf3e2011-10-22 09:21:24 +00001331AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001332 return 0;
bart417cf3e2011-10-22 09:21:24 +00001333]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001334FLAG_MMMX="-mmmx"
1335AC_MSG_RESULT([yes])
1336], [
1337FLAG_MMMX=""
1338AC_MSG_RESULT([no])
1339])
1340CFLAGS=$safe_CFLAGS
1341
1342AC_SUBST(FLAG_MMMX)
1343
1344
1345# does this compiler support -msse ?
1346AC_MSG_CHECKING([if gcc accepts -msse])
1347
1348safe_CFLAGS=$CFLAGS
1349CFLAGS="-msse"
1350
bart417cf3e2011-10-22 09:21:24 +00001351AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001352 return 0;
bart417cf3e2011-10-22 09:21:24 +00001353]])], [
sewardj67f1fcc2005-07-03 10:41:02 +00001354FLAG_MSSE="-msse"
1355AC_MSG_RESULT([yes])
1356], [
1357FLAG_MSSE=""
1358AC_MSG_RESULT([no])
1359])
1360CFLAGS=$safe_CFLAGS
1361
1362AC_SUBST(FLAG_MSSE)
1363
1364
sewardj5b754b42002-06-03 22:53:35 +00001365# does this compiler support -mpreferred-stack-boundary=2 ?
1366AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1367
daywalker3664f562003-10-17 13:43:46 +00001368safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001369CFLAGS="-mpreferred-stack-boundary=2"
1370
bart417cf3e2011-10-22 09:21:24 +00001371AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001372 return 0;
bart417cf3e2011-10-22 09:21:24 +00001373]])], [
sewardj5b754b42002-06-03 22:53:35 +00001374PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001375AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001376], [
1377PREFERRED_STACK_BOUNDARY=""
1378AC_MSG_RESULT([no])
1379])
daywalker3664f562003-10-17 13:43:46 +00001380CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001381
1382AC_SUBST(PREFERRED_STACK_BOUNDARY)
1383
sewardj535c50f2005-06-04 23:14:53 +00001384
sewardjb5f6f512005-03-10 23:59:00 +00001385# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001386AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001387
1388safe_CFLAGS=$CFLAGS
1389CFLAGS="-Wno-pointer-sign"
1390
bart417cf3e2011-10-22 09:21:24 +00001391AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001392 return 0;
bart417cf3e2011-10-22 09:21:24 +00001393]])], [
sewardjb5f6f512005-03-10 23:59:00 +00001394no_pointer_sign=yes
1395AC_MSG_RESULT([yes])
1396], [
1397no_pointer_sign=no
1398AC_MSG_RESULT([no])
1399])
1400CFLAGS=$safe_CFLAGS
1401
1402if test x$no_pointer_sign = xyes; then
1403 CFLAGS="$CFLAGS -Wno-pointer-sign"
1404fi
1405
sewardj535c50f2005-06-04 23:14:53 +00001406
barte026bd22009-07-04 12:17:07 +00001407# does this compiler support -Wno-empty-body ?
1408
1409AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1410
1411safe_CFLAGS=$CFLAGS
1412CFLAGS="-Wno-empty-body"
1413
bart417cf3e2011-10-22 09:21:24 +00001414AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
barte026bd22009-07-04 12:17:07 +00001415 return 0;
bart417cf3e2011-10-22 09:21:24 +00001416]])], [
barte026bd22009-07-04 12:17:07 +00001417AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1418AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001419], [
barte026bd22009-07-04 12:17:07 +00001420AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1421AC_MSG_RESULT([no])
1422])
1423CFLAGS=$safe_CFLAGS
1424
1425
bart9d865fa2008-06-23 12:11:49 +00001426# does this compiler support -Wno-format-zero-length ?
1427
1428AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1429
1430safe_CFLAGS=$CFLAGS
1431CFLAGS="-Wno-format-zero-length"
1432
bart417cf3e2011-10-22 09:21:24 +00001433AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart9d865fa2008-06-23 12:11:49 +00001434 return 0;
bart417cf3e2011-10-22 09:21:24 +00001435]])], [
bart9d865fa2008-06-23 12:11:49 +00001436AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1437AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001438], [
bart9d865fa2008-06-23 12:11:49 +00001439AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1440AC_MSG_RESULT([no])
1441])
1442CFLAGS=$safe_CFLAGS
1443
1444
bart8e216312011-05-15 17:05:36 +00001445# does this compiler support -Wno-nonnull ?
1446
1447AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1448
1449safe_CFLAGS=$CFLAGS
1450CFLAGS="-Wno-nonnull"
1451
bart417cf3e2011-10-22 09:21:24 +00001452AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001453 return 0;
bart417cf3e2011-10-22 09:21:24 +00001454]])], [
bart8e216312011-05-15 17:05:36 +00001455AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1456AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001457], [
bart8e216312011-05-15 17:05:36 +00001458AC_SUBST([FLAG_W_NO_NONNULL], [])
1459AC_MSG_RESULT([no])
1460])
1461CFLAGS=$safe_CFLAGS
1462
1463
1464# does this compiler support -Wno-overflow ?
1465
1466AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1467
1468safe_CFLAGS=$CFLAGS
1469CFLAGS="-Wno-overflow"
1470
bart417cf3e2011-10-22 09:21:24 +00001471AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart8e216312011-05-15 17:05:36 +00001472 return 0;
bart417cf3e2011-10-22 09:21:24 +00001473]])], [
bart8e216312011-05-15 17:05:36 +00001474AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1475AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001476], [
bart8e216312011-05-15 17:05:36 +00001477AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1478AC_MSG_RESULT([no])
1479])
1480CFLAGS=$safe_CFLAGS
1481
1482
bartbf9b85c2009-08-12 12:55:56 +00001483# does this compiler support -Wno-uninitialized ?
1484
1485AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1486
1487safe_CFLAGS=$CFLAGS
1488CFLAGS="-Wno-uninitialized"
1489
bart417cf3e2011-10-22 09:21:24 +00001490AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bartbf9b85c2009-08-12 12:55:56 +00001491 return 0;
bart417cf3e2011-10-22 09:21:24 +00001492]])], [
bartbf9b85c2009-08-12 12:55:56 +00001493AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1494AC_MSG_RESULT([yes])
bart417cf3e2011-10-22 09:21:24 +00001495], [
bartbf9b85c2009-08-12 12:55:56 +00001496AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1497AC_MSG_RESULT([no])
1498])
1499CFLAGS=$safe_CFLAGS
1500
1501
bart56730cd2008-05-11 06:41:46 +00001502# does this compiler support -Wextra or the older -W ?
1503
1504AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1505
1506safe_CFLAGS=$CFLAGS
1507CFLAGS="-Wextra"
1508
bart417cf3e2011-10-22 09:21:24 +00001509AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001510 return 0;
bart417cf3e2011-10-22 09:21:24 +00001511]])], [
bart56730cd2008-05-11 06:41:46 +00001512AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1513AC_MSG_RESULT([-Wextra])
1514], [
1515 CFLAGS="-W"
sewardj9bdf2a62011-10-27 06:22:23 +00001516 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001517 return 0;
sewardj9bdf2a62011-10-27 06:22:23 +00001518 ]])], [
bart56730cd2008-05-11 06:41:46 +00001519 AC_SUBST([FLAG_W_EXTRA], [-W])
1520 AC_MSG_RESULT([-W])
1521 ], [
1522 AC_SUBST([FLAG_W_EXTRA], [])
1523 AC_MSG_RESULT([not supported])
1524 ])
1525])
1526CFLAGS=$safe_CFLAGS
1527
1528
sewardja72c26d2007-05-01 13:44:08 +00001529# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001530AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001531
1532safe_CFLAGS=$CFLAGS
1533CFLAGS="-fno-stack-protector"
1534
bart417cf3e2011-10-22 09:21:24 +00001535AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
njn9890ee12009-01-21 22:25:50 +00001536 return 0;
bart417cf3e2011-10-22 09:21:24 +00001537]])], [
sewardja72c26d2007-05-01 13:44:08 +00001538no_stack_protector=yes
1539FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1540AC_MSG_RESULT([yes])
1541], [
1542no_stack_protector=no
1543FLAG_FNO_STACK_PROTECTOR=""
1544AC_MSG_RESULT([no])
1545])
1546CFLAGS=$safe_CFLAGS
1547
1548AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1549
1550if test x$no_stack_protector = xyes; then
1551 CFLAGS="$CFLAGS -fno-stack-protector"
1552fi
1553
1554
bart56730cd2008-05-11 06:41:46 +00001555# does this compiler support --param inline-unit-growth=... ?
1556
1557AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1558
1559safe_CFLAGS=$CFLAGS
1560CFLAGS="--param inline-unit-growth=900"
1561
bart417cf3e2011-10-22 09:21:24 +00001562AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
bart56730cd2008-05-11 06:41:46 +00001563 return 0;
bart417cf3e2011-10-22 09:21:24 +00001564]])], [
bart56730cd2008-05-11 06:41:46 +00001565AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1566 ["--param inline-unit-growth=900"])
1567AC_MSG_RESULT([yes])
1568], [
1569AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1570AC_MSG_RESULT([no])
1571])
1572CFLAGS=$safe_CFLAGS
1573
1574
sewardjd9350682012-04-05 07:55:47 +00001575# does this compiler support -gdwarf-4 -fdebug-types-section ?
1576
1577AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1578
1579safe_CFLAGS=$CFLAGS
1580CFLAGS="-gdwarf-4 -fdebug-types-section"
1581
1582AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1583 return 0;
1584]])], [
1585ac_have_dwarf4=yes
1586AC_MSG_RESULT([yes])
1587], [
1588ac_have_dwarf4=no
1589AC_MSG_RESULT([no])
1590])
1591AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1592CFLAGS=$safe_CFLAGS
1593
1594
sewardjd3645802010-06-13 22:13:58 +00001595# does the linker support -Wl,--build-id=none ? Note, it's
1596# important that we test indirectly via whichever C compiler
1597# is selected, rather than testing /usr/bin/ld or whatever
1598# directly.
bart699fbac2010-06-08 18:23:59 +00001599
sewardjd3645802010-06-13 22:13:58 +00001600AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
bart699fbac2010-06-08 18:23:59 +00001601
1602safe_CFLAGS=$CFLAGS
1603CFLAGS="-Wl,--build-id=none"
1604
bart8508c752010-06-10 06:26:21 +00001605AC_LINK_IFELSE(
1606[AC_LANG_PROGRAM([ ], [return 0;])],
bart699fbac2010-06-08 18:23:59 +00001607[
1608 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1609 AC_MSG_RESULT([yes])
1610], [
1611 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1612 AC_MSG_RESULT([no])
1613])
1614CFLAGS=$safe_CFLAGS
1615
1616
sewardj00f1e622006-03-12 16:47:10 +00001617# does the ppc assembler support "mtocrf" et al?
1618AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1619
bart417cf3e2011-10-22 09:21:24 +00001620AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjdd4cbe12006-03-12 17:27:44 +00001621__asm__ __volatile__("mtocrf 4,0");
1622__asm__ __volatile__("mfocrf 0,4");
bart417cf3e2011-10-22 09:21:24 +00001623]])], [
sewardj00f1e622006-03-12 16:47:10 +00001624ac_have_as_ppc_mftocrf=yes
1625AC_MSG_RESULT([yes])
1626], [
1627ac_have_as_ppc_mftocrf=no
1628AC_MSG_RESULT([no])
1629])
1630if test x$ac_have_as_ppc_mftocrf = xyes ; then
1631 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1632fi
1633
1634
sewardjb5b87402011-03-07 16:05:35 +00001635CFLAGS=$safe_CFLAGS
1636
sewardjf0aabf82007-03-22 00:24:21 +00001637# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001638# Note, this doesn't generate a C-level symbol. It generates a
1639# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001640AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1641
bart417cf3e2011-10-22 09:21:24 +00001642AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjf0aabf82007-03-22 00:24:21 +00001643 do { long long int x;
1644 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1645 while (0)
bart417cf3e2011-10-22 09:21:24 +00001646]])], [
sewardjf0aabf82007-03-22 00:24:21 +00001647ac_have_as_sse3=yes
1648AC_MSG_RESULT([yes])
1649], [
1650ac_have_as_sse3=no
1651AC_MSG_RESULT([no])
1652])
sewardjfa18a262007-03-22 12:13:13 +00001653
1654AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001655
1656
sewardj6d6da5b2008-02-09 12:07:40 +00001657# Ditto for SSSE3 instructions (note extra S)
1658# Note, this doesn't generate a C-level symbol. It generates a
1659# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1660AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1661
florianc443b962011-10-28 21:37:19 +00001662save_CFLAGS="$CFLAGS"
1663CFLAGS="$CFLAGS -msse"
bart417cf3e2011-10-22 09:21:24 +00001664AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj6d6da5b2008-02-09 12:07:40 +00001665 do { long long int x;
1666 __asm__ __volatile__(
1667 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1668 while (0)
bart417cf3e2011-10-22 09:21:24 +00001669]])], [
sewardj6d6da5b2008-02-09 12:07:40 +00001670ac_have_as_ssse3=yes
1671AC_MSG_RESULT([yes])
1672], [
1673ac_have_as_ssse3=no
1674AC_MSG_RESULT([no])
1675])
florianc443b962011-10-28 21:37:19 +00001676CFLAGS="$save_CFLAGS"
sewardj6d6da5b2008-02-09 12:07:40 +00001677
1678AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1679
1680
sewardj27d176a2011-01-17 11:15:48 +00001681# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1682# Note, this doesn't generate a C-level symbol. It generates a
1683# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
sewardje3ae8a32010-09-28 19:59:47 +00001684AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
bart417cf3e2011-10-22 09:21:24 +00001685AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardje3ae8a32010-09-28 19:59:47 +00001686 do {
1687 __asm__ __volatile__(
1688 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1689 while (0)
bart417cf3e2011-10-22 09:21:24 +00001690]])], [
sewardje3ae8a32010-09-28 19:59:47 +00001691ac_have_as_pclmulqdq=yes
1692AC_MSG_RESULT([yes])
1693], [
1694ac_have_as_pclmulqdq=no
1695AC_MSG_RESULT([no])
1696])
1697
1698AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1699
1700
bart9bbe2bb2012-08-03 19:37:02 +00001701# does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
1702# Note, this doesn't generate a C-level symbol. It generates a
1703# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
1704AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
1705AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1706 do {
1707 /*
1708 * Carry-less multiplication of xmm1 with xmm2 and store the result in
1709 * xmm3. The immediate is used to determine which quadwords of xmm1 and
1710 * xmm2 should be used.
1711 */
1712 __asm__ __volatile__(
1713 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
1714 } while (0)
1715]])], [
1716ac_have_as_vpclmulqdq=yes
1717AC_MSG_RESULT([yes])
1718], [
1719ac_have_as_vpclmulqdq=no
1720AC_MSG_RESULT([no])
1721])
1722
1723AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
1724
1725
sewardj27d176a2011-01-17 11:15:48 +00001726# does the x86/amd64 assembler understand the LZCNT instruction?
1727# Note, this doesn't generate a C-level symbol. It generates a
1728# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
bart55e438b2010-09-14 10:53:57 +00001729AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1730
bart417cf3e2011-10-22 09:21:24 +00001731AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
bart55e438b2010-09-14 10:53:57 +00001732 do {
sewardjc62291c2012-07-22 11:10:08 +00001733 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
bart55e438b2010-09-14 10:53:57 +00001734 } while (0)
bart417cf3e2011-10-22 09:21:24 +00001735]])], [
bart55e438b2010-09-14 10:53:57 +00001736 ac_have_as_lzcnt=yes
1737 AC_MSG_RESULT([yes])
1738], [
1739 ac_have_as_lzcnt=no
1740 AC_MSG_RESULT([no])
1741])
1742
1743AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1744
sewardj27d176a2011-01-17 11:15:48 +00001745
1746# does the x86/amd64 assembler understand SSE 4.2 instructions?
1747# Note, this doesn't generate a C-level symbol. It generates a
1748# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1749AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1750
bart417cf3e2011-10-22 09:21:24 +00001751AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardj27d176a2011-01-17 11:15:48 +00001752 do { long long int x;
1753 __asm__ __volatile__(
florianfdfca222012-01-17 13:16:50 +00001754 "crc32q %%r15,%%r15" : : : "r15" );
1755 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00001756 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
1757 __asm__ __volatile__(
1758 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
sewardj27d176a2011-01-17 11:15:48 +00001759 while (0)
bart417cf3e2011-10-22 09:21:24 +00001760]])], [
sewardj27d176a2011-01-17 11:15:48 +00001761ac_have_as_sse42=yes
1762AC_MSG_RESULT([yes])
1763], [
1764ac_have_as_sse42=no
1765AC_MSG_RESULT([no])
1766])
1767
1768AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1769
1770
sewardj9fb31ca2012-06-05 00:31:49 +00001771# does the x86/amd64 assembler understand AVX instructions?
1772# Note, this doesn't generate a C-level symbol. It generates a
1773# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
1774AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
1775
1776AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1777 do { long long int x;
1778 __asm__ __volatile__(
1779 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
1780 __asm__ __volatile__(
1781 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
1782 while (0)
1783]])], [
1784ac_have_as_avx=yes
1785AC_MSG_RESULT([yes])
1786], [
1787ac_have_as_avx=no
1788AC_MSG_RESULT([no])
1789])
1790
1791AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
1792
1793
sewardjb08d84d2012-07-16 08:23:26 +00001794# does the x86/amd64 assembler understand MOVBE?
1795# Note, this doesn't generate a C-level symbol. It generates a
1796# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
1797AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
1798
1799AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1800 do { long long int x;
1801 __asm__ __volatile__(
sewardjc62291c2012-07-22 11:10:08 +00001802 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
sewardjb08d84d2012-07-16 08:23:26 +00001803 while (0)
1804]])], [
1805ac_have_as_movbe=yes
1806AC_MSG_RESULT([yes])
1807], [
1808ac_have_as_movbe=no
1809AC_MSG_RESULT([no])
1810])
1811
1812AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
1813
1814
florian251c2f92012-07-05 21:21:37 +00001815# Does the C compiler support the "ifunc" attribute
1816# Note, this doesn't generate a C-level symbol. It generates a
1817# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
1818AC_MSG_CHECKING([if gcc supports the ifunc attribute])
1819
florianf78a5032012-07-06 09:17:29 +00001820AC_LINK_IFELSE([AC_LANG_SOURCE([[
1821static void mytest(void) {}
1822
1823static void (*resolve_test(void))(void)
1824{
1825 return (void (*)(void))&mytest;
1826}
1827
1828void test(void) __attribute__((ifunc("resolve_test")));
1829
1830int main()
1831{
1832 test();
1833 return 0;
1834}
florian251c2f92012-07-05 21:21:37 +00001835]])], [
1836ac_have_ifunc_attr=yes
1837AC_MSG_RESULT([yes])
1838], [
1839ac_have_ifunc_attr=no
1840AC_MSG_RESULT([no])
1841])
1842
1843AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
1844
1845
sewardje089f012010-10-13 21:47:29 +00001846# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1847# when building the tool executables. I think we should get rid of it.
1848#
sewardjb5f6f512005-03-10 23:59:00 +00001849# Check for TLS support in the compiler and linker
bart2bd9a682011-10-22 09:46:16 +00001850AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1851 [[return foo;]])],
1852 [vg_cv_linktime_tls=yes],
1853 [vg_cv_linktime_tls=no])
bartca9f2ad2008-06-02 07:14:20 +00001854# Native compilation: check whether running a program using TLS succeeds.
1855# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1856# succeeds but running programs using TLS fails.
bart2bd9a682011-10-22 09:46:16 +00001857# Cross-compiling: check whether linking a program using TLS succeeds.
bartca9f2ad2008-06-02 07:14:20 +00001858AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1859 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1860 [vg_cv_tls=$enableval],
1861 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1862 [[return foo;]])],
1863 [vg_cv_tls=yes],
bart2bd9a682011-10-22 09:46:16 +00001864 [vg_cv_tls=no],
1865 [vg_cv_tls=$vg_cv_linktime_tls])])])
sewardjb5f6f512005-03-10 23:59:00 +00001866
1867if test "$vg_cv_tls" = yes; then
1868AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1869fi
sewardj5b754b42002-06-03 22:53:35 +00001870
sewardj535c50f2005-06-04 23:14:53 +00001871
njn7fd6d382009-01-22 21:56:32 +00001872#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001873# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001874#----------------------------------------------------------------------------
1875
sewardjde4a1d02002-03-22 01:27:54 +00001876AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001877AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001878 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001879 endian.h \
1880 mqueue.h \
1881 sys/endian.h \
1882 sys/epoll.h \
1883 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001884 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001885 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001886 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001887 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001888 sys/syscall.h \
1889 sys/time.h \
1890 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001891 ])
sewardjde4a1d02002-03-22 01:27:54 +00001892
bart818f17e2011-09-17 06:24:49 +00001893# Verify whether the <linux/futex.h> header is usable.
1894AC_MSG_CHECKING([if <linux/futex.h> is usable])
1895
bart417cf3e2011-10-22 09:21:24 +00001896AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
bart818f17e2011-09-17 06:24:49 +00001897#include <linux/futex.h>
bart417cf3e2011-10-22 09:21:24 +00001898]], [[
bart818f17e2011-09-17 06:24:49 +00001899 return FUTEX_WAIT;
bart417cf3e2011-10-22 09:21:24 +00001900]])], [
bart78bfc712011-12-08 16:14:59 +00001901ac_have_usable_linux_futex_h=yes
bart818f17e2011-09-17 06:24:49 +00001902AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1903 [Define to 1 if you have a usable <linux/futex.h> header file.])
1904AC_MSG_RESULT([yes])
1905], [
bart78bfc712011-12-08 16:14:59 +00001906ac_have_usable_linux_futex_h=no
bart818f17e2011-09-17 06:24:49 +00001907AC_MSG_RESULT([no])
1908])
1909
njn7fd6d382009-01-22 21:56:32 +00001910#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001911# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001912#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001913AC_TYPE_UID_T
1914AC_TYPE_OFF_T
1915AC_TYPE_SIZE_T
1916AC_HEADER_TIME
1917
sewardj535c50f2005-06-04 23:14:53 +00001918
njn7fd6d382009-01-22 21:56:32 +00001919#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001920# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001921#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001922AC_FUNC_MEMCMP
1923AC_FUNC_MMAP
sewardjde4a1d02002-03-22 01:27:54 +00001924
bart26288e42011-04-03 16:46:01 +00001925AC_CHECK_LIB([pthread], [pthread_create])
bart71bad292008-04-27 11:43:23 +00001926AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001927
bartf5ceec82008-04-26 07:45:10 +00001928AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001929 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001930 epoll_create \
1931 epoll_pwait \
bartce48fa92008-04-26 10:59:46 +00001932 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001933 mallinfo \
1934 memchr \
1935 memset \
1936 mkdir \
njnf76d27a2009-05-28 01:53:07 +00001937 mremap \
bartf5ceec82008-04-26 07:45:10 +00001938 ppoll \
bart6d45e922009-01-20 13:45:38 +00001939 pthread_barrier_init \
1940 pthread_condattr_setclock \
1941 pthread_mutex_timedlock \
1942 pthread_rwlock_timedrdlock \
1943 pthread_rwlock_timedwrlock \
1944 pthread_spin_lock \
barta72a27b2010-04-29 06:22:17 +00001945 pthread_yield \
bartd1f724c2009-08-26 18:11:18 +00001946 readlinkat \
bartf5ceec82008-04-26 07:45:10 +00001947 semtimedop \
1948 signalfd \
njn6cc22472009-03-16 03:46:48 +00001949 sigwaitinfo \
bartf5ceec82008-04-26 07:45:10 +00001950 strchr \
1951 strdup \
1952 strpbrk \
1953 strrchr \
1954 strstr \
barta72a27b2010-04-29 06:22:17 +00001955 syscall \
bartf5ceec82008-04-26 07:45:10 +00001956 utimensat \
tom9e4b6362012-02-10 09:39:37 +00001957 process_vm_readv \
1958 process_vm_writev \
bartf5ceec82008-04-26 07:45:10 +00001959 ])
sewardjde4a1d02002-03-22 01:27:54 +00001960
bart623eec32008-07-29 17:54:49 +00001961# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1962# libraries with any shared object and/or executable. This is NOT what we
1963# want for e.g. vgpreload_core-x86-linux.so
1964LIBS=""
sewardj80637752006-03-02 13:48:21 +00001965
bart6d45e922009-01-20 13:45:38 +00001966AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1967 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001968AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1969 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001970AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1971 [test x$ac_cv_func_pthread_spin_lock = xyes])
1972
njn7fd6d382009-01-22 21:56:32 +00001973
1974#----------------------------------------------------------------------------
1975# MPI checks
1976#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001977# Do we have a useable MPI setup on the primary and/or secondary targets?
1978# On Linux, by default, assumes mpicc and -m32/-m64
sewardje9fa5062006-03-12 18:29:18 +00001979# Note: this is a kludge in that it assumes the specified mpicc
sewardj6e9de462011-06-28 07:25:29 +00001980# understands -m32/-m64 regardless of what is specified using
sewardj03d86f22006-10-17 00:57:24 +00001981# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001982MPI_CC="mpicc"
sewardj03d86f22006-10-17 00:57:24 +00001983
sewardje9fa5062006-03-12 18:29:18 +00001984mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001985if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
sewardj6e9de462011-06-28 07:25:29 +00001986 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
sewardj5db15402012-06-07 09:13:21 +00001987 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1988 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001989 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001990elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
sewardjb5b87402011-03-07 16:05:35 +00001991 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1992 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001993 mflag_primary=$FLAG_M64
philippef7c54332012-05-17 15:32:54 +00001994elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
1995 mflag_primary="$FLAG_M32 -arch i386"
1996elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
1997 mflag_primary="$FLAG_M64 -arch x86_64"
sewardje9fa5062006-03-12 18:29:18 +00001998fi
1999
sewardj03d86f22006-10-17 00:57:24 +00002000mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00002001if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2002 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00002003 mflag_secondary=$FLAG_M32
philippef7c54332012-05-17 15:32:54 +00002004elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2005 mflag_secondary="$FLAG_M32 -arch i386"
sewardj03d86f22006-10-17 00:57:24 +00002006fi
2007
2008
sewardj0ad46092006-03-02 17:09:16 +00002009AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00002010 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00002011 MPI_CC=$withval
2012)
sewardj03d86f22006-10-17 00:57:24 +00002013AC_SUBST(MPI_CC)
2014
bart0ab84fe2012-09-09 18:30:17 +00002015#----------------------------------------------------------------------------
2016# Xen checks
2017#----------------------------------------------------------------------------
2018AC_ARG_ENABLE(xen,
2019 [ --enable-xen Enable support for Xen hypervisor],
2020 [vg_cv_xen=$enableval],
2021 [vg_cv_xen=no])
2022
2023AC_ARG_WITH(xen,
2024 [ --with-xen= Specify location of Xen headers],
2025 XEN_CFLAGS=-I$withval
2026)
2027AC_SUBST(XEN_CFLAGS)
2028
2029AM_CONDITIONAL([ENABLE_XEN], [test x$vg_cv_xen = xyes])
2030if test x"$vg_cv_xen" = xyes; then
2031 AC_DEFINE([ENABLE_XEN], 1, [configured to support Xen])
2032fi
2033
philippef7c54332012-05-17 15:32:54 +00002034## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2035## use these values in the check for a functioning mpicc.
2036##
2037## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2038## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2039AM_COND_IF([VGCONF_OS_IS_LINUX],
2040 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2041 LDFLAGS_MPI="-fpic -shared"])
2042AM_COND_IF([VGCONF_OS_IS_DARWIN],
2043 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2044 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2045
2046AC_SUBST([CFLAGS_MPI])
2047AC_SUBST([LDFLAGS_MPI])
2048
2049
sewardj03d86f22006-10-17 00:57:24 +00002050## See if MPI_CC works for the primary target
2051##
2052AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00002053saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00002054saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00002055CC=$MPI_CC
philippef7c54332012-05-17 15:32:54 +00002056CFLAGS="$CFLAGS_MPI $mflag_primary"
2057saved_LDFLAGS="$LDFLAGS"
2058LDFLAGS="$LDFLAGS_MPI $mflag_primary"
bart417cf3e2011-10-22 09:21:24 +00002059AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj1a85e602006-03-08 15:26:10 +00002060#include <mpi.h>
2061#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002062]], [[
philippef7c54332012-05-17 15:32:54 +00002063 int ni, na, nd, comb;
sewardjde4f3842006-03-09 02:41:41 +00002064 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002065 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2066 r |= MPI_Finalize();
sewardjde4f3842006-03-09 02:41:41 +00002067 return r;
bart417cf3e2011-10-22 09:21:24 +00002068]])], [
sewardj03d86f22006-10-17 00:57:24 +00002069ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00002070AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00002071], [
sewardj03d86f22006-10-17 00:57:24 +00002072ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00002073AC_MSG_RESULT([no])
2074])
sewardj0ad46092006-03-02 17:09:16 +00002075CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00002076CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002077LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002078AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00002079
sewardj03d86f22006-10-17 00:57:24 +00002080## See if MPI_CC works for the secondary target. Complication: what if
2081## there is no secondary target? We need this to then fail.
2082## Kludge this by making MPI_CC something which will surely fail in
2083## such a case.
2084##
2085AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2086saved_CC=$CC
2087saved_CFLAGS=$CFLAGS
philippef7c54332012-05-17 15:32:54 +00002088saved_LDFLAGS="$LDFLAGS"
2089LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
njn7fd6d382009-01-22 21:56:32 +00002090if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00002091 CC="$MPI_CC this will surely fail"
2092else
2093 CC=$MPI_CC
2094fi
philippef7c54332012-05-17 15:32:54 +00002095CFLAGS="$CFLAGS_MPI $mflag_secondary"
bart417cf3e2011-10-22 09:21:24 +00002096AC_LINK_IFELSE([AC_LANG_PROGRAM([[
sewardj03d86f22006-10-17 00:57:24 +00002097#include <mpi.h>
2098#include <stdio.h>
bart417cf3e2011-10-22 09:21:24 +00002099]], [[
philippef7c54332012-05-17 15:32:54 +00002100 int ni, na, nd, comb;
sewardj03d86f22006-10-17 00:57:24 +00002101 int r = MPI_Init(NULL,NULL);
philippef7c54332012-05-17 15:32:54 +00002102 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2103 r |= MPI_Finalize();
sewardj03d86f22006-10-17 00:57:24 +00002104 return r;
bart417cf3e2011-10-22 09:21:24 +00002105]])], [
sewardj03d86f22006-10-17 00:57:24 +00002106ac_have_mpi2_sec=yes
2107AC_MSG_RESULT([yes, $MPI_CC])
2108], [
2109ac_have_mpi2_sec=no
2110AC_MSG_RESULT([no])
2111])
2112CC=$saved_CC
2113CFLAGS=$saved_CFLAGS
philippef7c54332012-05-17 15:32:54 +00002114LDFLAGS="$saved_LDFLAGS"
sewardj03d86f22006-10-17 00:57:24 +00002115AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00002116
2117
njn7fd6d382009-01-22 21:56:32 +00002118#----------------------------------------------------------------------------
2119# Other library checks
2120#----------------------------------------------------------------------------
bart2ef12d42010-10-18 16:32:11 +00002121# There now follow some tests for Boost, and OpenMP. These
sewardj493c4ef2008-12-13 16:45:19 +00002122# tests are present because Drd has some regression tests that use
2123# these packages. All regression test programs all compiled only
2124# for the primary target. And so it is important that the configure
2125# checks that follow, use the correct -m32 or -m64 flag for the
2126# primary target (called $mflag_primary). Otherwise, we can end up
2127# in a situation (eg) where, on amd64-linux, the test for Boost checks
2128# for usable 64-bit Boost facilities, but because we are doing a 32-bit
2129# only build (meaning, the primary target is x86-linux), the build
2130# of the regtest programs that use Boost fails, because they are
2131# build as 32-bit (IN THIS EXAMPLE).
2132#
2133# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2134# NEEDED BY THE REGRESSION TEST PROGRAMS.
2135
2136
sewardj493c4ef2008-12-13 16:45:19 +00002137# Check whether the boost library 1.35 or later has been installed.
2138# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2139
2140AC_MSG_CHECKING([for boost])
2141
2142AC_LANG(C++)
2143safe_CXXFLAGS=$CXXFLAGS
bart7129c722012-04-18 18:34:22 +00002144CXXFLAGS="$mflag_primary"
2145safe_LIBS="$LIBS"
2146LIBS="-lboost_thread-mt $LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002147
bart128fc522011-03-12 10:36:35 +00002148AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002149#include <boost/thread.hpp>
2150static void thread_func(void)
2151{ }
2152int main(int argc, char** argv)
2153{
2154 boost::thread t(thread_func);
2155 return 0;
2156}
bart128fc522011-03-12 10:36:35 +00002157])],
sewardj493c4ef2008-12-13 16:45:19 +00002158[
2159ac_have_boost_1_35=yes
2160AC_SUBST([BOOST_CFLAGS], [])
bartbb31f2d2012-04-18 18:42:34 +00002161AC_SUBST([BOOST_LIBS], [-lboost_thread-mt])
sewardj493c4ef2008-12-13 16:45:19 +00002162AC_MSG_RESULT([yes])
2163], [
2164ac_have_boost_1_35=no
2165AC_MSG_RESULT([no])
2166])
2167
bart7129c722012-04-18 18:34:22 +00002168LIBS="$safe_LIBS"
sewardj493c4ef2008-12-13 16:45:19 +00002169CXXFLAGS=$safe_CXXFLAGS
2170AC_LANG(C)
2171
2172AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2173
2174
2175# does this compiler support -fopenmp, does it have the include file
2176# <omp.h> and does it have libgomp ?
2177
2178AC_MSG_CHECKING([for OpenMP])
2179
2180safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00002181CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00002182
bart128fc522011-03-12 10:36:35 +00002183AC_LINK_IFELSE([AC_LANG_SOURCE([
sewardj493c4ef2008-12-13 16:45:19 +00002184#include <omp.h>
2185int main(int argc, char** argv)
2186{
2187 omp_set_dynamic(0);
2188 return 0;
2189}
bart128fc522011-03-12 10:36:35 +00002190])],
sewardj493c4ef2008-12-13 16:45:19 +00002191[
2192ac_have_openmp=yes
2193AC_MSG_RESULT([yes])
2194], [
2195ac_have_openmp=no
2196AC_MSG_RESULT([no])
2197])
2198CFLAGS=$safe_CFLAGS
2199
2200AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2201
2202
bart78bfc712011-12-08 16:14:59 +00002203# does this compiler have built-in functions for atomic memory access for the
2204# primary target ?
2205AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
sewardjc876a2f2009-01-22 22:44:30 +00002206
2207safe_CFLAGS=$CFLAGS
2208CFLAGS="$mflag_primary"
2209
bart417cf3e2011-10-22 09:21:24 +00002210AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
sewardjc876a2f2009-01-22 22:44:30 +00002211 int variable = 1;
2212 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2213 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002214]])], [
bartb4ff7822011-12-10 19:48:04 +00002215 ac_have_builtin_atomic_primary=yes
sewardjc876a2f2009-01-22 22:44:30 +00002216 AC_MSG_RESULT([yes])
bart78bfc712011-12-08 16:14:59 +00002217 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 +00002218], [
bartb4ff7822011-12-10 19:48:04 +00002219 ac_have_builtin_atomic_primary=no
sewardjc876a2f2009-01-22 22:44:30 +00002220 AC_MSG_RESULT([no])
2221])
2222
2223CFLAGS=$safe_CFLAGS
2224
bartb4ff7822011-12-10 19:48:04 +00002225AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2226 [test x$ac_have_builtin_atomic_primary = xyes])
bartc82d1372009-05-31 16:21:23 +00002227
bart78bfc712011-12-08 16:14:59 +00002228
2229# does this compiler have built-in functions for atomic memory access for the
2230# secondary target ?
2231
2232if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2233
2234AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2235
2236safe_CFLAGS=$CFLAGS
2237CFLAGS="$mflag_secondary"
2238
2239AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2240 int variable = 1;
2241 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2242]])], [
2243 ac_have_builtin_atomic_secondary=yes
2244 AC_MSG_RESULT([yes])
2245], [
2246 ac_have_builtin_atomic_secondary=no
2247 AC_MSG_RESULT([no])
2248])
2249
2250CFLAGS=$safe_CFLAGS
2251
2252fi
2253
2254AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2255 [test x$ac_have_builtin_atomic_secondary = xyes])
2256
bart1e856ea2011-12-17 12:53:23 +00002257# does this compiler have built-in functions for atomic memory access on
2258# 64-bit integers for all targets ?
2259
2260AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2261
2262AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2263 #include <stdint.h>
2264]], [[
2265 uint64_t variable = 1;
2266 return __sync_add_and_fetch(&variable, 1)
2267]])], [
2268 ac_have_builtin_atomic64_primary=yes
2269], [
2270 ac_have_builtin_atomic64_primary=no
2271])
2272
2273if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2274
2275safe_CFLAGS=$CFLAGS
2276CFLAGS="$mflag_secondary"
2277
2278AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2279 #include <stdint.h>
2280]], [[
2281 uint64_t variable = 1;
2282 return __sync_add_and_fetch(&variable, 1)
2283]])], [
2284 ac_have_builtin_atomic64_secondary=yes
2285], [
2286 ac_have_builtin_atomic64_secondary=no
2287])
2288
2289CFLAGS=$safe_CFLAGS
2290
2291fi
2292
2293if test x$ac_have_builtin_atomic64_primary = xyes && \
2294 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2295 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2296 AC_MSG_RESULT([yes])
2297 ac_have_builtin_atomic64=yes
2298else
2299 AC_MSG_RESULT([no])
2300 ac_have_builtin_atomic64=no
2301fi
2302
2303AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2304 [test x$ac_have_builtin_atomic64 = xyes])
2305
bart78bfc712011-12-08 16:14:59 +00002306
barte8740422011-03-24 20:27:54 +00002307# does g++ have built-in functions for atomic memory access ?
bart78bfc712011-12-08 16:14:59 +00002308AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
barte8740422011-03-24 20:27:54 +00002309
2310safe_CXXFLAGS=$CXXFLAGS
2311CXXFLAGS="$mflag_primary"
2312
2313AC_LANG_PUSH(C++)
bart417cf3e2011-10-22 09:21:24 +00002314AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
barte8740422011-03-24 20:27:54 +00002315 int variable = 1;
2316 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2317 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
bart417cf3e2011-10-22 09:21:24 +00002318]])], [
barte8740422011-03-24 20:27:54 +00002319 ac_have_builtin_atomic_cxx=yes
2320 AC_MSG_RESULT([yes])
2321 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 +00002322], [
barte8740422011-03-24 20:27:54 +00002323 ac_have_builtin_atomic_cxx=no
2324 AC_MSG_RESULT([no])
2325])
2326AC_LANG_POP(C++)
2327
2328CXXFLAGS=$safe_CXXFLAGS
2329
2330AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
sewardjc876a2f2009-01-22 22:44:30 +00002331
bart78bfc712011-12-08 16:14:59 +00002332
2333if test x$ac_have_usable_linux_futex_h = xyes \
bartb4ff7822011-12-10 19:48:04 +00002334 -a x$ac_have_builtin_atomic_primary = xyes; then
bart78bfc712011-12-08 16:14:59 +00002335 ac_enable_linux_ticket_lock_primary=yes
2336fi
2337AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2338 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2339
2340if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2341 -a x$ac_have_usable_linux_futex_h = xyes \
2342 -a x$ac_have_builtin_atomic_secondary = xyes; then
2343 ac_enable_linux_ticket_lock_secondary=yes
2344fi
2345AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2346 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2347
2348
bartf68af882011-12-10 19:42:05 +00002349# does libstdc++ support annotating shared pointers ?
2350AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2351
2352safe_CXXFLAGS=$CFLAGS
2353CXXFLAGS="-std=c++0x"
2354
2355AC_LANG_PUSH(C++)
2356AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2357 #include <memory>
2358]], [[
2359 std::shared_ptr<int> p
2360]])], [
2361 ac_have_shared_ptr=yes
2362], [
2363 ac_have_shared_ptr=no
2364])
2365if test x$ac_have_shared_ptr = xyes; then
2366 # If compilation of the program below fails because of a syntax error
2367 # triggered by substituting one of the annotation macros then that
2368 # means that libstdc++ supports these macros.
2369 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2370 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2371 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2372 #include <memory>
2373 ]], [[
2374 std::shared_ptr<int> p
2375 ]])], [
2376 ac_have_shared_pointer_annotation=no
2377 AC_MSG_RESULT([no])
2378 ], [
2379 ac_have_shared_pointer_annotation=yes
2380 AC_MSG_RESULT([yes])
2381 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2382 [Define to 1 if libstd++ supports annotating shared pointers])
2383 ])
2384else
2385 ac_have_shared_pointer_annotation=no
2386 AC_MSG_RESULT([no])
2387fi
2388AC_LANG_POP(C++)
2389
2390CXXFLAGS=$safe_CXXFLAGS
2391
2392AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2393 [test x$ac_have_shared_pointer_annotation = xyes])
2394
2395
njn7fd6d382009-01-22 21:56:32 +00002396#----------------------------------------------------------------------------
2397# Ok. We're done checking.
2398#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00002399
njn8b68b642009-06-24 00:37:09 +00002400# Nb: VEX/Makefile is generated from Makefile.vex.in.
2401AC_CONFIG_FILES([
sewardjde4a1d02002-03-22 01:27:54 +00002402 Makefile
njn8b68b642009-06-24 00:37:09 +00002403 VEX/Makefile:Makefile.vex.in
njn25cac76cb2002-09-23 11:21:57 +00002404 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00002405 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00002406 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00002407 docs/Makefile
2408 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00002409 tests/vg_regtest
njnec0c27a2005-12-10 23:11:28 +00002410 perf/Makefile
2411 perf/vg_perf
sewardj3b290482011-05-06 21:02:55 +00002412 gdbserver_tests/Makefile
njn254d542432002-09-23 16:09:39 +00002413 include/Makefile
njn7a6e7462002-11-09 17:53:30 +00002414 auxprogs/Makefile
njn8b68b642009-06-24 00:37:09 +00002415 mpi/Makefile
njn25ab726032002-09-23 16:24:41 +00002416 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002417 memcheck/Makefile
2418 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002419 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00002420 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00002421 memcheck/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002422 memcheck/tests/darwin/Makefile
njnea2d6fd2010-07-01 00:20:20 +00002423 memcheck/tests/amd64-linux/Makefile
njna454ec02009-01-19 03:16:59 +00002424 memcheck/tests/x86-linux/Makefile
sewardj0e342a02010-09-03 23:49:33 +00002425 memcheck/tests/ppc32/Makefile
2426 memcheck/tests/ppc64/Makefile
florian0bb707e2012-05-30 20:46:58 +00002427 memcheck/tests/s390x/Makefile
florianbb913cd2012-08-28 16:50:39 +00002428 memcheck/tests/vbit-test/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002429 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002430 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002431 cachegrind/tests/x86/Makefile
njnf2df9b52002-10-04 11:35:47 +00002432 cachegrind/cg_annotate
njn69d495d2010-06-30 05:23:34 +00002433 cachegrind/cg_diff
weidendoa17f2a32006-03-20 10:27:30 +00002434 callgrind/Makefile
2435 callgrind/callgrind_annotate
2436 callgrind/callgrind_control
2437 callgrind/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002438 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00002439 helgrind/tests/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002440 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00002441 massif/tests/Makefile
njnd5a8d242007-11-02 20:44:57 +00002442 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00002443 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00002444 lackey/tests/Makefile
njn25cac76cb2002-09-23 11:21:57 +00002445 none/Makefile
2446 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00002447 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00002448 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00002449 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00002450 none/tests/x86/Makefile
sewardj59570ff2010-01-01 11:59:33 +00002451 none/tests/arm/Makefile
sewardjb5b87402011-03-07 16:05:35 +00002452 none/tests/s390x/Makefile
sewardj5db15402012-06-07 09:13:21 +00002453 none/tests/mips32/Makefile
njn0458a122009-02-13 06:23:46 +00002454 none/tests/linux/Makefile
njnf76d27a2009-05-28 01:53:07 +00002455 none/tests/darwin/Makefile
njn06ca3322009-04-15 23:10:04 +00002456 none/tests/x86-linux/Makefile
sewardjd2f95a02011-05-11 16:04:28 +00002457 exp-sgcheck/Makefile
2458 exp-sgcheck/tests/Makefile
bartccf17de2008-07-04 15:14:35 +00002459 drd/Makefile
bartccf17de2008-07-04 15:14:35 +00002460 drd/scripts/download-and-build-splash2
2461 drd/tests/Makefile
njndbebecc2009-07-14 01:39:54 +00002462 exp-bbv/Makefile
njndbebecc2009-07-14 01:39:54 +00002463 exp-bbv/tests/Makefile
2464 exp-bbv/tests/x86/Makefile
2465 exp-bbv/tests/x86-linux/Makefile
2466 exp-bbv/tests/amd64-linux/Makefile
2467 exp-bbv/tests/ppc32-linux/Makefile
vince226e0782010-01-06 15:22:11 +00002468 exp-bbv/tests/arm-linux/Makefile
sewardj4d7d8f52010-10-12 10:09:15 +00002469 exp-dhat/Makefile
2470 exp-dhat/tests/Makefile
njn8b68b642009-06-24 00:37:09 +00002471])
sewardjd3645802010-06-13 22:13:58 +00002472AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2473 [chmod +x coregrind/link_tool_exe_linux])
2474AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2475 [chmod +x coregrind/link_tool_exe_darwin])
njn8b68b642009-06-24 00:37:09 +00002476AC_OUTPUT
gobry3b777892002-04-04 09:18:39 +00002477
2478cat<<EOF
2479
njn311303f2009-02-06 03:46:50 +00002480 Maximum build arch: ${ARCH_MAX}
2481 Primary build arch: ${VGCONF_ARCH_PRI}
njn3f8a6e92009-06-02 00:20:47 +00002482 Secondary build arch: ${VGCONF_ARCH_SEC}
njn311303f2009-02-06 03:46:50 +00002483 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00002484 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2485 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardjcb495c82011-07-11 20:42:34 +00002486 Platform variant: ${VGCONF_PLATVARIANT}
2487 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
sewardje95d94f2008-09-19 09:02:19 +00002488 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00002489
gobry3b777892002-04-04 09:18:39 +00002490EOF