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.7.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 # Try to get the gcc version, sed-ing out some unexpected stuff
102 # that appears with the default gcc on OSX 10.6 and 10.7 respectively.
103 # Without this, the version number comes out as 686, 10 or 11 :-(
105 # i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
106 # i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
108 [gcc_version=`${CC} --version \
110 | $SED 's/i686-apple-darwin10//' \
111 | $SED 's/i686-apple-darwin11//' \
112 | $SED 's/^[^0-9]*\([0-9.]*\).*$/\1/'`]
115 if test "x`${CC} --version | head -n 1 | $SED 's/\(clang\) version.*/\1/'`" = "xclang" ; then
119 case "${is_clang}-${gcc_version}" in
121 AC_MSG_RESULT([ok (${gcc_version})])
124 AC_MSG_RESULT([ok (${gcc_version})])
127 AC_MSG_RESULT([ok (clang-${gcc_version})])
130 AC_MSG_RESULT([no (${gcc_version})])
131 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
135 #----------------------------------------------------------------------------
136 # Arch/OS/platform tests.
137 #----------------------------------------------------------------------------
138 # We create a number of arch/OS/platform-related variables. We prefix them
139 # all with "VGCONF_" which indicates that they are defined at
140 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
141 # variables used when compiling C files.
145 AC_MSG_CHECKING([for a supported CPU])
147 # ARCH_MAX reflects the most that this CPU can do: for example if it
148 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
149 # Ditto for amd64. It is used for more configuration below, but is not used
151 case "${host_cpu}" in
153 AC_MSG_RESULT([ok (${host_cpu})])
158 AC_MSG_RESULT([ok (${host_cpu})])
163 AC_MSG_RESULT([ok (${host_cpu})])
168 # On Linux this means only a 32-bit capable CPU.
169 AC_MSG_RESULT([ok (${host_cpu})])
174 AC_MSG_RESULT([ok (${host_cpu})])
179 AC_MSG_RESULT([ok (${host_cpu})])
184 AC_MSG_RESULT([no (${host_cpu})])
185 AC_MSG_ERROR([Unsupported host architecture. Sorry])
189 #----------------------------------------------------------------------------
191 # Sometimes it's convenient to subvert the bi-arch build system and
192 # just have a single build even though the underlying platform is
193 # capable of both. Hence handle --enable-only64bit and
194 # --enable-only32bit. Complain if both are issued :-)
195 # [Actually, if either of these options are used, I think both get built,
196 # but only one gets installed. So if you use an in-place build, both can be
199 # Check if a 64-bit only build has been requested
200 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
201 [AC_ARG_ENABLE(only64bit,
202 [ --enable-only64bit do a 64-bit only build],
203 [vg_cv_only64bit=$enableval],
204 [vg_cv_only64bit=no])])
206 # Check if a 32-bit only build has been requested
207 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
208 [AC_ARG_ENABLE(only32bit,
209 [ --enable-only32bit do a 32-bit only build],
210 [vg_cv_only32bit=$enableval],
211 [vg_cv_only32bit=no])])
214 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
216 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
219 #----------------------------------------------------------------------------
221 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
222 # compilation of many C files via -VGO_$(VGCONF_OS) and
223 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
224 AC_MSG_CHECKING([for a supported OS])
231 AC_MSG_RESULT([ok (${host_os})])
234 # Ok, this is linux. Check the kernel version
235 AC_MSG_CHECKING([for the kernel version])
241 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
242 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x or Linux 3.x])
246 AC_MSG_RESULT([2.4 family (${kernel})])
247 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
251 AC_MSG_RESULT([unsupported (${kernel})])
252 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
259 AC_MSG_RESULT([ok (${host_os})])
261 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
262 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
263 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
265 AC_MSG_CHECKING([for the kernel version])
268 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
269 # has only one relevant version, the OS version. The `uname` check
270 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
271 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
272 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
273 # and we don't know of an macros similar to __GLIBC__ to get that info.
275 # XXX: `uname -r` won't do the right thing for cross-compiles, but
276 # that's not a problem yet.
278 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
279 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
280 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
281 # time support for 10.5 (the 9.* pattern just below), I'll leave it
282 # in for now, just in case anybody wants to give it a try. But I'm
283 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
286 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
287 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
288 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
289 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
292 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
293 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
294 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
295 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
298 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
299 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
300 # FIXME: change these to xx11.supp
301 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
302 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
305 AC_MSG_RESULT([unsupported (${kernel})])
306 AC_MSG_ERROR([Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)])
312 AC_MSG_RESULT([no (${host_os})])
313 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
317 #----------------------------------------------------------------------------
319 # If we are building on a 64 bit platform test to see if the system
320 # supports building 32 bit programs and disable 32 bit support if it
321 # does not support building 32 bit programs
323 case "$ARCH_MAX-$VGCONF_OS" in
324 amd64-linux|ppc64-linux)
325 AC_MSG_CHECKING([for 32 bit build support])
328 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
333 vg_cv_only64bit="yes"
336 CFLAGS=$safe_CFLAGS;;
339 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
341 [--enable-only32bit was specified but system does not support 32 bit builds])
344 #----------------------------------------------------------------------------
346 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
347 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
348 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
349 # above) will be "amd64" since that reflects the most that this cpu can do,
350 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
351 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
352 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
353 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
354 AC_SUBST(VGCONF_ARCH_PRI)
356 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
357 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
358 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
359 # It is empty if there is no secondary target.
360 AC_SUBST(VGCONF_ARCH_SEC)
362 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
363 # The entire system, including regression and performance tests, will be
364 # built for this target. The "_CAPS" indicates that the name is in capital
365 # letters, and it also uses '_' rather than '-' as a separator, because it's
366 # used to create various Makefile variables, which are all in caps by
367 # convention and cannot contain '-' characters. This is in contrast to
368 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
369 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
371 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
372 # Valgrind and tools will also be built for this target, but not the
373 # regression or performance tests.
375 # By default, the primary arch is the same as the "max" arch, as commented
376 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
377 # the big case statement just below here, in the case where we're building
378 # on a 64 bit machine but have been requested only to do a 32 bit build.
379 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
381 AC_MSG_CHECKING([for a supported CPU/OS combination])
383 # NB. The load address for a given platform may be specified in more
384 # than one place, in some cases, depending on whether we're doing a biarch,
385 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
386 # Be careful to give consistent values in all subcases. Also, all four
387 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
388 # even if it is to "0xUNSET".
390 case "$ARCH_MAX-$VGCONF_OS" in
392 VGCONF_ARCH_PRI="x86"
394 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
395 VGCONF_PLATFORM_SEC_CAPS=""
396 valt_load_address_pri_norml="0x38000000"
397 valt_load_address_pri_inner="0x28000000"
398 valt_load_address_sec_norml="0xUNSET"
399 valt_load_address_sec_inner="0xUNSET"
400 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
403 valt_load_address_sec_norml="0xUNSET"
404 valt_load_address_sec_inner="0xUNSET"
405 if test x$vg_cv_only64bit = xyes; then
406 VGCONF_ARCH_PRI="amd64"
408 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
409 VGCONF_PLATFORM_SEC_CAPS=""
410 valt_load_address_pri_norml="0x38000000"
411 valt_load_address_pri_inner="0x28000000"
412 elif test x$vg_cv_only32bit = xyes; then
413 VGCONF_ARCH_PRI="x86"
415 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
416 VGCONF_PLATFORM_SEC_CAPS=""
417 valt_load_address_pri_norml="0x38000000"
418 valt_load_address_pri_inner="0x28000000"
420 VGCONF_ARCH_PRI="amd64"
421 VGCONF_ARCH_SEC="x86"
422 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
423 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
424 valt_load_address_pri_norml="0x38000000"
425 valt_load_address_pri_inner="0x28000000"
426 valt_load_address_sec_norml="0x38000000"
427 valt_load_address_sec_inner="0x28000000"
429 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
432 VGCONF_ARCH_PRI="ppc32"
434 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
435 VGCONF_PLATFORM_SEC_CAPS=""
436 valt_load_address_pri_norml="0x38000000"
437 valt_load_address_pri_inner="0x28000000"
438 valt_load_address_sec_norml="0xUNSET"
439 valt_load_address_sec_inner="0xUNSET"
440 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
443 valt_load_address_sec_norml="0xUNSET"
444 valt_load_address_sec_inner="0xUNSET"
445 if test x$vg_cv_only64bit = xyes; then
446 VGCONF_ARCH_PRI="ppc64"
448 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
449 VGCONF_PLATFORM_SEC_CAPS=""
450 valt_load_address_pri_norml="0x38000000"
451 valt_load_address_pri_inner="0x28000000"
452 elif test x$vg_cv_only32bit = xyes; then
453 VGCONF_ARCH_PRI="ppc32"
455 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
456 VGCONF_PLATFORM_SEC_CAPS=""
457 valt_load_address_pri_norml="0x38000000"
458 valt_load_address_pri_inner="0x28000000"
460 VGCONF_ARCH_PRI="ppc64"
461 VGCONF_ARCH_SEC="ppc32"
462 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
463 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
464 valt_load_address_pri_norml="0x38000000"
465 valt_load_address_pri_inner="0x28000000"
466 valt_load_address_sec_norml="0x38000000"
467 valt_load_address_sec_inner="0x28000000"
469 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
471 # Darwin gets identified as 32-bit even when it supports 64-bit.
472 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
473 # all Macs support both 32-bit and 64-bit, so we just build both. If
474 # someone has a really old 32-bit only machine they can (hopefully?)
475 # build with --enable-only32bit. See bug 243362.
476 x86-darwin|amd64-darwin)
478 valt_load_address_sec_norml="0xUNSET"
479 valt_load_address_sec_inner="0xUNSET"
480 if test x$vg_cv_only64bit = xyes; then
481 VGCONF_ARCH_PRI="amd64"
483 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
484 VGCONF_PLATFORM_SEC_CAPS=""
485 valt_load_address_pri_norml="0x138000000"
486 valt_load_address_pri_inner="0x128000000"
487 elif test x$vg_cv_only32bit = xyes; then
488 VGCONF_ARCH_PRI="x86"
490 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
491 VGCONF_PLATFORM_SEC_CAPS=""
492 VGCONF_ARCH_PRI_CAPS="x86"
493 valt_load_address_pri_norml="0x38000000"
494 valt_load_address_pri_inner="0x28000000"
496 VGCONF_ARCH_PRI="amd64"
497 VGCONF_ARCH_SEC="x86"
498 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
499 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
500 valt_load_address_pri_norml="0x138000000"
501 valt_load_address_pri_inner="0x128000000"
502 valt_load_address_sec_norml="0x38000000"
503 valt_load_address_sec_inner="0x28000000"
505 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
508 VGCONF_ARCH_PRI="arm"
509 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
510 VGCONF_PLATFORM_SEC_CAPS=""
511 valt_load_address_pri_norml="0x38000000"
512 valt_load_address_pri_inner="0x28000000"
513 valt_load_address_sec_norml="0xUNSET"
514 valt_load_address_sec_inner="0xUNSET"
515 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
518 VGCONF_ARCH_PRI="s390x"
520 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
521 VGCONF_PLATFORM_SEC_CAPS=""
522 # we want to have the generated code close to the dispatcher
523 valt_load_address_pri_norml="0x401000000"
524 valt_load_address_pri_inner="0x410000000"
525 valt_load_address_sec_norml="0xUNSET"
526 valt_load_address_sec_inner="0xUNSET"
527 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
530 VGCONF_ARCH_PRI="unknown"
531 VGCONF_ARCH_SEC="unknown"
532 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
533 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
534 valt_load_address_pri_norml="0xUNSET"
535 valt_load_address_pri_inner="0xUNSET"
536 valt_load_address_sec_norml="0xUNSET"
537 valt_load_address_sec_inner="0xUNSET"
538 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
539 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
543 #----------------------------------------------------------------------------
545 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
547 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
548 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
549 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
550 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
551 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
552 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
553 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
554 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
555 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
556 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
557 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
558 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
559 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX )
560 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
561 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
562 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
563 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
565 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
567 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
568 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
569 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
570 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
571 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
572 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
573 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
574 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
575 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
576 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
577 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
578 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
579 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
580 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
581 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
583 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
584 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
585 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
586 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
587 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
590 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
591 # Relies on the assumption that the primary and secondary targets are
592 # for the same OS, so therefore only necessary to test the primary.
593 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
594 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
595 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
596 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
597 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
598 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
599 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
600 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
601 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
602 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
605 # Sometimes, in the Makefile.am files, it's useful to know whether or not
606 # there is a secondary target.
607 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
608 test x$VGCONF_PLATFORM_SEC_CAPS != x)
611 #----------------------------------------------------------------------------
613 #----------------------------------------------------------------------------
615 # Check if this should be built as an inner Valgrind, to be run within
616 # another Valgrind. Choose the load address accordingly.
617 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
618 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
619 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
620 [AC_ARG_ENABLE(inner,
621 [ --enable-inner enables self-hosting],
622 [vg_cv_inner=$enableval],
624 if test "$vg_cv_inner" = yes; then
625 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
626 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
627 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
629 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
630 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
634 #----------------------------------------------------------------------------
635 # Extra fine-tuning of installation directories
636 #----------------------------------------------------------------------------
638 [ --with-tmpdir=PATH Specify path for temporary files],
641 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
644 #----------------------------------------------------------------------------
645 # Libc and suppressions
646 #----------------------------------------------------------------------------
647 # This variable will collect the suppression files to be used.
648 AC_SUBST(DEFAULT_SUPP)
650 AC_CHECK_HEADER([features.h])
652 if test x$ac_cv_header_features_h = xyes; then
653 rm -f conftest.$ac_ext
654 cat <<_ACEOF >conftest.$ac_ext
655 #include <features.h>
656 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
657 glibc version is: __GLIBC__ __GLIBC_MINOR__
660 GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
663 # not really a version check
664 AC_EGREP_CPP([DARWIN_LIBC], [
665 #include <sys/cdefs.h>
666 #if defined(__DARWIN_VERS_1050)
670 GLIBC_VERSION="darwin")
672 # not really a version check
673 AC_EGREP_CPP([BIONIC_LIBC], [
674 #if defined(__ANDROID__)
678 GLIBC_VERSION="bionic")
681 AC_MSG_CHECKING([the GLIBC_VERSION version])
683 case "${GLIBC_VERSION}" in
685 AC_MSG_RESULT(2.2 family)
686 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
687 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
688 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
689 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
693 AC_MSG_RESULT(2.3 family)
694 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
695 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
696 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
697 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
701 AC_MSG_RESULT(2.4 family)
702 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
703 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
704 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
705 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
709 AC_MSG_RESULT(2.5 family)
710 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
711 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
712 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
713 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
716 AC_MSG_RESULT(2.6 family)
717 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
718 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
719 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
720 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
723 AC_MSG_RESULT(2.7 family)
724 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
725 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
726 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
727 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
730 AC_MSG_RESULT(2.8 family)
731 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
732 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
733 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
734 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
737 AC_MSG_RESULT(2.9 family)
738 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
739 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
740 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
741 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
744 AC_MSG_RESULT(2.10 family)
745 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
746 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
747 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
748 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
751 AC_MSG_RESULT(2.11 family)
752 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
753 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
754 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
755 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
758 AC_MSG_RESULT(2.12 family)
759 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
760 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
761 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
762 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
765 AC_MSG_RESULT(2.13 family)
766 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
767 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
768 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
769 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
772 AC_MSG_RESULT(2.14 family)
773 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
774 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
775 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
776 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
779 AC_MSG_RESULT(Darwin)
780 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
781 # DEFAULT_SUPP set by kernel version check above.
784 AC_MSG_RESULT(Bionic)
785 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
786 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
790 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
791 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.14])
792 AC_MSG_ERROR([or Darwin libc])
796 AC_SUBST(GLIBC_VERSION)
799 # Add default suppressions for the X client libraries. Make no
800 # attempt to detect whether such libraries are installed on the
801 # build machine (or even if any X facilities are present); just
802 # add the suppressions antidisirregardless.
803 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
804 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
806 # Add glibc and X11 suppressions for exp-sgcheck
807 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
810 #----------------------------------------------------------------------------
812 #----------------------------------------------------------------------------
814 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
815 # But there are times where we need a bit more control. The motivating
816 # and currently only case is Android: this is almost identical to arm-linux,
817 # but not quite. So this introduces the concept of platform variant tags,
818 # which get passed in the compile as -DVGPV_<arch>_<os>_<variant> along
819 # with the main -DVGP_<arch>_<os> definition.
821 # In almost all cases, the <variant> bit is "vanilla". But for Android
822 # it is "android" instead.
824 # Consequently (eg), plain arm-linux would build with
826 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
828 # whilst an Android build would have
830 # -DVGP_arm_linux -DVGPV_arm_linux_android
832 # The setup of the platform variant is pushed relatively far down this
833 # file in order that we can inspect any of the variables set above.
835 # In the normal case ..
836 VGCONF_PLATVARIANT="vanilla"
839 if test "$VGCONF_ARCH_PRI-$VGCONF_OS" = "arm-linux" \
840 -a "$GLIBC_VERSION" = "bionic";
842 VGCONF_PLATVARIANT="android"
845 AC_SUBST(VGCONF_PLATVARIANT)
848 # FIXME: do we also want to define automake variables
849 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
850 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
851 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
852 # do that. Problem is that we can't do and-ing in Makefile.am's, but
853 # that's what we'd need to do to use this, since what we'd want to write
856 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
858 # Hmm. Can't think of a nice clean solution to this.
860 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
861 test x$VGCONF_PLATVARIANT = xvanilla)
862 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
863 test x$VGCONF_PLATVARIANT = xandroid)
866 #----------------------------------------------------------------------------
867 # Checking for various library functions and other definitions
868 #----------------------------------------------------------------------------
870 # Check for CLOCK_MONOTONIC
872 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
874 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
878 clock_gettime(CLOCK_MONOTONIC, &t);
882 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
883 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
889 # Check for PTHREAD_RWLOCK_T
891 AC_MSG_CHECKING([for pthread_rwlock_t])
893 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
897 pthread_rwlock_t rwl;
900 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
901 [Define to 1 if you have the `pthread_rwlock_t' type.])
907 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
909 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
911 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
915 return (PTHREAD_MUTEX_ADAPTIVE_NP);
918 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
919 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
925 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
927 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
929 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
933 return (PTHREAD_MUTEX_ERRORCHECK_NP);
936 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
937 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
943 # Check for PTHREAD_MUTEX_RECURSIVE_NP
945 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
947 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
951 return (PTHREAD_MUTEX_RECURSIVE_NP);
954 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
955 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
961 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
963 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
965 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
969 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
973 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
974 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
980 # Check whether pthread_mutex_t has a member called __m_kind.
982 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
983 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
985 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
988 [#include <pthread.h>])
991 # Check whether pthread_mutex_t has a member called __data.__kind.
993 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
994 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
996 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
999 [#include <pthread.h>])
1002 # does this compiler support -maltivec and does it have the include file
1005 AC_MSG_CHECKING([for Altivec])
1010 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1011 #include <altivec.h>
1013 vector unsigned int v;
1016 AC_MSG_RESULT([yes])
1017 AC_DEFINE([HAS_ALTIVEC], 1,
1018 [Define to 1 if gcc/as can do Altivec.])
1025 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1028 # Check that both: the compiler supports -mvsx and that the assembler
1029 # understands VSX instructions. If either of those doesn't work,
1030 # conclude that we can't do VSX. NOTE: basically this is a kludge
1031 # in that it conflates two things that should be separate -- whether
1032 # the compiler understands the flag vs whether the assembler
1033 # understands the opcodes. This really ought to be cleaned up
1034 # and done properly, like it is for x86/x86_64.
1036 AC_MSG_CHECKING([for VSX])
1041 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1042 #include <altivec.h>
1044 vector unsigned int v;
1045 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1048 AC_MSG_RESULT([yes])
1055 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1058 # Check for pthread_create@GLIBC2.0
1059 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1063 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1064 extern int pthread_create_glibc_2_0(void*, const void*,
1065 void *(*)(void*), void*);
1066 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1070 * Apparently on PowerPC linking this program succeeds and generates an
1071 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1073 #error This test does not work properly on PowerPC.
1075 pthread_create_glibc_2_0(0, 0, 0, 0);
1079 ac_have_pthread_create_glibc_2_0=yes
1080 AC_MSG_RESULT([yes])
1081 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1082 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1084 ac_have_pthread_create_glibc_2_0=no
1089 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1090 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1093 # Check for eventfd_t, eventfd() and eventfd_read()
1094 AC_MSG_CHECKING([for eventfd()])
1096 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1097 #include <sys/eventfd.h>
1103 eventfd_read(fd, &ev);
1106 AC_MSG_RESULT([yes])
1107 AC_DEFINE([HAVE_EVENTFD], 1,
1108 [Define to 1 if you have the `eventfd' function.])
1109 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1110 [Define to 1 if you have the `eventfd_read' function.])
1116 #----------------------------------------------------------------------------
1117 # Checking for supported compiler flags.
1118 #----------------------------------------------------------------------------
1120 # does this compiler support -m32 ?
1121 AC_MSG_CHECKING([if gcc accepts -m32])
1126 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1130 AC_MSG_RESULT([yes])
1140 # does this compiler support -m64 ?
1141 AC_MSG_CHECKING([if gcc accepts -m64])
1146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1150 AC_MSG_RESULT([yes])
1160 # does this compiler support -mmmx ?
1161 AC_MSG_CHECKING([if gcc accepts -mmmx])
1166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1170 AC_MSG_RESULT([yes])
1180 # does this compiler support -msse ?
1181 AC_MSG_CHECKING([if gcc accepts -msse])
1186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1190 AC_MSG_RESULT([yes])
1200 # does this compiler support -mpreferred-stack-boundary=2 ?
1201 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1204 CFLAGS="-mpreferred-stack-boundary=2"
1206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1209 PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
1210 AC_MSG_RESULT([yes])
1212 PREFERRED_STACK_BOUNDARY=""
1217 AC_SUBST(PREFERRED_STACK_BOUNDARY)
1220 # does this compiler support -Wno-pointer-sign ?
1221 AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
1224 CFLAGS="-Wno-pointer-sign"
1226 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1230 AC_MSG_RESULT([yes])
1237 if test x$no_pointer_sign = xyes; then
1238 CFLAGS="$CFLAGS -Wno-pointer-sign"
1242 # does this compiler support -Wno-empty-body ?
1244 AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1247 CFLAGS="-Wno-empty-body"
1249 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1252 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1253 AC_MSG_RESULT([yes])
1255 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1261 # does this compiler support -Wno-format-zero-length ?
1263 AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1266 CFLAGS="-Wno-format-zero-length"
1268 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1271 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1272 AC_MSG_RESULT([yes])
1274 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1280 # does this compiler support -Wno-nonnull ?
1282 AC_MSG_CHECKING([if gcc accepts -Wno-nonnull])
1285 CFLAGS="-Wno-nonnull"
1287 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1290 AC_SUBST([FLAG_W_NO_NONNULL], [-Wno-nonnull])
1291 AC_MSG_RESULT([yes])
1293 AC_SUBST([FLAG_W_NO_NONNULL], [])
1299 # does this compiler support -Wno-overflow ?
1301 AC_MSG_CHECKING([if gcc accepts -Wno-overflow])
1304 CFLAGS="-Wno-overflow"
1306 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1309 AC_SUBST([FLAG_W_NO_OVERFLOW], [-Wno-overflow])
1310 AC_MSG_RESULT([yes])
1312 AC_SUBST([FLAG_W_NO_OVERFLOW], [])
1318 # does this compiler support -Wno-uninitialized ?
1320 AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1323 CFLAGS="-Wno-uninitialized"
1325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1328 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1329 AC_MSG_RESULT([yes])
1331 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1337 # does this compiler support -Wextra or the older -W ?
1339 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1347 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1348 AC_MSG_RESULT([-Wextra])
1351 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ ]], [[
1354 AC_SUBST([FLAG_W_EXTRA], [-W])
1357 AC_SUBST([FLAG_W_EXTRA], [])
1358 AC_MSG_RESULT([not supported])
1364 # does this compiler support -fno-stack-protector ?
1365 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1368 CFLAGS="-fno-stack-protector"
1370 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1373 no_stack_protector=yes
1374 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1375 AC_MSG_RESULT([yes])
1377 no_stack_protector=no
1378 FLAG_FNO_STACK_PROTECTOR=""
1383 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1385 if test x$no_stack_protector = xyes; then
1386 CFLAGS="$CFLAGS -fno-stack-protector"
1390 # does this compiler support --param inline-unit-growth=... ?
1392 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1395 CFLAGS="--param inline-unit-growth=900"
1397 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1400 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1401 ["--param inline-unit-growth=900"])
1402 AC_MSG_RESULT([yes])
1404 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1410 # does the linker support -Wl,--build-id=none ? Note, it's
1411 # important that we test indirectly via whichever C compiler
1412 # is selected, rather than testing /usr/bin/ld or whatever
1415 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1418 CFLAGS="-Wl,--build-id=none"
1421 [AC_LANG_PROGRAM([ ], [return 0;])],
1423 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1424 AC_MSG_RESULT([yes])
1426 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1432 # does the ppc assembler support "mtocrf" et al?
1433 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1436 __asm__ __volatile__("mtocrf 4,0");
1437 __asm__ __volatile__("mfocrf 0,4");
1439 ac_have_as_ppc_mftocrf=yes
1440 AC_MSG_RESULT([yes])
1442 ac_have_as_ppc_mftocrf=no
1445 if test x$ac_have_as_ppc_mftocrf = xyes ; then
1446 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1452 # does the x86/amd64 assembler understand SSE3 instructions?
1453 # Note, this doesn't generate a C-level symbol. It generates a
1454 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
1455 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1457 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1458 do { long long int x;
1459 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1463 AC_MSG_RESULT([yes])
1469 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
1472 # Ditto for SSSE3 instructions (note extra S)
1473 # Note, this doesn't generate a C-level symbol. It generates a
1474 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1475 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1477 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1478 do { long long int x;
1479 __asm__ __volatile__(
1480 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1483 ac_have_as_ssse3=yes
1484 AC_MSG_RESULT([yes])
1490 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1493 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1494 # Note, this doesn't generate a C-level symbol. It generates a
1495 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
1496 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
1497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1499 __asm__ __volatile__(
1500 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1503 ac_have_as_pclmulqdq=yes
1504 AC_MSG_RESULT([yes])
1506 ac_have_as_pclmulqdq=no
1510 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1513 # does the x86/amd64 assembler understand the LZCNT instruction?
1514 # Note, this doesn't generate a C-level symbol. It generates a
1515 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
1516 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1518 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1520 __asm__ __volatile__("lzcnt %rax,%rax");
1523 ac_have_as_lzcnt=yes
1524 AC_MSG_RESULT([yes])
1530 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1533 # does the x86/amd64 assembler understand SSE 4.2 instructions?
1534 # Note, this doesn't generate a C-level symbol. It generates a
1535 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1536 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1539 do { long long int x;
1540 __asm__ __volatile__(
1541 "crc32q %%r15,%%r15" : : : "r15" ); }
1544 ac_have_as_sse42=yes
1545 AC_MSG_RESULT([yes])
1551 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1554 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
1555 # when building the tool executables. I think we should get rid of it.
1557 # Check for TLS support in the compiler and linker
1558 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1560 [vg_cv_linktime_tls=yes],
1561 [vg_cv_linktime_tls=no])
1562 # Native compilation: check whether running a program using TLS succeeds.
1563 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1564 # succeeds but running programs using TLS fails.
1565 # Cross-compiling: check whether linking a program using TLS succeeds.
1566 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1567 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1568 [vg_cv_tls=$enableval],
1569 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1573 [vg_cv_tls=$vg_cv_linktime_tls])])])
1575 if test "$vg_cv_tls" = yes; then
1576 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1580 #----------------------------------------------------------------------------
1581 # Checks for C header files.
1582 #----------------------------------------------------------------------------
1585 AC_CHECK_HEADERS([ \
1601 # Verify whether the <linux/futex.h> header is usable.
1602 AC_MSG_CHECKING([if <linux/futex.h> is usable])
1604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1605 #include <linux/futex.h>
1609 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
1610 [Define to 1 if you have a usable <linux/futex.h> header file.])
1611 AC_MSG_RESULT([yes])
1616 #----------------------------------------------------------------------------
1617 # Checks for typedefs, structures, and compiler characteristics.
1618 #----------------------------------------------------------------------------
1625 #----------------------------------------------------------------------------
1626 # Checks for library functions.
1627 #----------------------------------------------------------------------------
1631 AC_CHECK_LIB([pthread], [pthread_create])
1632 AC_CHECK_LIB([rt], [clock_gettime])
1645 pthread_barrier_init \
1646 pthread_condattr_setclock \
1647 pthread_mutex_timedlock \
1648 pthread_rwlock_timedrdlock \
1649 pthread_rwlock_timedwrlock \
1665 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1666 # libraries with any shared object and/or executable. This is NOT what we
1667 # want for e.g. vgpreload_core-x86-linux.so
1670 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1671 [test x$ac_cv_func_pthread_barrier_init = xyes])
1672 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1673 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
1674 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1675 [test x$ac_cv_func_pthread_spin_lock = xyes])
1678 #----------------------------------------------------------------------------
1680 #----------------------------------------------------------------------------
1681 # Do we have a useable MPI setup on the primary and/or secondary targets?
1682 # On Linux, by default, assumes mpicc and -m32/-m64
1683 # Note: this is a kludge in that it assumes the specified mpicc
1684 # understands -m32/-m64 regardless of what is specified using
1689 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1690 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1691 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX ; then
1692 mflag_primary=$FLAG_M32
1693 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1694 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1695 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
1696 mflag_primary=$FLAG_M64
1700 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1701 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
1702 mflag_secondary=$FLAG_M32
1707 [ --with-mpicc= Specify name of MPI2-ised C compiler],
1712 ## See if MPI_CC works for the primary target
1714 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
1716 saved_CFLAGS=$CFLAGS
1718 CFLAGS=$mflag_primary
1719 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1723 int r = MPI_Init(NULL,NULL);
1724 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1727 ac_have_mpi2_pri=yes
1728 AC_MSG_RESULT([yes, $MPI_CC])
1734 CFLAGS=$saved_CFLAGS
1735 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
1737 ## See if MPI_CC works for the secondary target. Complication: what if
1738 ## there is no secondary target? We need this to then fail.
1739 ## Kludge this by making MPI_CC something which will surely fail in
1742 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1744 saved_CFLAGS=$CFLAGS
1745 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
1746 CC="$MPI_CC this will surely fail"
1750 CFLAGS=$mflag_secondary
1751 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1755 int r = MPI_Init(NULL,NULL);
1756 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1759 ac_have_mpi2_sec=yes
1760 AC_MSG_RESULT([yes, $MPI_CC])
1766 CFLAGS=$saved_CFLAGS
1767 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
1770 #----------------------------------------------------------------------------
1771 # Other library checks
1772 #----------------------------------------------------------------------------
1773 # There now follow some tests for Boost, and OpenMP. These
1774 # tests are present because Drd has some regression tests that use
1775 # these packages. All regression test programs all compiled only
1776 # for the primary target. And so it is important that the configure
1777 # checks that follow, use the correct -m32 or -m64 flag for the
1778 # primary target (called $mflag_primary). Otherwise, we can end up
1779 # in a situation (eg) where, on amd64-linux, the test for Boost checks
1780 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
1781 # only build (meaning, the primary target is x86-linux), the build
1782 # of the regtest programs that use Boost fails, because they are
1783 # build as 32-bit (IN THIS EXAMPLE).
1785 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1786 # NEEDED BY THE REGRESSION TEST PROGRAMS.
1789 # Check whether the boost library 1.35 or later has been installed.
1790 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1792 AC_MSG_CHECKING([for boost])
1795 safe_CXXFLAGS=$CXXFLAGS
1796 CXXFLAGS="-lboost_thread-mt $mflag_primary"
1798 AC_LINK_IFELSE([AC_LANG_SOURCE([
1799 #include <boost/thread.hpp>
1800 static void thread_func(void)
1802 int main(int argc, char** argv)
1804 boost::thread t(thread_func);
1809 ac_have_boost_1_35=yes
1810 AC_SUBST([BOOST_CFLAGS], [])
1811 AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1812 AC_MSG_RESULT([yes])
1814 ac_have_boost_1_35=no
1818 CXXFLAGS=$safe_CXXFLAGS
1821 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1824 # does this compiler support -fopenmp, does it have the include file
1825 # <omp.h> and does it have libgomp ?
1827 AC_MSG_CHECKING([for OpenMP])
1830 CFLAGS="-fopenmp $mflag_primary"
1832 AC_LINK_IFELSE([AC_LANG_SOURCE([
1834 int main(int argc, char** argv)
1842 AC_MSG_RESULT([yes])
1849 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1852 # does this compiler have built-in functions for atomic memory access ?
1853 AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
1856 CFLAGS="$mflag_primary"
1858 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1860 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1861 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1863 ac_have_builtin_atomic=yes
1864 AC_MSG_RESULT([yes])
1865 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
1867 ac_have_builtin_atomic=no
1873 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC], [test x$ac_have_builtin_atomic = xyes])
1875 # does g++ have built-in functions for atomic memory access ?
1876 AC_MSG_CHECKING([if g++ supports __sync_bool_compare_and_swap])
1878 safe_CXXFLAGS=$CXXFLAGS
1879 CXXFLAGS="$mflag_primary"
1882 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1884 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1885 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1887 ac_have_builtin_atomic_cxx=yes
1888 AC_MSG_RESULT([yes])
1889 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
1891 ac_have_builtin_atomic_cxx=no
1896 CXXFLAGS=$safe_CXXFLAGS
1898 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
1900 #----------------------------------------------------------------------------
1901 # Ok. We're done checking.
1902 #----------------------------------------------------------------------------
1904 # Nb: VEX/Makefile is generated from Makefile.vex.in.
1907 VEX/Makefile:Makefile.vex.in
1916 gdbserver_tests/Makefile
1922 memcheck/tests/Makefile
1923 memcheck/tests/amd64/Makefile
1924 memcheck/tests/x86/Makefile
1925 memcheck/tests/linux/Makefile
1926 memcheck/tests/darwin/Makefile
1927 memcheck/tests/amd64-linux/Makefile
1928 memcheck/tests/x86-linux/Makefile
1929 memcheck/tests/ppc32/Makefile
1930 memcheck/tests/ppc64/Makefile
1931 memcheck/perf/Makefile
1933 cachegrind/tests/Makefile
1934 cachegrind/tests/x86/Makefile
1935 cachegrind/cg_annotate
1938 callgrind/callgrind_annotate
1939 callgrind/callgrind_control
1940 callgrind/tests/Makefile
1942 helgrind/tests/Makefile
1944 massif/tests/Makefile
1945 massif/perf/Makefile
1948 lackey/tests/Makefile
1951 none/tests/amd64/Makefile
1952 none/tests/ppc32/Makefile
1953 none/tests/ppc64/Makefile
1954 none/tests/x86/Makefile
1955 none/tests/arm/Makefile
1956 none/tests/s390x/Makefile
1957 none/tests/linux/Makefile
1958 none/tests/darwin/Makefile
1959 none/tests/x86-linux/Makefile
1960 exp-sgcheck/Makefile
1961 exp-sgcheck/tests/Makefile
1963 drd/scripts/download-and-build-splash2
1966 exp-bbv/tests/Makefile
1967 exp-bbv/tests/x86/Makefile
1968 exp-bbv/tests/x86-linux/Makefile
1969 exp-bbv/tests/amd64-linux/Makefile
1970 exp-bbv/tests/ppc32-linux/Makefile
1971 exp-bbv/tests/arm-linux/Makefile
1973 exp-dhat/tests/Makefile
1975 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
1976 [chmod +x coregrind/link_tool_exe_linux])
1977 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
1978 [chmod +x coregrind/link_tool_exe_darwin])
1983 Maximum build arch: ${ARCH_MAX}
1984 Primary build arch: ${VGCONF_ARCH_PRI}
1985 Secondary build arch: ${VGCONF_ARCH_SEC}
1986 Build OS: ${VGCONF_OS}
1987 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
1988 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
1989 Platform variant: ${VGCONF_PLATVARIANT}
1990 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
1991 Default supp files: ${DEFAULT_SUPP}