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