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