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