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