s390x: rewrite some testcases. To make my testing and debugging life
[ambi/valgrind.git] / configure.in
1
2 ##------------------------------------------------------------##
3
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic.  Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
7 #
8 ##------------------------------------------------------------##
9
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 AM_CONFIG_HEADER(config.h)
14 AM_INIT_AUTOMAKE([foreign])
15
16 AM_MAINTAINER_MODE
17
18 #----------------------------------------------------------------------------
19 # Checks for various programs.
20 #----------------------------------------------------------------------------
21 CFLAGS="-Wno-long-long $CFLAGS"
22
23 AC_PROG_LN_S
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_PROG_CPP
27 AC_PROG_CXX
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
31 # following:
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],
36 #        [AC_PROG_OBJC],
37 #        [AC_CHECK_TOOL([OBJC], [gcc])
38 #         AC_SUBST([OBJC])
39 #         AC_SUBST([OBJCFLAGS])
40 #        ])
41 AC_PROG_RANLIB
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],
46                     [AC_ARG_VAR([SED])
47                      AC_CHECK_PROGS([SED],[gsed sed])])])
48 AC_PROG_SED
49
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])
54 fi
55 AC_ARG_VAR([AR],[Archiver command])
56
57 # Check for the compiler support
58 if test "${GCC}" != "yes" ; then
59    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
60 fi
61
62 # figure out where perl lives
63 AC_PATH_PROG(PERL, perl)
64
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])
68
69 # some older automake's don't have it so try something on our own
70 ifdef([AM_PROG_AS],[AM_PROG_AS],
71 [
72 AS="${CC}"
73 AC_SUBST(AS)
74
75 ASFLAGS=""
76 AC_SUBST(ASFLAGS)
77 ])
78
79
80 # Check if 'diff' supports -u (universal diffs) and use it if possible.
81
82 AC_MSG_CHECKING([for diff -u])
83 AC_SUBST(DIFF)
84
85 # Comparing two identical files results in 0, unless -u isn't supported (as
86 # it's not on AIX).
87 tmpfile="tmp-xxx-yyy-zzz"
88 touch $tmpfile;
89 if diff -u $tmpfile $tmpfile ; then
90     AC_MSG_RESULT([yes])
91     DIFF="diff -u"
92 else
93     AC_MSG_RESULT([no])
94     DIFF="diff"
95 fi
96 rm $tmpfile
97
98
99 # We don't want gcc < 3.0
100 AC_MSG_CHECKING([for a supported version of gcc])
101
102 [gcc_version=`${CC} --version | head -n 1 | $SED 's/^[^0-9]*\([0-9.]*\).*$/\1/'`]
103
104 case "${gcc_version}" in
105      2.*)
106         AC_MSG_RESULT([no (${gcc_version})])
107         AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
108         ;;
109      *)
110         AC_MSG_RESULT([ok (${gcc_version})])
111         ;;
112 esac
113
114 #----------------------------------------------------------------------------
115 # Arch/OS/platform tests.
116 #----------------------------------------------------------------------------
117 # We create a number of arch/OS/platform-related variables.  We prefix them
118 # all with "VGCONF_" which indicates that they are defined at
119 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
120 # variables used when compiling C files.
121
122 AC_CANONICAL_HOST
123
124 AC_MSG_CHECKING([for a supported CPU])
125
126 # ARCH_MAX reflects the most that this CPU can do: for example if it
127 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
128 # Ditto for amd64.  It is used for more configuration below, but is not used
129 # outside this file.
130 case "${host_cpu}" in
131      i?86) 
132         AC_MSG_RESULT([ok (${host_cpu})])
133         ARCH_MAX="x86"
134         ;;
135
136      x86_64) 
137         AC_MSG_RESULT([ok (${host_cpu})])
138         ARCH_MAX="amd64"
139         ;;
140
141      powerpc64)
142         # This value can only happen on Linux, not on AIX
143         AC_MSG_RESULT([ok (${host_cpu})])
144         ARCH_MAX="ppc64"
145         ;;
146
147      powerpc)
148         # Complexity.  'powerpc' on AIX implies a 64-bit capable CPU.
149         # Whereas in Linux that means only a 32-bit capable CPU.
150         AC_MSG_RESULT([ok (${host_cpu})])
151         case "${host_os}" in
152            aix5.*)
153               ARCH_MAX="ppc64"
154               ;;
155            *)
156               ARCH_MAX="ppc32"
157               ;;
158         esac
159         ;;
160
161      s390x)
162         AC_MSG_RESULT([ok (${host_cpu})])
163         ARCH_MAX="s390x"
164         ;;
165
166      armv7*)
167         AC_MSG_RESULT([ok (${host_cpu})])
168         ARCH_MAX="arm"
169         ;;
170
171      *) 
172         AC_MSG_RESULT([no (${host_cpu})])
173         AC_MSG_ERROR([Unsupported host architecture. Sorry])
174         ;;
175 esac
176
177 #----------------------------------------------------------------------------
178
179 # Sometimes it's convenient to subvert the bi-arch build system and
180 # just have a single build even though the underlying platform is
181 # capable of both.  Hence handle --enable-only64bit and
182 # --enable-only32bit.  Complain if both are issued :-)
183 # [Actually, if either of these options are used, I think both get built,
184 # but only one gets installed.  So if you use an in-place build, both can be
185 # used. --njn]
186
187 # Check if a 64-bit only build has been requested
188 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
189    [AC_ARG_ENABLE(only64bit, 
190       [  --enable-only64bit      do a 64-bit only build],
191       [vg_cv_only64bit=$enableval],
192       [vg_cv_only64bit=no])])
193
194 # Check if a 32-bit only build has been requested
195 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
196    [AC_ARG_ENABLE(only32bit, 
197       [  --enable-only32bit      do a 32-bit only build],
198       [vg_cv_only32bit=$enableval],
199       [vg_cv_only32bit=no])])
200
201 # Stay sane
202 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
203    AC_MSG_ERROR(
204       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
205 fi
206
207 #----------------------------------------------------------------------------
208
209 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
210 # compilation of many C files via -VGO_$(VGCONF_OS) and
211 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
212 AC_MSG_CHECKING([for a supported OS])
213 AC_SUBST(VGCONF_OS)
214
215 DEFAULT_SUPP=""
216
217 case "${host_os}" in
218      *linux*)
219         AC_MSG_RESULT([ok (${host_os})])
220         VGCONF_OS="linux"
221
222         # Ok, this is linux. Check the kernel version
223         AC_MSG_CHECKING([for the kernel version])
224
225         kernel=`uname -r`
226
227         case "${kernel}" in
228              2.6.*) 
229                     AC_MSG_RESULT([2.6 family (${kernel})])
230                     AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
231                     ;;
232
233              2.4.*) 
234                     AC_MSG_RESULT([2.4 family (${kernel})])
235                     AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
236                     ;;
237
238              *) 
239                     AC_MSG_RESULT([unsupported (${kernel})])
240                     AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
241                     ;;
242         esac
243
244         ;;
245
246      aix5.1.*)
247         AC_MSG_RESULT([ok (${host_os})])
248         VGCONF_OS="aix5"
249         ;;
250      aix5.2.*)
251         AC_MSG_RESULT([ok (${host_os})])
252         VGCONF_OS="aix5"
253         ;;       
254      aix5.3.*)
255         AC_MSG_RESULT([ok (${host_os})])
256         VGCONF_OS="aix5"
257         ;;       
258
259      *darwin*)
260         AC_MSG_RESULT([ok (${host_os})])
261         VGCONF_OS="darwin"
262         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
263         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
264         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
265
266         AC_MSG_CHECKING([for the kernel version])
267         kernel=`uname -r`
268
269         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
270         # has only one relevant version, the OS version. The `uname` check
271         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
272         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard), 
273         # and we don't know of an macros similar to __GLIBC__ to get that info.
274         #
275         # XXX: `uname -r` won't do the right thing for cross-compiles, but
276         # that's not a problem yet.
277         case "${kernel}" in
278              9.*)
279                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
280                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
281                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
282                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
283                   ;;
284              10.*)
285                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
286                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
287                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
288                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
289                   ;;
290      *) 
291                   AC_MSG_RESULT([unsupported (${kernel})])
292                   AC_MSG_ERROR([Valgrind works on Darwin 9.x and 10.x (Mac OS X 10.5 and 10.6)])
293                   ;;
294         esac
295         ;;
296
297      *) 
298         AC_MSG_RESULT([no (${host_os})])
299         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
300         ;;
301 esac
302
303 #----------------------------------------------------------------------------
304
305 # If we are building on a 64 bit platform test to see if the system
306 # supports building 32 bit programs and disable 32 bit support if it
307 # does not support building 32 bit programs
308
309 case "$ARCH_MAX-$VGCONF_OS" in
310      amd64-linux|ppc64-linux)
311         AC_MSG_CHECKING([for 32 bit build support])
312         safe_CFLAGS=$CFLAGS
313         CFLAGS="-m32"
314         AC_TRY_LINK(, [
315           return 0;
316         ],
317         [
318         AC_MSG_RESULT([yes])
319         ], [
320         vg_cv_only64bit="yes"
321         AC_MSG_RESULT([no])
322         ])
323         CFLAGS=$safe_CFLAGS;;
324 esac
325
326 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
327    AC_MSG_ERROR(
328       [--enable-only32bit was specified but system does not support 32 bit builds])
329 fi
330
331 #----------------------------------------------------------------------------
332
333 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
334 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
335 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
336 # above) will be "amd64" since that reflects the most that this cpu can do,
337 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
338 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
339 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
340 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
341 AC_SUBST(VGCONF_ARCH_PRI)
342
343 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
344 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
345 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
346 # It is empty if there is no secondary target.
347 AC_SUBST(VGCONF_ARCH_SEC)
348
349 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
350 # The entire system, including regression and performance tests, will be
351 # built for this target.  The "_CAPS" indicates that the name is in capital
352 # letters, and it also uses '_' rather than '-' as a separator, because it's
353 # used to create various Makefile variables, which are all in caps by
354 # convention and cannot contain '-' characters.  This is in contrast to
355 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
356 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
357
358 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
359 # Valgrind and tools will also be built for this target, but not the
360 # regression or performance tests.
361 #
362 # By default, the primary arch is the same as the "max" arch, as commented
363 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
364 # the big case statement just below here, in the case where we're building
365 # on a 64 bit machine but have been requested only to do a 32 bit build.
366 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
367
368 AC_MSG_CHECKING([for a supported CPU/OS combination])
369
370 # NB.  The load address for a given platform may be specified in more 
371 # than one place, in some cases, depending on whether we're doing a biarch,
372 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
373 # Be careful to give consistent values in all subcases.  Also, all four
374 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
375 # even if it is to "0xUNSET".
376 #
377 case "$ARCH_MAX-$VGCONF_OS" in
378      x86-linux)
379         VGCONF_ARCH_PRI="x86"
380         VGCONF_ARCH_SEC=""
381         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
382         VGCONF_PLATFORM_SEC_CAPS=""
383         valt_load_address_pri_norml="0x38000000"
384         valt_load_address_pri_inner="0x28000000"
385         valt_load_address_sec_norml="0xUNSET"
386         valt_load_address_sec_inner="0xUNSET"
387         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
388         ;;
389      amd64-linux)
390         valt_load_address_sec_norml="0xUNSET"
391         valt_load_address_sec_inner="0xUNSET"
392         if test x$vg_cv_only64bit = xyes; then
393            VGCONF_ARCH_PRI="amd64"
394            VGCONF_ARCH_SEC=""
395            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
396            VGCONF_PLATFORM_SEC_CAPS=""
397            valt_load_address_pri_norml="0x38000000"
398            valt_load_address_pri_inner="0x28000000"
399         elif test x$vg_cv_only32bit = xyes; then
400            VGCONF_ARCH_PRI="x86"
401            VGCONF_ARCH_SEC=""
402            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
403            VGCONF_PLATFORM_SEC_CAPS=""
404            valt_load_address_pri_norml="0x38000000"
405            valt_load_address_pri_inner="0x28000000"
406         else
407            VGCONF_ARCH_PRI="amd64"
408            VGCONF_ARCH_SEC="x86"
409            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
410            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
411            valt_load_address_pri_norml="0x38000000"
412            valt_load_address_pri_inner="0x28000000"
413            valt_load_address_sec_norml="0x38000000"
414            valt_load_address_sec_inner="0x28000000"
415         fi
416         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
417         ;;
418      ppc32-linux)
419         VGCONF_ARCH_PRI="ppc32"
420         VGCONF_ARCH_SEC=""
421         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
422         VGCONF_PLATFORM_SEC_CAPS=""
423         valt_load_address_pri_norml="0x38000000"
424         valt_load_address_pri_inner="0x28000000"
425         valt_load_address_sec_norml="0xUNSET"
426         valt_load_address_sec_inner="0xUNSET"
427         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
428         ;;
429      ppc64-aix5)
430         valt_load_address_pri_norml="0xUNSET"
431         valt_load_address_pri_inner="0xUNSET"
432         valt_load_address_sec_norml="0xUNSET"
433         valt_load_address_sec_inner="0xUNSET"
434         if test x$vg_cv_only64bit = xyes; then
435            VGCONF_ARCH_PRI="ppc64"
436            VGCONF_ARCH_SEC=""
437            VGCONF_PLATFORM_PRI_CAPS="PPC64_AIX5"
438            VGCONF_PLATFORM_SEC_CAPS=""
439         elif test x$vg_cv_only32bit = xyes; then
440            VGCONF_ARCH_PRI="ppc32"
441            VGCONF_ARCH_SEC=""
442            VGCONF_PLATFORM_PRI_CAPS="PPC32_AIX5"
443            VGCONF_PLATFORM_SEC_CAPS=""
444         else
445            VGCONF_ARCH_PRI="ppc64"
446            VGCONF_ARCH_SEC="ppc32"
447            VGCONF_PLATFORM_PRI_CAPS="PPC64_AIX5"
448            VGCONF_PLATFORM_SEC_CAPS="PPC32_AIX5"
449         fi
450         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
451         ;;
452      ppc64-linux)
453         valt_load_address_sec_norml="0xUNSET"
454         valt_load_address_sec_inner="0xUNSET"
455         if test x$vg_cv_only64bit = xyes; then
456            VGCONF_ARCH_PRI="ppc64"
457            VGCONF_ARCH_SEC=""
458            VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
459            VGCONF_PLATFORM_SEC_CAPS=""
460            valt_load_address_pri_norml="0x38000000"
461            valt_load_address_pri_inner="0x28000000"
462         elif test x$vg_cv_only32bit = xyes; then
463            VGCONF_ARCH_PRI="ppc32"
464            VGCONF_ARCH_SEC=""
465            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
466            VGCONF_PLATFORM_SEC_CAPS=""
467            valt_load_address_pri_norml="0x38000000"
468            valt_load_address_pri_inner="0x28000000"
469         else
470            VGCONF_ARCH_PRI="ppc64"
471            VGCONF_ARCH_SEC="ppc32"
472            VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
473            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
474            valt_load_address_pri_norml="0x38000000"
475            valt_load_address_pri_inner="0x28000000"
476            valt_load_address_sec_norml="0x38000000"
477            valt_load_address_sec_inner="0x28000000"
478         fi
479         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
480         ;;
481      # Darwin gets identified as 32-bit even when it supports 64-bit.
482      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
483      # all Macs support both 32-bit and 64-bit, so we just build both.  If
484      # someone has a really old 32-bit only machine they can (hopefully?)
485      # build with --enable-only32bit.  See bug 243362.
486      x86-darwin|amd64-darwin)
487         ARCH_MAX="amd64"
488         valt_load_address_sec_norml="0xUNSET"
489         valt_load_address_sec_inner="0xUNSET"
490         if test x$vg_cv_only64bit = xyes; then
491            VGCONF_ARCH_PRI="amd64"
492            VGCONF_ARCH_SEC=""
493            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
494            VGCONF_PLATFORM_SEC_CAPS=""
495            valt_load_address_pri_norml="0x138000000"
496            valt_load_address_pri_inner="0x128000000"
497         elif test x$vg_cv_only32bit = xyes; then
498            VGCONF_ARCH_PRI="x86"
499            VGCONF_ARCH_SEC=""
500            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
501            VGCONF_PLATFORM_SEC_CAPS=""
502            VGCONF_ARCH_PRI_CAPS="x86"
503            valt_load_address_pri_norml="0x38000000"
504            valt_load_address_pri_inner="0x28000000"
505         else
506            VGCONF_ARCH_PRI="amd64"
507            VGCONF_ARCH_SEC="x86"
508            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
509            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
510            valt_load_address_pri_norml="0x138000000"
511            valt_load_address_pri_inner="0x128000000"
512            valt_load_address_sec_norml="0x38000000"
513            valt_load_address_sec_inner="0x28000000"
514         fi
515         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
516         ;;
517      arm-linux) 
518         VGCONF_ARCH_PRI="arm"
519         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
520         VGCONF_PLATFORM_SEC_CAPS=""
521         valt_load_address_pri_norml="0x38000000"
522         valt_load_address_pri_inner="0x28000000"
523         valt_load_address_sec_norml="0xUNSET"
524         valt_load_address_sec_inner="0xUNSET"
525         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
526         ;;
527      s390x-linux)
528         VGCONF_ARCH_PRI="s390x"
529         VGCONF_ARCH_SEC=""
530         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
531         VGCONF_PLATFORM_SEC_CAPS=""
532         # we want to have the generated code close to the dispatcher
533         valt_load_address_pri_norml="0x401000000"
534         valt_load_address_pri_inner="0x410000000"
535         valt_load_address_sec_norml="0xUNSET"
536         valt_load_address_sec_inner="0xUNSET"
537         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
538         ;;
539     *)
540         VGCONF_ARCH_PRI="unknown"
541         VGCONF_ARCH_SEC="unknown"
542         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
543         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
544         valt_load_address_pri_norml="0xUNSET"
545         valt_load_address_pri_inner="0xUNSET"
546         valt_load_address_sec_norml="0xUNSET"
547         valt_load_address_sec_inner="0xUNSET"
548         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
549         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
550         ;;
551 esac
552
553 #----------------------------------------------------------------------------
554
555 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
556 # defined.
557 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
558                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
559                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
560                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
561                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
562 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
563                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
564                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
565 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
566                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
567                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
568                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \ 
569                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5 )
570 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
571                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
572                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 )
573 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
574                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX )
575 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
576                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
577
578 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
579 # become defined.
580 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
581                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
582                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
583 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
584                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
585 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
586                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
587                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
588 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX, 
589                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
590 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
591                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX)
592 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
593                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
594                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
595
596 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5, 
597                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \ 
598                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5)
599 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5, 
600                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5)
601
602 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,   
603                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
604                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
605 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
606                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
607
608
609 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
610 # Relies on the assumption that the primary and secondary targets are 
611 # for the same OS, so therefore only necessary to test the primary.
612 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
613                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
614                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
615                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
616                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
617                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
618                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX)
619 AM_CONDITIONAL(VGCONF_OS_IS_AIX5,
620                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
621                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5)
622 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
623                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
624                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
625
626
627 # Sometimes, in the Makefile.am files, it's useful to know whether or not
628 # there is a secondary target.
629 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
630                test x$VGCONF_PLATFORM_SEC_CAPS != x)
631
632
633 #----------------------------------------------------------------------------
634 # Inner Valgrind?
635 #----------------------------------------------------------------------------
636
637 # Check if this should be built as an inner Valgrind, to be run within
638 # another Valgrind.  Choose the load address accordingly.
639 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
640 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
641 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
642    [AC_ARG_ENABLE(inner, 
643       [  --enable-inner          enables self-hosting],
644       [vg_cv_inner=$enableval],
645       [vg_cv_inner=no])])
646 if test "$vg_cv_inner" = yes; then
647     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
648     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
649     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
650 else
651     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
652     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
653 fi
654
655
656 #----------------------------------------------------------------------------
657 # Libc and suppressions
658 #----------------------------------------------------------------------------
659 # This variable will collect the suppression files to be used.
660 AC_SUBST(DEFAULT_SUPP)
661
662 AC_CHECK_HEADER([features.h])
663
664 if test x$ac_cv_header_features_h = xyes; then
665   rm -f conftest.$ac_ext
666   cat <<_ACEOF >conftest.$ac_ext
667 #include <features.h>
668 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
669 glibc version is: __GLIBC__ __GLIBC_MINOR__
670 #endif
671 _ACEOF
672   GLIBC_VERSION="`$CPP conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
673 fi
674
675 AC_EGREP_CPP([AIX5_LIBC], [
676 #include <standards.h>
677 #if defined(_AIXVERSION_510) || defined(_AIXVERSION_520) || defined(_AIXVERSION_530)
678   AIX5_LIBC
679 #endif
680 ],
681 GLIBC_VERSION="aix5")
682
683 # not really a version check
684 AC_EGREP_CPP([DARWIN_LIBC], [
685 #include <sys/cdefs.h>
686 #if defined(__DARWIN_VERS_1050)
687   DARWIN_LIBC
688 #endif
689 ],
690 GLIBC_VERSION="darwin")
691
692 AC_MSG_CHECKING([the GLIBC_VERSION version])
693
694 case "${GLIBC_VERSION}" in
695      2.2)
696         AC_MSG_RESULT(2.2 family)
697         AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
698         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
699         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
700         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
701         ;;
702
703      2.3)
704         AC_MSG_RESULT(2.3 family)
705         AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
706         DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
707         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
708         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
709         ;;
710
711      2.4)
712         AC_MSG_RESULT(2.4 family)
713         AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
714         DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
715         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
716         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
717         ;;
718
719      2.5)
720         AC_MSG_RESULT(2.5 family)
721         AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
722         DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
723         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
724         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
725         ;;
726      2.6)
727         AC_MSG_RESULT(2.6 family)
728         AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
729         DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
730         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
731         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
732         ;;
733      2.7)
734         AC_MSG_RESULT(2.7 family)
735         AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
736         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
737         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
738         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
739         ;;
740      2.8)
741         AC_MSG_RESULT(2.8 family)
742         AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
743         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
744         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
745         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
746         ;;
747      2.9)
748         AC_MSG_RESULT(2.9 family)
749         AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
750         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
751         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
752         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
753         ;;
754      2.10)
755         AC_MSG_RESULT(2.10 family)
756         AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
757         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
758         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
759         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
760         ;;
761      2.11)
762         AC_MSG_RESULT(2.11 family)
763         AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
764         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
765         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
766         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
767         ;;
768      2.12)
769         AC_MSG_RESULT(2.12 family)
770         AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
771         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
772         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
773         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
774         ;;
775      2.13)
776         AC_MSG_RESULT(2.13 family)
777         AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
778         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
779         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
780         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
781         ;;
782      aix5)
783         AC_MSG_RESULT(AIX 5.1 or 5.2 or 5.3)
784         AC_DEFINE([AIX5_LIBC], 1, [Define to 1 if you're using AIX 5.1 or 5.2 or 5.3])
785         DEFAULT_SUPP="aix5libc.supp ${DEFAULT_SUPP}"
786         ;;
787      darwin)
788         AC_MSG_RESULT(Darwin)
789         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
790         # DEFAULT_SUPP set by kernel version check above.
791         ;;
792
793      *)
794         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
795         AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.13])
796         AC_MSG_ERROR([or AIX 5.1 or 5.2 or 5.3 GLIBC_VERSION])
797         AC_MSG_ERROR([or Darwin libc])
798         ;;
799 esac
800
801 AC_SUBST(GLIBC_VERSION)
802
803
804 # Add default suppressions for the X client libraries.  Make no
805 # attempt to detect whether such libraries are installed on the
806 # build machine (or even if any X facilities are present); just
807 # add the suppressions antidisirregardless.
808 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
809 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
810
811 # Add glibc and X11 suppressions for exp-ptrcheck
812 DEFAULT_SUPP="exp-ptrcheck.supp ${DEFAULT_SUPP}"
813
814
815 #----------------------------------------------------------------------------
816 # Checking for various library functions and other definitions
817 #----------------------------------------------------------------------------
818
819 # Check for CLOCK_MONOTONIC
820
821 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
822
823 AC_TRY_COMPILE(
824 [
825 #include <time.h>
826 ], [
827   struct timespec t;
828   clock_gettime(CLOCK_MONOTONIC, &t);
829   return 0;
830 ],
831 [
832 AC_MSG_RESULT([yes])
833 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
834           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
835 ], [
836 AC_MSG_RESULT([no])
837 ])
838
839
840 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
841
842 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
843
844 AC_TRY_COMPILE(
845 [
846 #define _GNU_SOURCE
847 #include <pthread.h>
848 ], [
849   return (PTHREAD_MUTEX_ADAPTIVE_NP);
850 ],
851 [
852 AC_MSG_RESULT([yes])
853 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
854           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
855 ], [
856 AC_MSG_RESULT([no])
857 ])
858
859
860 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
861
862 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
863
864 AC_TRY_COMPILE(
865 [
866 #define _GNU_SOURCE
867 #include <pthread.h>
868 ], [
869   return (PTHREAD_MUTEX_ERRORCHECK_NP);
870 ],
871 [
872 AC_MSG_RESULT([yes])
873 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
874           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
875 ], [
876 AC_MSG_RESULT([no])
877 ])
878
879
880 # Check for PTHREAD_MUTEX_RECURSIVE_NP
881
882 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
883
884 AC_TRY_COMPILE(
885 [
886 #define _GNU_SOURCE
887 #include <pthread.h>
888 ], [
889   return (PTHREAD_MUTEX_RECURSIVE_NP);
890 ],
891 [
892 AC_MSG_RESULT([yes])
893 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
894           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
895 ], [
896 AC_MSG_RESULT([no])
897 ])
898
899
900 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
901
902 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
903
904 AC_TRY_COMPILE(
905 [
906 #define _GNU_SOURCE
907 #include <pthread.h>
908 ], [
909   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
910   return 0;
911 ],
912 [
913 AC_MSG_RESULT([yes])
914 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
915           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
916 ], [
917 AC_MSG_RESULT([no])
918 ])
919
920
921 # Check whether pthread_mutex_t has a member called __m_kind.
922
923 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
924                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
925                            1,                                   
926                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
927                 ],
928                 [],
929                 [#include <pthread.h>])
930
931
932 # Check whether pthread_mutex_t has a member called __data.__kind.
933
934 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
935                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
936                           1,
937                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
938                 ],
939                 [],
940                 [#include <pthread.h>])
941
942
943 # does this compiler support -maltivec and does it have the include file
944 # <altivec.h> ?
945
946 AC_MSG_CHECKING([for Altivec])
947
948 safe_CFLAGS=$CFLAGS
949 CFLAGS="-maltivec"
950
951 AC_TRY_COMPILE(
952 [
953 #include <altivec.h>
954 ], [
955   vector unsigned int v;
956 ],
957 [
958 ac_have_altivec=yes
959 AC_MSG_RESULT([yes])
960 AC_DEFINE([HAS_ALTIVEC], 1,
961           [Define to 1 if gcc/as can do Altivec.])
962 ], [
963 ac_have_altivec=no
964 AC_MSG_RESULT([no])
965 ])
966 CFLAGS=$safe_CFLAGS
967
968 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
969
970
971 # Check for pthread_create@GLIBC2.0
972 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
973
974 safe_CFLAGS=$CFLAGS
975 CFLAGS="-lpthread"
976 AC_TRY_LINK(
977 [
978 extern int pthread_create_glibc_2_0(void*, const void*,
979                                     void *(*)(void*), void*);
980 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
981 ], [
982 #ifdef __powerpc__
983 /*
984  * Apparently on PowerPC linking this program succeeds and generates an
985  * executable with the undefined symbol pthread_create@GLIBC_2.0.
986  */
987 #error This test does not work properly on PowerPC.
988 #else
989   pthread_create_glibc_2_0(0, 0, 0, 0);
990 #endif
991   return 0;
992 ],
993 [
994 ac_have_pthread_create_glibc_2_0=yes
995 AC_MSG_RESULT([yes])
996 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
997           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
998 ], [
999 ac_have_pthread_create_glibc_2_0=no
1000 AC_MSG_RESULT([no])
1001 ])
1002 CFLAGS=$safe_CFLAGS
1003
1004 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1005                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1006
1007
1008 # Check for eventfd_t, eventfd() and eventfd_read()
1009 AC_MSG_CHECKING([for eventfd()])
1010
1011 AC_TRY_LINK(
1012 [
1013 #include <sys/eventfd.h>
1014 ], [
1015   eventfd_t ev;
1016   int fd;
1017
1018   fd = eventfd(5, 0);
1019   eventfd_read(fd, &ev);
1020   return 0;
1021 ],
1022 [
1023 AC_MSG_RESULT([yes])
1024 AC_DEFINE([HAVE_EVENTFD], 1,
1025           [Define to 1 if you have the `eventfd' function.])
1026 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1027           [Define to 1 if you have the `eventfd_read' function.])
1028 ], [
1029 AC_MSG_RESULT([no])
1030 ])
1031
1032
1033 #----------------------------------------------------------------------------
1034 # Checking for supported compiler flags.
1035 #----------------------------------------------------------------------------
1036
1037 # does this compiler support -m32 ?
1038 AC_MSG_CHECKING([if gcc accepts -m32])
1039
1040 safe_CFLAGS=$CFLAGS
1041 CFLAGS="-m32"
1042
1043 AC_TRY_COMPILE(, [
1044   return 0;
1045 ],
1046 [
1047 FLAG_M32="-m32"
1048 AC_MSG_RESULT([yes])
1049 ], [
1050 FLAG_M32=""
1051 AC_MSG_RESULT([no])
1052 ])
1053 CFLAGS=$safe_CFLAGS
1054
1055 AC_SUBST(FLAG_M32)
1056
1057
1058 # does this compiler support -maix32 ?
1059 AC_MSG_CHECKING([if gcc accepts -maix32])
1060
1061 safe_CFLAGS=$CFLAGS
1062 CFLAGS="-maix32"
1063
1064 AC_TRY_COMPILE(, [
1065   return 0;
1066 ],
1067 [
1068 FLAG_MAIX32="-maix32"
1069 AC_MSG_RESULT([yes])
1070 ], [
1071 FLAG_MAIX32=""
1072 AC_MSG_RESULT([no])
1073 ])
1074 CFLAGS=$safe_CFLAGS
1075
1076 AC_SUBST(FLAG_MAIX32)
1077
1078
1079 # does this compiler support -m64 ?
1080 AC_MSG_CHECKING([if gcc accepts -m64])
1081
1082 safe_CFLAGS=$CFLAGS
1083 CFLAGS="-m64"
1084
1085 AC_TRY_COMPILE(, [
1086   return 0;
1087 ],
1088 [
1089 FLAG_M64="-m64"
1090 AC_MSG_RESULT([yes])
1091 ], [
1092 FLAG_M64=""
1093 AC_MSG_RESULT([no])
1094 ])
1095 CFLAGS=$safe_CFLAGS
1096
1097 AC_SUBST(FLAG_M64)
1098
1099
1100 # does this compiler support -maix64 ?
1101 AC_MSG_CHECKING([if gcc accepts -maix64])
1102
1103 safe_CFLAGS=$CFLAGS
1104 CFLAGS="-maix64"
1105
1106 AC_TRY_COMPILE(, [
1107   return 0;
1108 ],
1109 [
1110 FLAG_MAIX64="-maix64"
1111 AC_MSG_RESULT([yes])
1112 ], [
1113 FLAG_MAIX64=""
1114 AC_MSG_RESULT([no])
1115 ])
1116 CFLAGS=$safe_CFLAGS
1117
1118 AC_SUBST(FLAG_MAIX64)
1119
1120
1121 # does this compiler support -mmmx ?
1122 AC_MSG_CHECKING([if gcc accepts -mmmx])
1123
1124 safe_CFLAGS=$CFLAGS
1125 CFLAGS="-mmmx"
1126
1127 AC_TRY_COMPILE(, [
1128   return 0;
1129 ],
1130 [
1131 FLAG_MMMX="-mmmx"
1132 AC_MSG_RESULT([yes])
1133 ], [
1134 FLAG_MMMX=""
1135 AC_MSG_RESULT([no])
1136 ])
1137 CFLAGS=$safe_CFLAGS
1138
1139 AC_SUBST(FLAG_MMMX)
1140
1141
1142 # does this compiler support -msse ?
1143 AC_MSG_CHECKING([if gcc accepts -msse])
1144
1145 safe_CFLAGS=$CFLAGS
1146 CFLAGS="-msse"
1147
1148 AC_TRY_COMPILE(, [
1149   return 0;
1150 ],
1151 [
1152 FLAG_MSSE="-msse"
1153 AC_MSG_RESULT([yes])
1154 ], [
1155 FLAG_MSSE=""
1156 AC_MSG_RESULT([no])
1157 ])
1158 CFLAGS=$safe_CFLAGS
1159
1160 AC_SUBST(FLAG_MSSE)
1161
1162
1163 # does this compiler support -mpreferred-stack-boundary=2 ?
1164 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1165
1166 safe_CFLAGS=$CFLAGS
1167 CFLAGS="-mpreferred-stack-boundary=2"
1168
1169 AC_TRY_COMPILE(, [
1170   return 0;
1171 ],
1172 [
1173 PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
1174 AC_MSG_RESULT([yes])
1175 ], [
1176 PREFERRED_STACK_BOUNDARY=""
1177 AC_MSG_RESULT([no])
1178 ])
1179 CFLAGS=$safe_CFLAGS
1180
1181 AC_SUBST(PREFERRED_STACK_BOUNDARY)
1182
1183
1184 # does this compiler support -Wno-pointer-sign ?
1185 AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
1186
1187 safe_CFLAGS=$CFLAGS
1188 CFLAGS="-Wno-pointer-sign"
1189
1190 AC_TRY_COMPILE(, [
1191   return 0;
1192 ],
1193 [
1194 no_pointer_sign=yes
1195 AC_MSG_RESULT([yes])
1196 ], [
1197 no_pointer_sign=no
1198 AC_MSG_RESULT([no])
1199 ])
1200 CFLAGS=$safe_CFLAGS
1201
1202 if test x$no_pointer_sign = xyes; then
1203   CFLAGS="$CFLAGS -Wno-pointer-sign"
1204 fi
1205
1206
1207 # does this compiler support -Wno-empty-body ?
1208
1209 AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
1210
1211 safe_CFLAGS=$CFLAGS
1212 CFLAGS="-Wno-empty-body"
1213
1214 AC_TRY_COMPILE(
1215 [ ],
1216 [
1217   return 0;
1218 ],
1219 [
1220 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [-Wno-empty-body])
1221 AC_MSG_RESULT([yes])
1222 ],
1223 [
1224 AC_SUBST([FLAG_W_NO_EMPTY_BODY], [])
1225 AC_MSG_RESULT([no])
1226 ])
1227 CFLAGS=$safe_CFLAGS
1228
1229
1230 # does this compiler support -Wno-format-zero-length ?
1231
1232 AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1233
1234 safe_CFLAGS=$CFLAGS
1235 CFLAGS="-Wno-format-zero-length"
1236
1237 AC_TRY_COMPILE(
1238 [ ],
1239 [
1240   return 0;
1241 ],
1242 [
1243 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1244 AC_MSG_RESULT([yes])
1245 ],
1246 [
1247 AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1248 AC_MSG_RESULT([no])
1249 ])
1250 CFLAGS=$safe_CFLAGS
1251
1252
1253 # does this compiler support -Wno-uninitialized ?
1254
1255 AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
1256
1257 safe_CFLAGS=$CFLAGS
1258 CFLAGS="-Wno-uninitialized"
1259
1260 AC_TRY_COMPILE(
1261 [ ],
1262 [
1263   return 0;
1264 ],
1265 [
1266 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
1267 AC_MSG_RESULT([yes])
1268 ],
1269 [
1270 AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
1271 AC_MSG_RESULT([no])
1272 ])
1273 CFLAGS=$safe_CFLAGS
1274
1275
1276 # does this compiler support -Wextra or the older -W ?
1277
1278 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1279
1280 safe_CFLAGS=$CFLAGS
1281 CFLAGS="-Wextra"
1282
1283 AC_TRY_COMPILE(
1284 [ ],
1285 [
1286   return 0;
1287 ],
1288 [
1289 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1290 AC_MSG_RESULT([-Wextra])
1291 ], [
1292   CFLAGS="-W"
1293   AC_TRY_COMPILE(
1294   [ ],
1295   [
1296     return 0;
1297   ],
1298   [
1299   AC_SUBST([FLAG_W_EXTRA], [-W])
1300   AC_MSG_RESULT([-W])
1301   ], [
1302   AC_SUBST([FLAG_W_EXTRA], [])
1303   AC_MSG_RESULT([not supported])
1304   ])
1305 ])
1306 CFLAGS=$safe_CFLAGS
1307
1308
1309 # does this compiler support -fno-stack-protector ?
1310 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1311
1312 safe_CFLAGS=$CFLAGS
1313 CFLAGS="-fno-stack-protector"
1314
1315 AC_TRY_COMPILE(, [
1316   return 0;
1317 ],
1318 [
1319 no_stack_protector=yes
1320 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1321 AC_MSG_RESULT([yes])
1322 ], [
1323 no_stack_protector=no
1324 FLAG_FNO_STACK_PROTECTOR=""
1325 AC_MSG_RESULT([no])
1326 ])
1327 CFLAGS=$safe_CFLAGS
1328
1329 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1330
1331 if test x$no_stack_protector = xyes; then
1332   CFLAGS="$CFLAGS -fno-stack-protector"
1333 fi
1334
1335
1336 # does this compiler support --param inline-unit-growth=... ?
1337
1338 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1339
1340 safe_CFLAGS=$CFLAGS
1341 CFLAGS="--param inline-unit-growth=900"
1342
1343 AC_TRY_COMPILE(
1344 [ ],
1345 [
1346   return 0;
1347 ],
1348 [
1349 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1350          ["--param inline-unit-growth=900"])
1351 AC_MSG_RESULT([yes])
1352 ], [
1353 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1354 AC_MSG_RESULT([no])
1355 ])
1356 CFLAGS=$safe_CFLAGS
1357
1358
1359 # does the linker support -Wl,--build-id=none ?  Note, it's
1360 # important that we test indirectly via whichever C compiler
1361 # is selected, rather than testing /usr/bin/ld or whatever
1362 # directly.
1363
1364 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1365
1366 safe_CFLAGS=$CFLAGS
1367 CFLAGS="-Wl,--build-id=none"
1368
1369 AC_LINK_IFELSE(
1370 [AC_LANG_PROGRAM([ ], [return 0;])],
1371 [
1372   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1373   AC_MSG_RESULT([yes])
1374 ], [
1375   AC_SUBST([FLAG_NO_BUILD_ID], [""])
1376   AC_MSG_RESULT([no])
1377 ])
1378 CFLAGS=$safe_CFLAGS
1379
1380
1381 # does the ppc assembler support "mtocrf" et al?
1382 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1383
1384 AC_TRY_COMPILE(, [
1385 __asm__ __volatile__("mtocrf 4,0");
1386 __asm__ __volatile__("mfocrf 0,4");
1387 ],
1388 [
1389 ac_have_as_ppc_mftocrf=yes
1390 AC_MSG_RESULT([yes])
1391 ], [
1392 ac_have_as_ppc_mftocrf=no
1393 AC_MSG_RESULT([no])
1394 ])
1395 if test x$ac_have_as_ppc_mftocrf = xyes ; then
1396   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1397 fi
1398
1399
1400 CFLAGS=$safe_CFLAGS
1401
1402 # does the x86/amd64 assembler understand SSE3 instructions?
1403 # Note, this doesn't generate a C-level symbol.  It generates a
1404 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
1405 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1406
1407 AC_TRY_COMPILE(, [
1408   do { long long int x; 
1409      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
1410   while (0)
1411 ],
1412 [
1413 ac_have_as_sse3=yes
1414 AC_MSG_RESULT([yes])
1415 ], [
1416 ac_have_as_sse3=no
1417 AC_MSG_RESULT([no])
1418 ])
1419
1420 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
1421
1422
1423 # Ditto for SSSE3 instructions (note extra S)
1424 # Note, this doesn't generate a C-level symbol.  It generates a
1425 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1426 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1427
1428 AC_TRY_COMPILE(, [
1429   do { long long int x; 
1430    __asm__ __volatile__(
1431       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1432   while (0)
1433 ],
1434 [
1435 ac_have_as_ssse3=yes
1436 AC_MSG_RESULT([yes])
1437 ], [
1438 ac_have_as_ssse3=no
1439 AC_MSG_RESULT([no])
1440 ])
1441
1442 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1443
1444
1445 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
1446 # Note, this doesn't generate a C-level symbol.  It generates a
1447 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
1448 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
1449 AC_TRY_COMPILE(, [
1450   do {
1451    __asm__ __volatile__(
1452       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
1453   while (0)
1454 ],
1455 [
1456 ac_have_as_pclmulqdq=yes
1457 AC_MSG_RESULT([yes])
1458 ], [
1459 ac_have_as_pclmulqdq=no
1460 AC_MSG_RESULT([no])
1461 ])
1462
1463 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
1464
1465
1466 # does the x86/amd64 assembler understand the LZCNT instruction?
1467 # Note, this doesn't generate a C-level symbol.  It generates a
1468 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
1469 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
1470
1471 AC_TRY_COMPILE([], [
1472   do {           
1473       __asm__ __volatile__("lzcnt %rax,%rax");
1474   } while (0)
1475 ],
1476 [
1477   ac_have_as_lzcnt=yes
1478   AC_MSG_RESULT([yes])
1479 ], [
1480   ac_have_as_lzcnt=no
1481   AC_MSG_RESULT([no])
1482 ])
1483
1484 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
1485
1486
1487 # does the x86/amd64 assembler understand SSE 4.2 instructions?
1488 # Note, this doesn't generate a C-level symbol.  It generates a
1489 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
1490 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
1491
1492 AC_TRY_COMPILE(, [
1493   do { long long int x; 
1494    __asm__ __volatile__(
1495       "crc32q %%r15,%%r15" : : : "r15" ); }
1496   while (0)
1497 ],
1498 [
1499 ac_have_as_sse42=yes
1500 AC_MSG_RESULT([yes])
1501 ], [
1502 ac_have_as_sse42=no
1503 AC_MSG_RESULT([no])
1504 ])
1505
1506 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
1507
1508
1509 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
1510 # when building the tool executables.  I think we should get rid of it.
1511 #
1512 # Check for TLS support in the compiler and linker
1513 if test "x${cross_compiling}" = "xno"; then
1514 # Native compilation: check whether running a program using TLS succeeds.
1515 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1516 # succeeds but running programs using TLS fails.
1517 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1518                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
1519                 [vg_cv_tls=$enableval],
1520                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1521                                                 [[return foo;]])],
1522                                [vg_cv_tls=yes],
1523                                [vg_cv_tls=no])])])
1524 else
1525 # Cross-compiling: check whether linking a program using TLS succeeds.
1526 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1527                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
1528                 [vg_cv_tls=$enableval],
1529                 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1530                                                 [[return foo;]])],
1531                                [vg_cv_tls=yes],
1532                                [vg_cv_tls=no])])])
1533 fi
1534
1535 if test "$vg_cv_tls" = yes; then
1536 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1537 fi
1538
1539
1540 #----------------------------------------------------------------------------
1541 # Checks for C header files.
1542 #----------------------------------------------------------------------------
1543
1544 AC_HEADER_STDC
1545 AC_CHECK_HEADERS([       \
1546         asm/unistd.h     \
1547         endian.h         \
1548         mqueue.h         \
1549         sys/endian.h     \
1550         sys/epoll.h      \
1551         sys/eventfd.h    \
1552         sys/klog.h       \
1553         sys/poll.h       \
1554         sys/signal.h     \
1555         sys/signalfd.h   \
1556         sys/syscall.h    \
1557         sys/time.h       \
1558         sys/types.h      \
1559         ])
1560
1561 #----------------------------------------------------------------------------
1562 # Checks for typedefs, structures, and compiler characteristics.
1563 #----------------------------------------------------------------------------
1564 AC_TYPE_UID_T
1565 AC_TYPE_OFF_T
1566 AC_TYPE_SIZE_T
1567 AC_HEADER_TIME
1568
1569
1570 #----------------------------------------------------------------------------
1571 # Checks for library functions.
1572 #----------------------------------------------------------------------------
1573 AC_FUNC_MEMCMP
1574 AC_FUNC_MMAP
1575 AC_TYPE_SIGNAL
1576
1577 AC_CHECK_LIB([pthread], [pthread_create])
1578 AC_CHECK_LIB([rt], [clock_gettime])
1579
1580 AC_CHECK_FUNCS([     \
1581         clock_gettime\
1582         epoll_create \
1583         epoll_pwait  \
1584         klogctl      \
1585         mallinfo     \
1586         memchr       \
1587         memset       \
1588         mkdir        \
1589         mremap       \
1590         ppoll        \
1591         pthread_barrier_init       \
1592         pthread_condattr_setclock  \
1593         pthread_mutex_timedlock    \
1594         pthread_rwlock_timedrdlock \
1595         pthread_rwlock_timedwrlock \
1596         pthread_spin_lock          \
1597         pthread_yield              \
1598         readlinkat   \
1599         semtimedop   \
1600         signalfd     \
1601         sigwaitinfo  \
1602         strchr       \
1603         strdup       \
1604         strpbrk      \
1605         strrchr      \
1606         strstr       \
1607         syscall      \
1608         utimensat    \
1609         ])
1610
1611 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1612 # libraries with any shared object and/or executable. This is NOT what we
1613 # want for e.g. vgpreload_core-x86-linux.so
1614 LIBS=""
1615
1616 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1617                [test x$ac_cv_func_pthread_barrier_init = xyes])
1618 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1619                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
1620 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1621                [test x$ac_cv_func_pthread_spin_lock = xyes])
1622
1623
1624 #----------------------------------------------------------------------------
1625 # MPI checks
1626 #----------------------------------------------------------------------------
1627 # Do we have a useable MPI setup on the primary and/or secondary targets?
1628 # On Linux, by default, assumes mpicc and -m32/-m64
1629 # On AIX, by default, assumes mpxlc and -q32/-q64
1630 # Note: this is a kludge in that it assumes the specified mpicc 
1631 # understands -m32/-m64/-q32/-q64 regardless of what is specified using
1632 # --with-mpicc=.
1633 MPI_CC="mpicc"
1634 if test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
1635      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 ; then
1636   MPI_CC="mpxlc"
1637 fi
1638
1639 mflag_primary=
1640 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1641      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX ; then
1642   mflag_primary=$FLAG_M32
1643 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1644        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
1645        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
1646   mflag_primary=$FLAG_M64
1647 elif test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 ; then
1648   mflag_primary=-q32
1649 elif test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 ; then
1650   mflag_primary=-q64
1651 fi
1652
1653 mflag_secondary=
1654 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1655      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
1656   mflag_secondary=$FLAG_M32
1657 elif test x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5 ; then
1658   mflag_secondary=-q32
1659 fi
1660
1661
1662 AC_ARG_WITH(mpicc,
1663    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
1664    MPI_CC=$withval
1665 )
1666 AC_SUBST(MPI_CC)
1667
1668 ## See if MPI_CC works for the primary target
1669 ##
1670 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
1671 saved_CC=$CC
1672 saved_CFLAGS=$CFLAGS
1673 CC=$MPI_CC
1674 CFLAGS=$mflag_primary
1675 AC_TRY_LINK([
1676 #include <mpi.h>
1677 #include <stdio.h>
1678 ],[
1679   int r = MPI_Init(NULL,NULL);
1680   r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1681   return r; 
1682 ], [
1683 ac_have_mpi2_pri=yes
1684 AC_MSG_RESULT([yes, $MPI_CC])
1685 ], [
1686 ac_have_mpi2_pri=no
1687 AC_MSG_RESULT([no])
1688 ])
1689 CC=$saved_CC
1690 CFLAGS=$saved_CFLAGS
1691 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
1692
1693 ## See if MPI_CC works for the secondary target.  Complication: what if
1694 ## there is no secondary target?  We need this to then fail.
1695 ## Kludge this by making MPI_CC something which will surely fail in
1696 ## such a case.
1697 ##
1698 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1699 saved_CC=$CC
1700 saved_CFLAGS=$CFLAGS
1701 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
1702   CC="$MPI_CC this will surely fail"
1703 else
1704   CC=$MPI_CC
1705 fi
1706 CFLAGS=$mflag_secondary
1707 AC_TRY_LINK([
1708 #include <mpi.h>
1709 #include <stdio.h>
1710 ],[
1711   int r = MPI_Init(NULL,NULL);
1712   r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1713   return r; 
1714 ], [
1715 ac_have_mpi2_sec=yes
1716 AC_MSG_RESULT([yes, $MPI_CC])
1717 ], [
1718 ac_have_mpi2_sec=no
1719 AC_MSG_RESULT([no])
1720 ])
1721 CC=$saved_CC
1722 CFLAGS=$saved_CFLAGS
1723 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
1724
1725
1726 #----------------------------------------------------------------------------
1727 # Other library checks
1728 #----------------------------------------------------------------------------
1729 # There now follow some tests for Boost, and OpenMP.  These
1730 # tests are present because Drd has some regression tests that use
1731 # these packages.  All regression test programs all compiled only
1732 # for the primary target.  And so it is important that the configure
1733 # checks that follow, use the correct -m32 or -m64 flag for the
1734 # primary target (called $mflag_primary).  Otherwise, we can end up
1735 # in a situation (eg) where, on amd64-linux, the test for Boost checks
1736 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
1737 # only build (meaning, the primary target is x86-linux), the build
1738 # of the regtest programs that use Boost fails, because they are 
1739 # build as 32-bit (IN THIS EXAMPLE).
1740 #
1741 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1742 # NEEDED BY THE REGRESSION TEST PROGRAMS.
1743
1744
1745 # Check whether the boost library 1.35 or later has been installed.
1746 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1747
1748 AC_MSG_CHECKING([for boost])
1749
1750 AC_LANG(C++)
1751 safe_CXXFLAGS=$CXXFLAGS
1752 CXXFLAGS="-lboost_thread-mt $mflag_primary"
1753
1754 AC_LINK_IFELSE([AC_LANG_SOURCE([
1755 #include <boost/thread.hpp>
1756 static void thread_func(void)
1757 { }
1758 int main(int argc, char** argv)
1759 {
1760   boost::thread t(thread_func);
1761   return 0;
1762 }
1763 ])],
1764 [
1765 ac_have_boost_1_35=yes
1766 AC_SUBST([BOOST_CFLAGS], [])
1767 AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1768 AC_MSG_RESULT([yes])
1769 ], [
1770 ac_have_boost_1_35=no
1771 AC_MSG_RESULT([no])
1772 ])
1773
1774 CXXFLAGS=$safe_CXXFLAGS
1775 AC_LANG(C)
1776
1777 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1778
1779
1780 # does this compiler support -fopenmp, does it have the include file
1781 # <omp.h> and does it have libgomp ?
1782
1783 AC_MSG_CHECKING([for OpenMP])
1784
1785 safe_CFLAGS=$CFLAGS
1786 CFLAGS="-fopenmp $mflag_primary"
1787
1788 AC_LINK_IFELSE([AC_LANG_SOURCE([
1789 #include <omp.h> 
1790 int main(int argc, char** argv)
1791 {
1792   omp_set_dynamic(0);
1793   return 0;
1794 }
1795 ])],
1796 [
1797 ac_have_openmp=yes
1798 AC_MSG_RESULT([yes])
1799 ], [
1800 ac_have_openmp=no
1801 AC_MSG_RESULT([no])
1802 ])
1803 CFLAGS=$safe_CFLAGS
1804
1805 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1806
1807
1808 # does this compiler have built-in functions for atomic memory access ?
1809 AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
1810
1811 safe_CFLAGS=$CFLAGS
1812 CFLAGS="$mflag_primary"
1813
1814 AC_TRY_LINK(,
1815 [
1816   int variable = 1;
1817   return (__sync_bool_compare_and_swap(&variable, 1, 2)
1818           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1819 ],
1820 [
1821   ac_have_builtin_atomic=yes
1822   AC_MSG_RESULT([yes])
1823   AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
1824 ],
1825 [
1826   ac_have_builtin_atomic=no
1827   AC_MSG_RESULT([no])
1828 ])
1829
1830 CFLAGS=$safe_CFLAGS
1831
1832 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC], [test x$ac_have_builtin_atomic = xyes])
1833
1834 # does g++ have built-in functions for atomic memory access ?
1835 AC_MSG_CHECKING([if g++ supports __sync_bool_compare_and_swap])
1836
1837 safe_CXXFLAGS=$CXXFLAGS
1838 CXXFLAGS="$mflag_primary"
1839
1840 AC_LANG_PUSH(C++)
1841 AC_TRY_LINK(,
1842 [
1843   int variable = 1;
1844   return (__sync_bool_compare_and_swap(&variable, 1, 2)
1845           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1846 ],
1847 [
1848   ac_have_builtin_atomic_cxx=yes
1849   AC_MSG_RESULT([yes])
1850   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
1851 ],
1852 [
1853   ac_have_builtin_atomic_cxx=no
1854   AC_MSG_RESULT([no])
1855 ])
1856 AC_LANG_POP(C++)
1857
1858 CXXFLAGS=$safe_CXXFLAGS
1859
1860 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
1861
1862 #----------------------------------------------------------------------------
1863 # Ok.  We're done checking.
1864 #----------------------------------------------------------------------------
1865
1866 # Nb: VEX/Makefile is generated from Makefile.vex.in.
1867 AC_CONFIG_FILES([
1868    Makefile 
1869    VEX/Makefile:Makefile.vex.in
1870    valgrind.spec
1871    valgrind.pc
1872    glibc-2.X.supp
1873    docs/Makefile 
1874    tests/Makefile 
1875    tests/vg_regtest 
1876    perf/Makefile 
1877    perf/vg_perf
1878    include/Makefile 
1879    auxprogs/Makefile
1880    mpi/Makefile
1881    coregrind/Makefile 
1882    memcheck/Makefile
1883    memcheck/tests/Makefile
1884    memcheck/tests/amd64/Makefile
1885    memcheck/tests/x86/Makefile
1886    memcheck/tests/linux/Makefile
1887    memcheck/tests/darwin/Makefile
1888    memcheck/tests/amd64-linux/Makefile
1889    memcheck/tests/x86-linux/Makefile
1890    memcheck/tests/ppc32/Makefile
1891    memcheck/tests/ppc64/Makefile
1892    memcheck/perf/Makefile
1893    cachegrind/Makefile
1894    cachegrind/tests/Makefile
1895    cachegrind/tests/x86/Makefile
1896    cachegrind/cg_annotate
1897    cachegrind/cg_diff
1898    callgrind/Makefile
1899    callgrind/callgrind_annotate
1900    callgrind/callgrind_control
1901    callgrind/tests/Makefile
1902    helgrind/Makefile
1903    helgrind/tests/Makefile
1904    massif/Makefile
1905    massif/tests/Makefile
1906    massif/perf/Makefile
1907    massif/ms_print
1908    lackey/Makefile
1909    lackey/tests/Makefile
1910    none/Makefile
1911    none/tests/Makefile
1912    none/tests/amd64/Makefile
1913    none/tests/ppc32/Makefile
1914    none/tests/ppc64/Makefile
1915    none/tests/x86/Makefile
1916    none/tests/arm/Makefile
1917    none/tests/s390x/Makefile
1918    none/tests/linux/Makefile
1919    none/tests/darwin/Makefile
1920    none/tests/x86-linux/Makefile
1921    exp-ptrcheck/Makefile
1922    exp-ptrcheck/tests/Makefile
1923    drd/Makefile
1924    drd/scripts/download-and-build-splash2
1925    drd/tests/Makefile
1926    exp-bbv/Makefile
1927    exp-bbv/tests/Makefile
1928    exp-bbv/tests/x86/Makefile
1929    exp-bbv/tests/x86-linux/Makefile
1930    exp-bbv/tests/amd64-linux/Makefile
1931    exp-bbv/tests/ppc32-linux/Makefile
1932    exp-bbv/tests/arm-linux/Makefile
1933    exp-dhat/Makefile
1934    exp-dhat/tests/Makefile
1935 ])
1936 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
1937                 [chmod +x coregrind/link_tool_exe_linux])
1938 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
1939                 [chmod +x coregrind/link_tool_exe_darwin])
1940 AC_CONFIG_FILES([coregrind/link_tool_exe_aix5],
1941                 [chmod +x coregrind/link_tool_exe_aix5])
1942 AC_OUTPUT
1943
1944 cat<<EOF
1945
1946          Maximum build arch: ${ARCH_MAX}
1947          Primary build arch: ${VGCONF_ARCH_PRI}
1948        Secondary build arch: ${VGCONF_ARCH_SEC}
1949                    Build OS: ${VGCONF_OS}
1950        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
1951      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
1952          Default supp files: ${DEFAULT_SUPP}
1953
1954 EOF