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