2 ##------------------------------------------------------------##
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.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
11 AC_INIT([Valgrind],[3.9.0.SVN],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign])
18 #----------------------------------------------------------------------------
19 # Checks for various programs.
20 #----------------------------------------------------------------------------
21 CFLAGS="-Wno-long-long $CFLAGS"
28 # 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
32 # - 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],
37 # [AC_CHECK_TOOL([OBJC], [gcc])
39 # AC_SUBST([OBJCFLAGS])
42 # provide a very basic definition for AC_PROG_SED if it's not provided by
43 # autoconf (as e.g. in autoconf 2.59).
44 m4_ifndef([AC_PROG_SED],
45 [AC_DEFUN([AC_PROG_SED],
47 AC_CHECK_PROGS([SED],[gsed sed])])])
50 # If no AR variable was specified, look up the name of the archiver. Otherwise
51 # do not touch the AR variable.
52 if test "x$AR" = "x"; then
53 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
55 AC_ARG_VAR([AR],[Archiver command])
57 # Check for the compiler support
58 if test "${GCC}" != "yes" ; then
59 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
62 # figure out where perl lives
63 AC_PATH_PROG(PERL, perl)
65 # figure out where gdb lives
66 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
67 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
69 # some older automake's don't have it so try something on our own
70 ifdef([AM_PROG_AS],[AM_PROG_AS],
80 # Check if 'diff' supports -u (universal diffs) and use it if possible.
82 AC_MSG_CHECKING([for diff -u])
85 # Comparing two identical files results in 0.
86 tmpfile="tmp-xxx-yyy-zzz"
88 if diff -u $tmpfile $tmpfile ; then
98 # We don't want gcc < 3.0
99 AC_MSG_CHECKING([for a supported version of gcc])
101 # Obtain the compiler version.
103 # A few examples of how the ${CC} --version output looks like:
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
109 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
110 # 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)
113 # 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
117 if test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ; then
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'`
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'`
130 case "${is_clang}-${gcc_version}" in
132 AC_MSG_RESULT([ok (${gcc_version})])
135 AC_MSG_RESULT([ok (${gcc_version})])
137 clang-2.9|clang-3.*|clang-4.*)
138 AC_MSG_RESULT([ok (clang-${gcc_version})])
141 AC_MSG_RESULT([no (${gcc_version})])
142 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
146 #----------------------------------------------------------------------------
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.
156 AC_MSG_CHECKING([for a supported CPU])
158 # 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
162 case "${host_cpu}" in
164 AC_MSG_RESULT([ok (${host_cpu})])
169 AC_MSG_RESULT([ok (${host_cpu})])
174 AC_MSG_RESULT([ok (${host_cpu})])
179 # On Linux this means only a 32-bit capable CPU.
180 AC_MSG_RESULT([ok (${host_cpu})])
185 AC_MSG_RESULT([ok (${host_cpu})])
190 AC_MSG_RESULT([ok (${host_cpu})])
195 AC_MSG_RESULT([ok (${host_cpu})])
200 AC_MSG_RESULT([ok (${host_cpu})])
205 AC_MSG_RESULT([ok (${host_cpu})])
210 AC_MSG_RESULT([no (${host_cpu})])
211 AC_MSG_ERROR([Unsupported host architecture. Sorry])
215 #----------------------------------------------------------------------------
217 # 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 :-)
221 # [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
225 # Check if a 64-bit only build has been requested
226 AC_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])])
232 # Check if a 32-bit only build has been requested
233 AC_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])])
240 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
242 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
245 #----------------------------------------------------------------------------
247 # 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).
250 AC_MSG_CHECKING([for a supported OS])
257 AC_MSG_RESULT([ok (${host_os})])
260 # Ok, this is linux. Check the kernel version
261 AC_MSG_CHECKING([for the kernel version])
267 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])
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])
277 AC_MSG_RESULT([unsupported (${kernel})])
278 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
285 AC_MSG_RESULT([ok (${host_os})])
287 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])
290 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
292 AC_MSG_CHECKING([for the kernel version])
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
298 # 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),
300 # and we don't know of an macros similar to __GLIBC__ to get that info.
302 # XXX: `uname -r` won't do the right thing for cross-compiles, but
303 # that's not a problem yet.
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.
313 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
314 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
315 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
316 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
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}"
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])
327 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
328 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
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}"
337 AC_MSG_RESULT([unsupported (${kernel})])
338 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
344 AC_MSG_RESULT([no (${host_os})])
345 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
349 #----------------------------------------------------------------------------
351 # 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
355 case "$ARCH_MAX-$VGCONF_OS" in
356 amd64-linux|ppc64-linux)
357 AC_MSG_CHECKING([for 32 bit build support])
360 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
365 vg_cv_only64bit="yes"
368 CFLAGS=$safe_CFLAGS;;
371 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
373 [--enable-only32bit was specified but system does not support 32 bit builds])
376 #----------------------------------------------------------------------------
378 # 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
384 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
385 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
386 AC_SUBST(VGCONF_ARCH_PRI)
388 # 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.
392 AC_SUBST(VGCONF_ARCH_SEC)
394 # 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
398 # used to create various Makefile variables, which are all in caps by
399 # convention and cannot contain '-' characters. This is in contrast to
400 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
401 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
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.
407 # 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.
411 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
413 AC_MSG_CHECKING([for a supported CPU/OS combination])
415 # 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".
422 case "$ARCH_MAX-$VGCONF_OS" in
424 VGCONF_ARCH_PRI="x86"
426 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
427 VGCONF_PLATFORM_SEC_CAPS=""
428 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"
432 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
435 valt_load_address_sec_norml="0xUNSET"
436 valt_load_address_sec_inner="0xUNSET"
437 if test x$vg_cv_only64bit = xyes; then
438 VGCONF_ARCH_PRI="amd64"
440 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
441 VGCONF_PLATFORM_SEC_CAPS=""
442 valt_load_address_pri_norml="0x38000000"
443 valt_load_address_pri_inner="0x28000000"
444 elif test x$vg_cv_only32bit = xyes; then
445 VGCONF_ARCH_PRI="x86"
447 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
448 VGCONF_PLATFORM_SEC_CAPS=""
449 valt_load_address_pri_norml="0x38000000"
450 valt_load_address_pri_inner="0x28000000"
452 VGCONF_ARCH_PRI="amd64"
453 VGCONF_ARCH_SEC="x86"
454 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
455 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
456 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"
461 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
464 VGCONF_ARCH_PRI="ppc32"
466 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
467 VGCONF_PLATFORM_SEC_CAPS=""
468 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"
472 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
475 valt_load_address_sec_norml="0xUNSET"
476 valt_load_address_sec_inner="0xUNSET"
477 if test x$vg_cv_only64bit = xyes; then
478 VGCONF_ARCH_PRI="ppc64"
480 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
481 VGCONF_PLATFORM_SEC_CAPS=""
482 valt_load_address_pri_norml="0x38000000"
483 valt_load_address_pri_inner="0x28000000"
484 elif test x$vg_cv_only32bit = xyes; then
485 VGCONF_ARCH_PRI="ppc32"
487 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
488 VGCONF_PLATFORM_SEC_CAPS=""
489 valt_load_address_pri_norml="0x38000000"
490 valt_load_address_pri_inner="0x28000000"
492 VGCONF_ARCH_PRI="ppc64"
493 VGCONF_ARCH_SEC="ppc32"
494 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
495 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
496 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"
501 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
503 # 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)
510 valt_load_address_sec_norml="0xUNSET"
511 valt_load_address_sec_inner="0xUNSET"
512 if test x$vg_cv_only64bit = xyes; then
513 VGCONF_ARCH_PRI="amd64"
515 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
516 VGCONF_PLATFORM_SEC_CAPS=""
517 valt_load_address_pri_norml="0x138000000"
518 valt_load_address_pri_inner="0x128000000"
519 elif test x$vg_cv_only32bit = xyes; then
520 VGCONF_ARCH_PRI="x86"
522 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
523 VGCONF_PLATFORM_SEC_CAPS=""
524 VGCONF_ARCH_PRI_CAPS="x86"
525 valt_load_address_pri_norml="0x38000000"
526 valt_load_address_pri_inner="0x28000000"
528 VGCONF_ARCH_PRI="amd64"
529 VGCONF_ARCH_SEC="x86"
530 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
531 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
532 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"
537 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
540 VGCONF_ARCH_PRI="arm"
541 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
542 VGCONF_PLATFORM_SEC_CAPS=""
543 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"
547 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
550 VGCONF_ARCH_PRI="s390x"
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})])
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})])
573 VGCONF_ARCH_PRI="unknown"
574 VGCONF_ARCH_SEC="unknown"
575 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
576 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
577 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"
581 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
582 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
586 #----------------------------------------------------------------------------
588 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
590 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
591 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
592 -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 )
595 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
596 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
597 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
598 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
599 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
600 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
601 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
602 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
603 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
604 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
605 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
606 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
607 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
608 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
610 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
612 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
613 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
614 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
615 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
616 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
617 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
618 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
619 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
620 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
621 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
622 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
623 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
624 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
625 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
626 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
627 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
628 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
630 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
631 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
632 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
633 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
634 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
637 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
638 # Relies on the assumption that the primary and secondary targets are
639 # for the same OS, so therefore only necessary to test the primary.
640 AM_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 \
644 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
645 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
646 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
647 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
648 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
649 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
650 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
653 # Sometimes, in the Makefile.am files, it's useful to know whether or not
654 # there is a secondary target.
655 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
656 test x$VGCONF_PLATFORM_SEC_CAPS != x)
658 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
659 dnl fallback definition
660 dnl The macro is courtesy of Dave Hart:
661 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
662 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
663 if test -z "$$1_TRUE"; then :
672 #----------------------------------------------------------------------------
674 #----------------------------------------------------------------------------
676 # Check if this should be built as an inner Valgrind, to be run within
677 # another Valgrind. Choose the load address accordingly.
678 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
679 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
680 AC_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],
685 if test "$vg_cv_inner" = yes; then
686 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
687 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
688 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
690 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
691 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
695 #----------------------------------------------------------------------------
696 # Define MIPS_PAGE_SHIFT (--with-pagesize)
697 #----------------------------------------------------------------------------
698 AC_ARG_WITH(pagesize,
699 [ --with-pagesize= override detected page size (4, 16 or 64)],
704 if test "$psize" = "0"; then
705 psizer=`getconf PAGESIZE`
706 let "psize=${psizer}/1024"
709 if test "$psize" = "4"; then
710 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
711 elif test "$psize" = "16"; then
712 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
713 elif test "$psize" = "64"; then
714 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
716 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
718 AC_MSG_RESULT([checking for Pagesize... ${psize}k])
720 #----------------------------------------------------------------------------
721 # Define shm_align for MIPS (--shared-memory-alignment)
722 #----------------------------------------------------------------------------
723 AC_ARG_WITH(alignment,
724 [ --with-alignment= shared memory alignment for MIPS],
729 mod=`expr $align % 1024`
731 let "psz=psize*1024*2"
733 if 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])
737 elif test "$mod" = "0"; then
738 if test $align -lt $psz;
740 AC_MSG_ERROR([Alignment must be >= PAGE_SIZE])
742 AC_DEFINE_UNQUOTED([SHM_ALIGNMENT], ${align},
743 [configured memory alignment 2*PAGE_SIZE])
744 AC_MSG_RESULT([checking for shared memory alignment... ${align}])
747 AC_MSG_ERROR([Alignment % 1024 must be zero])
751 #----------------------------------------------------------------------------
752 # Extra fine-tuning of installation directories
753 #----------------------------------------------------------------------------
755 [ --with-tmpdir=PATH Specify path for temporary files],
758 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
761 #----------------------------------------------------------------------------
762 # Libc and suppressions
763 #----------------------------------------------------------------------------
764 # This variable will collect the suppression files to be used.
765 AC_SUBST(DEFAULT_SUPP)
767 AC_CHECK_HEADER([features.h])
769 if test x$ac_cv_header_features_h = xyes; then
770 rm -f conftest.$ac_ext
771 cat <<_ACEOF >conftest.$ac_ext
772 #include <features.h>
773 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
774 glibc version is: __GLIBC__ __GLIBC_MINOR__
777 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
780 # not really a version check
781 AC_EGREP_CPP([DARWIN_LIBC], [
782 #include <sys/cdefs.h>
783 #if defined(__DARWIN_VERS_1050)
787 GLIBC_VERSION="darwin")
789 # not really a version check
790 AC_EGREP_CPP([BIONIC_LIBC], [
791 #if defined(__ANDROID__)
795 GLIBC_VERSION="bionic")
798 AC_MSG_CHECKING([the GLIBC_VERSION version])
800 case "${GLIBC_VERSION}" in
802 AC_MSG_RESULT(2.2 family)
803 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
804 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
805 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
806 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
810 AC_MSG_RESULT(2.3 family)
811 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
812 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
813 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
814 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
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])
820 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
821 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
822 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
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])
828 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
829 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
830 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
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])
835 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
836 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
837 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
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])
842 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
843 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
844 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
847 AC_MSG_RESULT(2.8 family)
848 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
849 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}"
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}"
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}"
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}"
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}"
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}"
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}"
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}"
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}"
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.
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}"
921 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
922 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.16])
923 AC_MSG_ERROR([or Darwin libc])
927 AC_SUBST(GLIBC_VERSION)
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.
934 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
935 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
937 # Add glibc and X11 suppressions for exp-sgcheck
938 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
941 #----------------------------------------------------------------------------
943 #----------------------------------------------------------------------------
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
947 # 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.
952 # In almost all cases, the <variant> bit is "vanilla". But for Android
953 # it is "android" instead.
955 # Consequently (eg), plain arm-linux would build with
957 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
959 # whilst an Android build would have
961 # -DVGP_arm_linux -DVGPV_arm_linux_android
963 # 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.
966 # In the normal case ..
967 VGCONF_PLATVARIANT="vanilla"
970 if test "$GLIBC_VERSION" = "bionic";
972 VGCONF_PLATVARIANT="android"
975 AC_SUBST(VGCONF_PLATVARIANT)
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
986 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
988 # Hmm. Can't think of a nice clean solution to this.
990 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
991 test x$VGCONF_PLATVARIANT = xvanilla)
992 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
993 test x$VGCONF_PLATVARIANT = xandroid)
996 #----------------------------------------------------------------------------
997 # Checking for various library functions and other definitions
998 #----------------------------------------------------------------------------
1000 # Check for CLOCK_MONOTONIC
1002 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1004 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1008 clock_gettime(CLOCK_MONOTONIC, &t);
1011 AC_MSG_RESULT([yes])
1012 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1013 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1019 # Check for PTHREAD_RWLOCK_T
1021 AC_MSG_CHECKING([for pthread_rwlock_t])
1023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1025 #include <pthread.h>
1027 pthread_rwlock_t rwl;
1029 AC_MSG_RESULT([yes])
1030 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1031 [Define to 1 if you have the `pthread_rwlock_t' type.])
1037 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1039 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1041 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1043 #include <pthread.h>
1045 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1047 AC_MSG_RESULT([yes])
1048 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1049 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1055 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1057 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1061 #include <pthread.h>
1063 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1065 AC_MSG_RESULT([yes])
1066 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1067 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1073 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1075 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1077 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1079 #include <pthread.h>
1081 return (PTHREAD_MUTEX_RECURSIVE_NP);
1083 AC_MSG_RESULT([yes])
1084 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1085 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1091 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1093 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1095 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1097 #include <pthread.h>
1099 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1102 AC_MSG_RESULT([yes])
1103 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1104 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1110 # Check whether pthread_mutex_t has a member called __m_kind.
1112 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1113 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1115 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1118 [#include <pthread.h>])
1121 # Check whether pthread_mutex_t has a member called __data.__kind.
1123 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1124 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1126 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1129 [#include <pthread.h>])
1132 # does this compiler support -maltivec and does it have the include file
1135 AC_MSG_CHECKING([for Altivec])
1140 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1141 #include <altivec.h>
1143 vector unsigned int v;
1146 AC_MSG_RESULT([yes])
1147 AC_DEFINE([HAS_ALTIVEC], 1,
1148 [Define to 1 if gcc/as can do Altivec.])
1155 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1158 # 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.
1166 AC_MSG_CHECKING([for VSX])
1171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1172 #include <altivec.h>
1174 vector unsigned int v;
1175 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1178 AC_MSG_RESULT([yes])
1185 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1188 AC_MSG_CHECKING([that assembler knows DFP])
1190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1192 __asm__ __volatile__("dadd 1, 2, 3");
1193 __asm__ __volatile__("dcffix 1, 2");
1196 AC_MSG_RESULT([yes])
1203 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1208 __asm__ __volatile__("dadd 1, 2, 3");
1209 __asm__ __volatile__("dcffix 1, 2");
1212 AC_MSG_RESULT([yes])
1220 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
1223 # Check for pthread_create@GLIBC2.0
1224 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1228 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1229 extern 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");
1235 * Apparently on PowerPC linking this program succeeds and generates an
1236 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1238 #error This test does not work properly on PowerPC.
1240 pthread_create_glibc_2_0(0, 0, 0, 0);
1244 ac_have_pthread_create_glibc_2_0=yes
1245 AC_MSG_RESULT([yes])
1246 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1247 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1249 ac_have_pthread_create_glibc_2_0=no
1254 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1255 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1258 # Check for eventfd_t, eventfd() and eventfd_read()
1259 AC_MSG_CHECKING([for eventfd()])
1261 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1262 #include <sys/eventfd.h>
1268 eventfd_read(fd, &ev);
1271 AC_MSG_RESULT([yes])
1272 AC_DEFINE([HAVE_EVENTFD], 1,
1273 [Define to 1 if you have the `eventfd' function.])
1274 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1275 [Define to 1 if you have the `eventfd_read' function.])
1281 #----------------------------------------------------------------------------
1282 # Checking for supported compiler flags.
1283 #----------------------------------------------------------------------------
1285 # does this compiler support -m32 ?
1286 AC_MSG_CHECKING([if gcc accepts -m32])
1291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1295 AC_MSG_RESULT([yes])
1305 # does this compiler support -m64 ?
1306 AC_MSG_CHECKING([if gcc accepts -m64])
1311 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1315 AC_MSG_RESULT([yes])
1325 # does this compiler support -mmmx ?
1326 AC_MSG_CHECKING([if gcc accepts -mmmx])
1331 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1335 AC_MSG_RESULT([yes])
1345 # does this compiler support -msse ?
1346 AC_MSG_CHECKING([if gcc accepts -msse])
1351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1355 AC_MSG_RESULT([yes])
1365 # does this compiler support -mpreferred-stack-boundary=2 ?
1366 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1369 CFLAGS="-mpreferred-stack-boundary=2"
1371 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1374 PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
1375 AC_MSG_RESULT([yes])
1377 PREFERRED_STACK_BOUNDARY=""
1382 AC_SUBST(PREFERRED_STACK_BOUNDARY)
1385 # does this compiler support -Wno-pointer-sign ?
1386 AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
1389 CFLAGS="-Wno-pointer-sign"
1391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1395 AC_MSG_RESULT([yes])
1402 if test x$no_pointer_sign = xyes; then
1403 CFLAGS="$CFLAGS -Wno-pointer-sign"
1407 # does this compiler support -Wno-empty-body ?
1409 AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1412 CFLAGS="-Wno-empty-body"
1414 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1417 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1418 AC_MSG_RESULT([yes])
1420 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1426 # does this compiler support -Wno-format-zero-length ?
1428 AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1431 CFLAGS="-Wno-format-zero-length"
1433 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1436 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1437 AC_MSG_RESULT([yes])
1439 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1445 # does this compiler support -Wno-nonnull ?
1447 AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1450 CFLAGS="-Wno-nonnull"
1452 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1455 AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1456 AC_MSG_RESULT([yes])
1458 AC_SUBST([FLAG_W_NO_NONNULL], [])
1464 # does this compiler support -Wno-overflow ?
1466 AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1469 CFLAGS="-Wno-overflow"
1471 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1474 AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1475 AC_MSG_RESULT([yes])
1477 AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1483 # does this compiler support -Wno-uninitialized ?
1485 AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1488 CFLAGS="-Wno-uninitialized"
1490 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1493 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1494 AC_MSG_RESULT([yes])
1496 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1502 # does this compiler support -Wextra or the older -W ?
1504 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1512 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1513 AC_MSG_RESULT([-Wextra])
1516 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1519 AC_SUBST([FLAG_W_EXTRA], [-W])
1522 AC_SUBST([FLAG_W_EXTRA], [])
1523 AC_MSG_RESULT([not supported])
1529 # does this compiler support -fno-stack-protector ?
1530 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1533 CFLAGS="-fno-stack-protector"
1535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1538 no_stack_protector=yes
1539 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1540 AC_MSG_RESULT([yes])
1542 no_stack_protector=no
1543 FLAG_FNO_STACK_PROTECTOR=""
1548 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1550 if test x$no_stack_protector = xyes; then
1551 CFLAGS="$CFLAGS -fno-stack-protector"
1555 # does this compiler support --param inline-unit-growth=... ?
1557 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1560 CFLAGS="--param inline-unit-growth=900"
1562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1565 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1566 ["--param inline-unit-growth=900"])
1567 AC_MSG_RESULT([yes])
1569 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1575 # does this compiler support -gdwarf-4 -fdebug-types-section ?
1577 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1580 CFLAGS="-gdwarf-4 -fdebug-types-section"
1582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1586 AC_MSG_RESULT([yes])
1591 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1595 # 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
1600 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1603 CFLAGS="-Wl,--build-id=none"
1606 [AC_LANG_PROGRAM([ ], [return 0;])],
1608 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1609 AC_MSG_RESULT([yes])
1611 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1617 # does the ppc assembler support "mtocrf" et al?
1618 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1620 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1621 __asm__ __volatile__("mtocrf 4,0");
1622 __asm__ __volatile__("mfocrf 0,4");
1624 ac_have_as_ppc_mftocrf=yes
1625 AC_MSG_RESULT([yes])
1627 ac_have_as_ppc_mftocrf=no
1630 if 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.])
1637 # does the x86/amd64 assembler understand SSE3 instructions?
1638 # 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
1640 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1642 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1643 do { long long int x;
1644 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1648 AC_MSG_RESULT([yes])
1654 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
1657 # 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
1660 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1662 save_CFLAGS="$CFLAGS"
1663 CFLAGS="$CFLAGS -msse"
1664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1665 do { long long int x;
1666 __asm__ __volatile__(
1667 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1670 ac_have_as_ssse3=yes
1671 AC_MSG_RESULT([yes])
1676 CFLAGS="$save_CFLAGS"
1678 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1681 # 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
1684 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
1685 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1687 __asm__ __volatile__(
1688 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1691 ac_have_as_pclmulqdq=yes
1692 AC_MSG_RESULT([yes])
1694 ac_have_as_pclmulqdq=no
1698 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1701 # 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
1704 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
1705 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
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.
1712 __asm__ __volatile__(
1713 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
1716 ac_have_as_vpclmulqdq=yes
1717 AC_MSG_RESULT([yes])
1719 ac_have_as_vpclmulqdq=no
1723 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
1726 # 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
1729 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1733 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
1736 ac_have_as_lzcnt=yes
1737 AC_MSG_RESULT([yes])
1743 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
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
1749 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1751 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1752 do { long long int x;
1753 __asm__ __volatile__(
1754 "crc32q %%r15,%%r15" : : : "r15" );
1755 __asm__ __volatile__(
1756 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
1757 __asm__ __volatile__(
1758 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
1761 ac_have_as_sse42=yes
1762 AC_MSG_RESULT([yes])
1768 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1771 # 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
1774 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
1776 AC_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"); }
1785 AC_MSG_RESULT([yes])
1791 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
1794 # 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
1797 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
1799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1800 do { long long int x;
1801 __asm__ __volatile__(
1802 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
1805 ac_have_as_movbe=yes
1806 AC_MSG_RESULT([yes])
1812 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
1815 # 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
1818 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
1820 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1821 static void mytest(void) {}
1823 static void (*resolve_test(void))(void)
1825 return (void (*)(void))&mytest;
1828 void test(void) __attribute__((ifunc("resolve_test")));
1836 ac_have_ifunc_attr=yes
1837 AC_MSG_RESULT([yes])
1839 ac_have_ifunc_attr=no
1843 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
1846 # 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.
1849 # Check for TLS support in the compiler and linker
1850 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1852 [vg_cv_linktime_tls=yes],
1853 [vg_cv_linktime_tls=no])
1854 # 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.
1857 # Cross-compiling: check whether linking a program using TLS succeeds.
1858 AC_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;]],
1865 [vg_cv_tls=$vg_cv_linktime_tls])])])
1867 if test "$vg_cv_tls" = yes; then
1868 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1872 #----------------------------------------------------------------------------
1873 # Checks for C header files.
1874 #----------------------------------------------------------------------------
1877 AC_CHECK_HEADERS([ \
1893 # Verify whether the <linux/futex.h> header is usable.
1894 AC_MSG_CHECKING([if <linux/futex.h> is usable])
1896 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1897 #include <linux/futex.h>
1901 ac_have_usable_linux_futex_h=yes
1902 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1903 [Define to 1 if you have a usable <linux/futex.h> header file.])
1904 AC_MSG_RESULT([yes])
1906 ac_have_usable_linux_futex_h=no
1910 #----------------------------------------------------------------------------
1911 # Checks for typedefs, structures, and compiler characteristics.
1912 #----------------------------------------------------------------------------
1919 #----------------------------------------------------------------------------
1920 # Checks for library functions.
1921 #----------------------------------------------------------------------------
1925 AC_CHECK_LIB([pthread], [pthread_create])
1926 AC_CHECK_LIB([rt], [clock_gettime])
1939 pthread_barrier_init \
1940 pthread_condattr_setclock \
1941 pthread_mutex_timedlock \
1942 pthread_rwlock_timedrdlock \
1943 pthread_rwlock_timedwrlock \
1961 # 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
1966 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1967 [test x$ac_cv_func_pthread_barrier_init = xyes])
1968 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1969 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
1970 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1971 [test x$ac_cv_func_pthread_spin_lock = xyes])
1974 #----------------------------------------------------------------------------
1976 #----------------------------------------------------------------------------
1977 # Do we have a useable MPI setup on the primary and/or secondary targets?
1978 # On Linux, by default, assumes mpicc and -m32/-m64
1979 # Note: this is a kludge in that it assumes the specified mpicc
1980 # understands -m32/-m64 regardless of what is specified using
1985 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1986 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1987 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1988 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX ; then
1989 mflag_primary=$FLAG_M32
1990 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1991 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1992 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
1993 mflag_primary=$FLAG_M64
1994 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
1995 mflag_primary="$FLAG_M32 -arch i386"
1996 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
1997 mflag_primary="$FLAG_M64 -arch x86_64"
2001 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2002 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
2003 mflag_secondary=$FLAG_M32
2004 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2005 mflag_secondary="$FLAG_M32 -arch i386"
2010 [ --with-mpicc= Specify name of MPI2-ised C compiler],
2015 #----------------------------------------------------------------------------
2017 #----------------------------------------------------------------------------
2019 [ --enable-xen Enable support for Xen hypervisor],
2020 [vg_cv_xen=$enableval],
2024 [ --with-xen= Specify location of Xen headers],
2025 XEN_CFLAGS=-I$withval
2027 AC_SUBST(XEN_CFLAGS)
2029 AM_CONDITIONAL([ENABLE_XEN], [test x$vg_cv_xen = xyes])
2030 if test x"$vg_cv_xen" = xyes; then
2031 AC_DEFINE([ENABLE_XEN], 1, [configured to support Xen])
2034 ## 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.
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
2039 AM_COND_IF([VGCONF_OS_IS_LINUX],
2040 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2041 LDFLAGS_MPI="-fpic -shared"])
2042 AM_COND_IF([VGCONF_OS_IS_DARWIN],
2043 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2044 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2046 AC_SUBST([CFLAGS_MPI])
2047 AC_SUBST([LDFLAGS_MPI])
2050 ## See if MPI_CC works for the primary target
2052 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
2054 saved_CFLAGS=$CFLAGS
2056 CFLAGS="$CFLAGS_MPI $mflag_primary"
2057 saved_LDFLAGS="$LDFLAGS"
2058 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
2059 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2063 int ni, na, nd, comb;
2064 int r = MPI_Init(NULL,NULL);
2065 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2066 r |= MPI_Finalize();
2069 ac_have_mpi2_pri=yes
2070 AC_MSG_RESULT([yes, $MPI_CC])
2076 CFLAGS=$saved_CFLAGS
2077 LDFLAGS="$saved_LDFLAGS"
2078 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
2080 ## 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
2085 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2087 saved_CFLAGS=$CFLAGS
2088 saved_LDFLAGS="$LDFLAGS"
2089 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
2090 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
2091 CC="$MPI_CC this will surely fail"
2095 CFLAGS="$CFLAGS_MPI $mflag_secondary"
2096 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2100 int ni, na, nd, comb;
2101 int r = MPI_Init(NULL,NULL);
2102 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2103 r |= MPI_Finalize();
2106 ac_have_mpi2_sec=yes
2107 AC_MSG_RESULT([yes, $MPI_CC])
2113 CFLAGS=$saved_CFLAGS
2114 LDFLAGS="$saved_LDFLAGS"
2115 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
2118 #----------------------------------------------------------------------------
2119 # Other library checks
2120 #----------------------------------------------------------------------------
2121 # There now follow some tests for Boost, and OpenMP. These
2122 # 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).
2133 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2134 # NEEDED BY THE REGRESSION TEST PROGRAMS.
2137 # 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.
2140 AC_MSG_CHECKING([for boost])
2143 safe_CXXFLAGS=$CXXFLAGS
2144 CXXFLAGS="$mflag_primary"
2146 LIBS="-lboost_thread-mt $LIBS"
2148 AC_LINK_IFELSE([AC_LANG_SOURCE([
2149 #include <boost/thread.hpp>
2150 static void thread_func(void)
2152 int main(int argc, char** argv)
2154 boost::thread t(thread_func);
2159 ac_have_boost_1_35=yes
2160 AC_SUBST([BOOST_CFLAGS], [])
2161 AC_SUBST([BOOST_LIBS], [-lboost_thread-mt])
2162 AC_MSG_RESULT([yes])
2164 ac_have_boost_1_35=no
2169 CXXFLAGS=$safe_CXXFLAGS
2172 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2175 # does this compiler support -fopenmp, does it have the include file
2176 # <omp.h> and does it have libgomp ?
2178 AC_MSG_CHECKING([for OpenMP])
2181 CFLAGS="-fopenmp $mflag_primary"
2183 AC_LINK_IFELSE([AC_LANG_SOURCE([
2185 int main(int argc, char** argv)
2193 AC_MSG_RESULT([yes])
2200 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2203 # does this compiler have built-in functions for atomic memory access for the
2205 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
2208 CFLAGS="$mflag_primary"
2210 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2212 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2213 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2215 ac_have_builtin_atomic_primary=yes
2216 AC_MSG_RESULT([yes])
2217 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])
2219 ac_have_builtin_atomic_primary=no
2225 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2226 [test x$ac_have_builtin_atomic_primary = xyes])
2229 # does this compiler have built-in functions for atomic memory access for the
2230 # secondary target ?
2232 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2234 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2237 CFLAGS="$mflag_secondary"
2239 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2241 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2243 ac_have_builtin_atomic_secondary=yes
2244 AC_MSG_RESULT([yes])
2246 ac_have_builtin_atomic_secondary=no
2254 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2255 [test x$ac_have_builtin_atomic_secondary = xyes])
2257 # does this compiler have built-in functions for atomic memory access on
2258 # 64-bit integers for all targets ?
2260 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2262 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2265 uint64_t variable = 1;
2266 return __sync_add_and_fetch(&variable, 1)
2268 ac_have_builtin_atomic64_primary=yes
2270 ac_have_builtin_atomic64_primary=no
2273 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2276 CFLAGS="$mflag_secondary"
2278 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2281 uint64_t variable = 1;
2282 return __sync_add_and_fetch(&variable, 1)
2284 ac_have_builtin_atomic64_secondary=yes
2286 ac_have_builtin_atomic64_secondary=no
2293 if 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
2300 ac_have_builtin_atomic64=no
2303 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2304 [test x$ac_have_builtin_atomic64 = xyes])
2307 # does g++ have built-in functions for atomic memory access ?
2308 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
2310 safe_CXXFLAGS=$CXXFLAGS
2311 CXXFLAGS="$mflag_primary"
2314 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2316 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2317 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2319 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()])
2323 ac_have_builtin_atomic_cxx=no
2328 CXXFLAGS=$safe_CXXFLAGS
2330 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
2333 if test x$ac_have_usable_linux_futex_h = xyes \
2334 -a x$ac_have_builtin_atomic_primary = xyes; then
2335 ac_enable_linux_ticket_lock_primary=yes
2337 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2338 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2340 if 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
2345 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2346 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2349 # does libstdc++ support annotating shared pointers ?
2350 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2352 safe_CXXFLAGS=$CFLAGS
2353 CXXFLAGS="-std=c++0x"
2356 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2359 std::shared_ptr<int> p
2361 ac_have_shared_ptr=yes
2363 ac_have_shared_ptr=no
2365 if 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)----
2374 std::shared_ptr<int> p
2376 ac_have_shared_pointer_annotation=no
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])
2385 ac_have_shared_pointer_annotation=no
2390 CXXFLAGS=$safe_CXXFLAGS
2392 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2393 [test x$ac_have_shared_pointer_annotation = xyes])
2396 #----------------------------------------------------------------------------
2397 # Ok. We're done checking.
2398 #----------------------------------------------------------------------------
2400 # Nb: VEX/Makefile is generated from Makefile.vex.in.
2403 VEX/Makefile:Makefile.vex.in
2412 gdbserver_tests/Makefile
2418 memcheck/tests/Makefile
2419 memcheck/tests/amd64/Makefile
2420 memcheck/tests/x86/Makefile
2421 memcheck/tests/linux/Makefile
2422 memcheck/tests/darwin/Makefile
2423 memcheck/tests/amd64-linux/Makefile
2424 memcheck/tests/x86-linux/Makefile
2425 memcheck/tests/ppc32/Makefile
2426 memcheck/tests/ppc64/Makefile
2427 memcheck/tests/s390x/Makefile
2428 memcheck/tests/vbit-test/Makefile
2430 cachegrind/tests/Makefile
2431 cachegrind/tests/x86/Makefile
2432 cachegrind/cg_annotate
2435 callgrind/callgrind_annotate
2436 callgrind/callgrind_control
2437 callgrind/tests/Makefile
2439 helgrind/tests/Makefile
2441 massif/tests/Makefile
2444 lackey/tests/Makefile
2447 none/tests/amd64/Makefile
2448 none/tests/ppc32/Makefile
2449 none/tests/ppc64/Makefile
2450 none/tests/x86/Makefile
2451 none/tests/arm/Makefile
2452 none/tests/s390x/Makefile
2453 none/tests/mips32/Makefile
2454 none/tests/linux/Makefile
2455 none/tests/darwin/Makefile
2456 none/tests/x86-linux/Makefile
2457 exp-sgcheck/Makefile
2458 exp-sgcheck/tests/Makefile
2460 drd/scripts/download-and-build-splash2
2463 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
2468 exp-bbv/tests/arm-linux/Makefile
2470 exp-dhat/tests/Makefile
2472 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
2473 [chmod +x coregrind/link_tool_exe_linux])
2474 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
2475 [chmod +x coregrind/link_tool_exe_darwin])
2480 Maximum build arch: ${ARCH_MAX}
2481 Primary build arch: ${VGCONF_ARCH_PRI}
2482 Secondary build arch: ${VGCONF_ARCH_SEC}
2483 Build OS: ${VGCONF_OS}
2484 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
2485 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
2486 Platform variant: ${VGCONF_PLATVARIANT}
2487 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
2488 Default supp files: ${DEFAULT_SUPP}