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