blob: ed8fd3fe343c94bd91bff99345dc90d82814262c [file] [log] [blame]
sewardj01262142006-01-04 01:20:28 +00001
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
sewardjde4a1d02002-03-22 01:27:54 +000010# Process this file with autoconf to produce a configure script.
sewardj8d37f362009-01-05 17:14:12 +000011AC_INIT(Valgrind, 3.5.0.SVN, valgrind-users@lists.sourceforge.net)
njn04e16982005-05-31 00:23:43 +000012AC_CONFIG_SRCDIR(coregrind/m_main.c)
sewardjde4a1d02002-03-22 01:27:54 +000013AM_CONFIG_HEADER(config.h)
bart3a2dac02008-03-18 17:40:38 +000014AM_INIT_AUTOMAKE([foreign])
sewardjde4a1d02002-03-22 01:27:54 +000015
gobryb0ed4672002-03-27 20:58:58 +000016AM_MAINTAINER_MODE
17
njn7fd6d382009-01-22 21:56:32 +000018#----------------------------------------------------------------------------
njn8738c282004-11-23 16:31:56 +000019# Where is VEX ?
njn7fd6d382009-01-22 21:56:32 +000020#----------------------------------------------------------------------------
njnfe408942004-11-23 17:52:24 +000021# Nb: For the 2nd arg, the help string, AS_HELP_STRING is the proper way, but
22# older autoconfs don't support it... here's what it would say:
23#
sewardj85a9dca2005-07-26 10:42:57 +000024# AS_HELP_STRING([--with-vex], [Vex directory]),
njnfe408942004-11-23 17:52:24 +000025#
njn8738c282004-11-23 16:31:56 +000026AC_ARG_WITH(vex,
sewardj85a9dca2005-07-26 10:42:57 +000027 [ --with-vex=/path/to/vex/dir Vex directory],
njn8738c282004-11-23 16:31:56 +000028[
29 AC_CHECK_FILE($withval/pub/libvex.h,
30 [VEX_DIR=$withval],
31 [AC_MSG_ERROR([Directory '$withval' does not exist, or does not contain Vex])])
32],
33[
njn17adf1e2005-09-16 03:59:37 +000034 VEX_DIR='$(top_srcdir)/VEX'
njn8738c282004-11-23 16:31:56 +000035])
sewardj50629ec2004-11-22 13:44:11 +000036AC_SUBST(VEX_DIR)
37
njn657d9512005-06-24 15:20:52 +000038# "make distcheck" first builds a tarball, then extracts it.
39# Then it creates a build directory different from the extracted sources
40# (called _build), and issues
41#
42# ../configure $(DISTCHECK_CONFIGURE_FLAGS)
43#
44# and then builds, runs "make check", installs using DESTDIR, runs make
45# installcheck, uninstalls, checks whether the installed base is empty
46# again, then does yet another "make dist" and compares the resulting
47# tarball with the one it started off with for identical content. Then it
48# tests "make distclean" for no leftover files.
49#
50# So this line means: when doing "make dist", use the same --with-vex value
51# that you used when running configure to configure this tree in the first
52# place.
53AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], [--with-vex=$VEX_DIR])
54
njn7fd6d382009-01-22 21:56:32 +000055#----------------------------------------------------------------------------
56# Checks for various programs.
57#----------------------------------------------------------------------------
sewardjb5f6f512005-03-10 23:59:00 +000058CFLAGS="-Wno-long-long"
gobrye721a522002-03-22 13:38:30 +000059
sewardjde4a1d02002-03-22 01:27:54 +000060AC_PROG_LN_S
61AC_PROG_CC
bart0affa492008-03-18 17:53:09 +000062AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000063AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000064AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000065AC_PROG_RANLIB
66
bartcddeaf52008-05-25 15:58:11 +000067# If no AR variable was specified, look up the name of the archiver. Otherwise
68# do not touch the AR variable.
69if test "x$AR" = "x"; then
70 AC_PATH_PROGS([AR], ["${LD%ld}ar" "ar"], [ar])
71fi
72AC_ARG_VAR([AR],[Archiver command])
73
gobrye721a522002-03-22 13:38:30 +000074# Check for the compiler support
75if test "${GCC}" != "yes" ; then
76 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
77fi
78
sewardj2f685952002-12-22 19:32:23 +000079# figure out where perl lives
80AC_PATH_PROG(PERL, perl)
81
njn9315df32003-04-16 20:50:50 +000082# figure out where gdb lives
sewardjf8722ca2008-11-17 00:20:45 +000083AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
njnfe408942004-11-23 17:52:24 +000084AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
njn9315df32003-04-16 20:50:50 +000085
daywalker48ccca52002-04-15 00:31:58 +000086# some older automake's don't have it so try something on our own
87ifdef([AM_PROG_AS],[AM_PROG_AS],
88[
gobry1be19852002-03-26 20:44:55 +000089AS="${CC}"
90AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000091
gobry1be19852002-03-26 20:44:55 +000092ASFLAGS=""
93AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000094])
gobry3b777892002-04-04 09:18:39 +000095
gobry3b777892002-04-04 09:18:39 +000096
sewardjf33b4332008-07-18 18:20:42 +000097# Check we have GNU sed: some of the stuff done by "make install" relies
98# on some pretty fancy sed expressions, and AIX sed doesn't produce the
99# same results, causing install to fail
100
101AC_MSG_CHECKING([for GNU sed])
102
103[sed_firstline=`sed --version | head -n 1`]
104
105case "${sed_firstline}" in
106 GNU*)
107 AC_MSG_RESULT([ok, looks like GNU sed])
108 ;;
109 *)
110 AC_MSG_RESULT([please ensure first 'sed' in your path is GNU sed])
111 AC_MSG_RESULT([note: GNU sed is only required at build/install time])
112 AC_MSG_ERROR([build/install requires that 'sed' is GNU sed])
113 ;;
114esac
115
116
njn0d2e58f2009-02-25 04:57:56 +0000117# Check if 'diff' supports -u (universal diffs) and use it if possible.
118
119AC_MSG_CHECKING([for diff -u])
120AC_SUBST(DIFF)
121
122# Comparing two identical files results in 0, unless -u isn't supported (as
123# it's not on AIX).
124touch tmp-xxx;
125if diff -u tmp-xxx tmp-xxx ; then
126 AC_MSG_RESULT([yes])
127 DIFF="diff -u"
128else
129 AC_MSG_RESULT([no])
130 DIFF="diff"
131fi
132
133
sewardj535c50f2005-06-04 23:14:53 +0000134# We don't want gcc < 3.0
gobrye721a522002-03-22 13:38:30 +0000135AC_MSG_CHECKING([for a supported version of gcc])
136
sewardjf33b4332008-07-18 18:20:42 +0000137[gcc_version=`${CC} --version | head -n 1 | sed 's/^[^0-9]*\([0-9.]*\).*$/\1/'`]
gobrye721a522002-03-22 13:38:30 +0000138
139case "${gcc_version}" in
bart76719bf2008-04-19 07:47:56 +0000140 2.*)
gobrye721a522002-03-22 13:38:30 +0000141 AC_MSG_RESULT([no (${gcc_version})])
sewardj535c50f2005-06-04 23:14:53 +0000142 AC_MSG_ERROR([please use a recent (>= gcc-3.0) version of gcc])
143 ;;
gobrye721a522002-03-22 13:38:30 +0000144 *)
145 AC_MSG_RESULT([ok (${gcc_version})])
146 ;;
147esac
148
njn7fd6d382009-01-22 21:56:32 +0000149#----------------------------------------------------------------------------
150# Arch/OS/platform tests.
151#----------------------------------------------------------------------------
152# We create a number of arch/OS/platform-related variables. We prefix them
153# all with "VGCONF_" which indicates that they are defined at
154# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
155# variables used when compiling C files.
sewardj03d86f22006-10-17 00:57:24 +0000156
sewardjde4a1d02002-03-22 01:27:54 +0000157AC_CANONICAL_HOST
158
159AC_MSG_CHECKING([for a supported CPU])
sewardjbc692db2006-01-04 03:31:07 +0000160
njn7fd6d382009-01-22 21:56:32 +0000161# ARCH_MAX reflects the most that this CPU can do: for example if it
162# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
163# Ditto for amd64. It is used for more configuration below, but is not used
164# outside this file.
gobrye721a522002-03-22 13:38:30 +0000165case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +0000166 i?86)
167 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000168 ARCH_MAX="x86"
sewardjde4a1d02002-03-22 01:27:54 +0000169 ;;
170
njnfe408942004-11-23 17:52:24 +0000171 x86_64)
172 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000173 ARCH_MAX="amd64"
njnfe408942004-11-23 17:52:24 +0000174 ;;
175
sewardj2c48c7b2005-11-29 13:05:56 +0000176 powerpc64)
njn7fd6d382009-01-22 21:56:32 +0000177 # This value can only happen on Linux, not on AIX
sewardj2c48c7b2005-11-29 13:05:56 +0000178 AC_MSG_RESULT([ok (${host_cpu})])
njn7fd6d382009-01-22 21:56:32 +0000179 ARCH_MAX="ppc64"
sewardj2c48c7b2005-11-29 13:05:56 +0000180 ;;
181
182 powerpc)
njn7fd6d382009-01-22 21:56:32 +0000183 # Complexity. 'powerpc' on AIX implies a 64-bit capable CPU.
184 # Whereas in Linux that means only a 32-bit capable CPU.
cerion85665ca2005-06-20 15:51:07 +0000185 AC_MSG_RESULT([ok (${host_cpu})])
sewardj03d86f22006-10-17 00:57:24 +0000186 case "${host_os}" in
187 aix5.*)
njn7fd6d382009-01-22 21:56:32 +0000188 ARCH_MAX="ppc64"
sewardj03d86f22006-10-17 00:57:24 +0000189 ;;
190 *)
njn7fd6d382009-01-22 21:56:32 +0000191 ARCH_MAX="ppc32"
sewardj03d86f22006-10-17 00:57:24 +0000192 ;;
193 esac
nethercote9bcc9062004-10-13 13:50:01 +0000194 ;;
195
sewardjde4a1d02002-03-22 01:27:54 +0000196 *)
197 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +0000198 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +0000199 ;;
200esac
201
njn7fd6d382009-01-22 21:56:32 +0000202#----------------------------------------------------------------------------
203
sewardj86e992f2006-01-28 18:39:09 +0000204# Sometimes it's convenient to subvert the bi-arch build system and
205# just have a single build even though the underlying platform is
206# capable of both. Hence handle --enable-only64bit and
207# --enable-only32bit. Complain if both are issued :-)
njn7fd6d382009-01-22 21:56:32 +0000208# [Actually, if either of these options are used, I think both get built,
209# but only one gets installed. So if you use an in-place build, both can be
210# used. --njn]
sewardj86e992f2006-01-28 18:39:09 +0000211
212# Check if a 64-bit only build has been requested
213AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
214 [AC_ARG_ENABLE(only64bit,
215 [ --enable-only64bit do a 64-bit only build],
216 [vg_cv_only64bit=$enableval],
217 [vg_cv_only64bit=no])])
218
219# Check if a 32-bit only build has been requested
220AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
221 [AC_ARG_ENABLE(only32bit,
222 [ --enable-only32bit do a 32-bit only build],
223 [vg_cv_only32bit=$enableval],
224 [vg_cv_only32bit=no])])
225
226# Stay sane
227if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
228 AC_MSG_ERROR(
229 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
230fi
231
njn7fd6d382009-01-22 21:56:32 +0000232#----------------------------------------------------------------------------
sewardj86e992f2006-01-28 18:39:09 +0000233
njn311303f2009-02-06 03:46:50 +0000234# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
235# compilation of many C files via -VGO_$(VGCONF_OS) and
236# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
sewardjde4a1d02002-03-22 01:27:54 +0000237AC_MSG_CHECKING([for a supported OS])
njn7fd6d382009-01-22 21:56:32 +0000238AC_SUBST(VGCONF_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000239
gobrye721a522002-03-22 13:38:30 +0000240case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000241 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000242 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000243 VGCONF_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000244
245 # Ok, this is linux. Check the kernel version
246 AC_MSG_CHECKING([for the kernel version])
247
248 kernel=`uname -r`
249
250 case "${kernel}" in
251 2.6.*)
252 AC_MSG_RESULT([2.6 family (${kernel})])
253 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
254 ;;
255
256 2.4.*)
257 AC_MSG_RESULT([2.4 family (${kernel})])
258 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
259 ;;
260
mueller8c68e042004-01-03 15:21:14 +0000261 *)
262 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000263 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000264 ;;
265 esac
266
267 ;;
268
sewardj03d86f22006-10-17 00:57:24 +0000269 aix5.1.*)
270 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000271 VGCONF_OS="aix5"
sewardj03d86f22006-10-17 00:57:24 +0000272 ;;
273 aix5.2.*)
274 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000275 VGCONF_OS="aix5"
sewardj03d86f22006-10-17 00:57:24 +0000276 ;;
277 aix5.3.*)
278 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000279 VGCONF_OS="aix5"
sewardj03d86f22006-10-17 00:57:24 +0000280 ;;
281
mueller8c68e042004-01-03 15:21:14 +0000282 *freebsd*)
283 AC_MSG_RESULT([ok (${host_os})])
njn7fd6d382009-01-22 21:56:32 +0000284 VGCONF_OS="freebsd"
sewardjde4a1d02002-03-22 01:27:54 +0000285 ;;
286
287 *)
288 AC_MSG_RESULT([no (${host_os})])
mueller8c68e042004-01-03 15:21:14 +0000289 AC_MSG_ERROR([Valgrind is operating system specific. Sorry. Please consider doing a port.])
sewardjde4a1d02002-03-22 01:27:54 +0000290 ;;
291esac
292
njn7fd6d382009-01-22 21:56:32 +0000293#----------------------------------------------------------------------------
294
tomd6398392006-06-07 17:44:36 +0000295# If we are building on a 64 bit platform test to see if the system
296# supports building 32 bit programs and disable 32 bit support if it
297# does not support building 32 bit programs
298
njn7fd6d382009-01-22 21:56:32 +0000299case "$ARCH_MAX-$VGCONF_OS" in
tomd6398392006-06-07 17:44:36 +0000300 amd64-linux|ppc64-linux)
301 AC_MSG_CHECKING([for 32 bit build support])
302 safe_CFLAGS=$CFLAGS
303 CFLAGS="-m32"
304 AC_TRY_LINK(, [
njn9890ee12009-01-21 22:25:50 +0000305 return 0;
tomd6398392006-06-07 17:44:36 +0000306 ],
307 [
308 AC_MSG_RESULT([yes])
309 ], [
310 vg_cv_only64bit="yes"
311 AC_MSG_RESULT([no])
312 ])
313 CFLAGS=$safe_CFLAGS;;
314esac
315
316if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
317 AC_MSG_ERROR(
318 [--enable-only32bit was specified but system does not support 32 bit builds])
319fi
nethercote888ecb72004-08-23 14:54:40 +0000320
njn7fd6d382009-01-22 21:56:32 +0000321#----------------------------------------------------------------------------
322
njn311303f2009-02-06 03:46:50 +0000323# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
324# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
325# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
326# above) will be "amd64" since that reflects the most that this cpu can do,
327# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
328# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
njn7fd6d382009-01-22 21:56:32 +0000329# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
330# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
331AC_SUBST(VGCONF_ARCH_PRI)
332
njn311303f2009-02-06 03:46:50 +0000333# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
334# The entire system, including regression and performance tests, will be
335# built for this target. The "_CAPS" indicates that the name is in capital
336# letters, and it also uses '_' rather than '-' as a separator, because it's
njn7fd6d382009-01-22 21:56:32 +0000337# used to create various Makefile variables, which are all in caps by
njn311303f2009-02-06 03:46:50 +0000338# convention and cannot contain '-' characters. This is in contrast to
339# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
njn7fd6d382009-01-22 21:56:32 +0000340AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
341
342# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
343# Valgrind and tools will also be built for this target, but not the
344# regression or performance tests.
sewardj01262142006-01-04 01:20:28 +0000345#
njn7fd6d382009-01-22 21:56:32 +0000346# By default, the primary arch is the same as the "max" arch, as commented
347# above (at the definition of ARCH_MAX). We may choose to downgrade it in
348# the big case statement just below here, in the case where we're building
349# on a 64 bit machine but have been requested only to do a 32 bit build.
350AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
351
sewardj01262142006-01-04 01:20:28 +0000352AC_MSG_CHECKING([for a supported CPU/OS combination])
nethercote888ecb72004-08-23 14:54:40 +0000353
njn7fd6d382009-01-22 21:56:32 +0000354case "$ARCH_MAX-$VGCONF_OS" in
sewardj01262142006-01-04 01:20:28 +0000355 x86-linux)
njn7fd6d382009-01-22 21:56:32 +0000356 VGCONF_ARCH_PRI="x86"
357 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
358 VGCONF_PLATFORM_SEC_CAPS=""
njnd74b0ef2009-01-20 06:06:52 +0000359 valt_load_address_normal="0x38000000"
360 valt_load_address_inner="0x28000000"
sewardj3e38ce02004-11-23 01:17:29 +0000361 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
sewardj01262142006-01-04 01:20:28 +0000362 ;;
363 amd64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000364 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000365 VGCONF_ARCH_PRI="amd64"
366 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
367 VGCONF_PLATFORM_SEC_CAPS=""
sewardj86e992f2006-01-28 18:39:09 +0000368 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000369 VGCONF_ARCH_PRI="x86"
370 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
371 VGCONF_PLATFORM_SEC_CAPS=""
sewardj86e992f2006-01-28 18:39:09 +0000372 else
njn7fd6d382009-01-22 21:56:32 +0000373 VGCONF_ARCH_PRI="amd64"
374 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
375 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
sewardj86e992f2006-01-28 18:39:09 +0000376 fi
njnd74b0ef2009-01-20 06:06:52 +0000377 valt_load_address_normal="0x38000000"
378 valt_load_address_inner="0x28000000"
sewardj01262142006-01-04 01:20:28 +0000379 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
380 ;;
381 ppc32-linux)
njn7fd6d382009-01-22 21:56:32 +0000382 VGCONF_ARCH_PRI="ppc32"
383 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
384 VGCONF_PLATFORM_SEC_CAPS=""
njnd74b0ef2009-01-20 06:06:52 +0000385 valt_load_address_normal="0x38000000"
386 valt_load_address_inner="0x28000000"
sewardj01262142006-01-04 01:20:28 +0000387 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
388 ;;
sewardj03d86f22006-10-17 00:57:24 +0000389 ppc64-aix5)
390 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000391 VGCONF_ARCH_PRI="ppc64"
392 VGCONF_PLATFORM_PRI_CAPS="PPC64_AIX5"
393 VGCONF_PLATFORM_SEC_CAPS=""
sewardj03d86f22006-10-17 00:57:24 +0000394 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000395 VGCONF_ARCH_PRI="ppc32"
396 VGCONF_PLATFORM_PRI_CAPS="PPC32_AIX5"
397 VGCONF_PLATFORM_SEC_CAPS=""
sewardj03d86f22006-10-17 00:57:24 +0000398 else
njn7fd6d382009-01-22 21:56:32 +0000399 VGCONF_ARCH_PRI="ppc64"
400 VGCONF_PLATFORM_PRI_CAPS="PPC64_AIX5"
401 VGCONF_PLATFORM_SEC_CAPS="PPC32_AIX5"
sewardj03d86f22006-10-17 00:57:24 +0000402 fi
njnd74b0ef2009-01-20 06:06:52 +0000403 valt_load_address_normal="0x38000000"
404 valt_load_address_inner="0x28000000"
sewardj03d86f22006-10-17 00:57:24 +0000405 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
406 ;;
sewardj01262142006-01-04 01:20:28 +0000407 ppc64-linux)
sewardj86e992f2006-01-28 18:39:09 +0000408 if test x$vg_cv_only64bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000409 VGCONF_ARCH_PRI="ppc64"
410 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
411 VGCONF_PLATFORM_SEC_CAPS=""
sewardj86e992f2006-01-28 18:39:09 +0000412 elif test x$vg_cv_only32bit = xyes; then
njn7fd6d382009-01-22 21:56:32 +0000413 VGCONF_ARCH_PRI="ppc32"
414 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
415 VGCONF_PLATFORM_SEC_CAPS=""
416 VGCONF_ARCH_PRI="ppc32"
sewardj86e992f2006-01-28 18:39:09 +0000417 else
njn7fd6d382009-01-22 21:56:32 +0000418 VGCONF_ARCH_PRI="ppc64"
419 VGCONF_PLATFORM_PRI_CAPS="PPC64_LINUX"
420 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
sewardj86e992f2006-01-28 18:39:09 +0000421 fi
njnd74b0ef2009-01-20 06:06:52 +0000422 valt_load_address_normal="0x38000000"
423 valt_load_address_inner="0x28000000"
sewardj01262142006-01-04 01:20:28 +0000424 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
425 ;;
nethercote888ecb72004-08-23 14:54:40 +0000426 *)
njn7fd6d382009-01-22 21:56:32 +0000427 VGCONF_ARCH_PRI="unknown"
428 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
429 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
nethercote888ecb72004-08-23 14:54:40 +0000430 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
sewardj3e38ce02004-11-23 01:17:29 +0000431 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
nethercote888ecb72004-08-23 14:54:40 +0000432 ;;
433esac
sewardjde4a1d02002-03-22 01:27:54 +0000434
njn7fd6d382009-01-22 21:56:32 +0000435#----------------------------------------------------------------------------
njna454ec02009-01-19 03:16:59 +0000436
njn7fd6d382009-01-22 21:56:32 +0000437# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
438# defined.
439AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
440 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
441 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX )
442AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
443 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX )
444AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
445 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
446 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
447 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
448 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5 )
449AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
450 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
451 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 )
sewardj03d86f22006-10-17 00:57:24 +0000452
njn7fd6d382009-01-22 21:56:32 +0000453# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
454# become defined.
455AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
456 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
457 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
458AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
459 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
460AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
461 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
462 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
463AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX,
464 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
465AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5,
466 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
467 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5)
468AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5,
469 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5)
470
471# Similarly, set up VGCONF_OF_IS_<os>. Exactly one of these becomes defined.
sewardj03d86f22006-10-17 00:57:24 +0000472# Relies on the assumption that the primary and secondary targets are
473# for the same OS, so therefore only necessary to test the primary.
njn7fd6d382009-01-22 21:56:32 +0000474AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
475 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
476 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
477 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
478 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX)
479AM_CONDITIONAL(VGCONF_OS_IS_AIX5,
480 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
481 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5)
sewardj03d86f22006-10-17 00:57:24 +0000482
483
njn7fd6d382009-01-22 21:56:32 +0000484# Sometimes, in the Makefile.am files, it's useful to know whether or not
485# there is a secondary target.
486AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC_CAPS,
487 test x$VGCONF_PLATFORM_SEC_CAPS != x)
tomfb7bcde2005-11-07 15:24:38 +0000488
tomb637bad2005-11-08 12:28:35 +0000489
njn7fd6d382009-01-22 21:56:32 +0000490#----------------------------------------------------------------------------
491# Inner Valgrind?
492#----------------------------------------------------------------------------
493
njnd74b0ef2009-01-20 06:06:52 +0000494# Check if this should be built as an inner Valgrind, to be run within
495# another Valgrind. Choose the load address accordingly.
496AC_SUBST(VALT_LOAD_ADDRESS)
497AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
498 [AC_ARG_ENABLE(inner,
499 [ --enable-inner enables self-hosting],
500 [vg_cv_inner=$enableval],
501 [vg_cv_inner=no])])
502if test "$vg_cv_inner" = yes; then
503 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
504 VALT_LOAD_ADDRESS=$valt_load_address_inner
505else
506 VALT_LOAD_ADDRESS=$valt_load_address_normal
507fi
508
509
njn7fd6d382009-01-22 21:56:32 +0000510#----------------------------------------------------------------------------
511# Libc and suppressions
512#----------------------------------------------------------------------------
513# This variable will collect the suppression files to be used.
514DEFAULT_SUPP=""
515AC_SUBST(DEFAULT_SUPP)
sewardj01262142006-01-04 01:20:28 +0000516
dirk07596a22008-04-25 11:33:30 +0000517GLIBC_VERSION=""
sewardjde4a1d02002-03-22 01:27:54 +0000518
sewardjde4a1d02002-03-22 01:27:54 +0000519AC_EGREP_CPP([GLIBC_22], [
520#include <features.h>
521#ifdef __GNU_LIBRARY__
522 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
523 GLIBC_22
524 #endif
525#endif
526],
dirk07596a22008-04-25 11:33:30 +0000527GLIBC_VERSION="2.2")
sewardjde4a1d02002-03-22 01:27:54 +0000528
sewardj08c7f012002-10-07 23:56:55 +0000529AC_EGREP_CPP([GLIBC_23], [
530#include <features.h>
531#ifdef __GNU_LIBRARY__
532 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
533 GLIBC_23
534 #endif
535#endif
536],
dirk07596a22008-04-25 11:33:30 +0000537GLIBC_VERSION="2.3")
sewardj08c7f012002-10-07 23:56:55 +0000538
njn781dba52005-06-30 04:06:38 +0000539AC_EGREP_CPP([GLIBC_24], [
540#include <features.h>
541#ifdef __GNU_LIBRARY__
542 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 4)
543 GLIBC_24
544 #endif
545#endif
546],
dirk07596a22008-04-25 11:33:30 +0000547GLIBC_VERSION="2.4")
njn781dba52005-06-30 04:06:38 +0000548
dirkaece45c2006-10-12 08:17:49 +0000549AC_EGREP_CPP([GLIBC_25], [
550#include <features.h>
551#ifdef __GNU_LIBRARY__
552 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 5)
553 GLIBC_25
554 #endif
555#endif
556],
dirk07596a22008-04-25 11:33:30 +0000557GLIBC_VERSION="2.5")
dirkaece45c2006-10-12 08:17:49 +0000558
dirkc8bd0c52007-05-23 17:39:08 +0000559AC_EGREP_CPP([GLIBC_26], [
560#include <features.h>
561#ifdef __GNU_LIBRARY__
562 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 6)
563 GLIBC_26
564 #endif
565#endif
566],
dirk07596a22008-04-25 11:33:30 +0000567GLIBC_VERSION="2.6")
dirkc8bd0c52007-05-23 17:39:08 +0000568
sewardj68c80c12007-11-18 14:40:02 +0000569AC_EGREP_CPP([GLIBC_27], [
570#include <features.h>
571#ifdef __GNU_LIBRARY__
572 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 7)
573 GLIBC_27
574 #endif
575#endif
576],
dirk07596a22008-04-25 11:33:30 +0000577GLIBC_VERSION="2.7")
578
579AC_EGREP_CPP([GLIBC_28], [
580#include <features.h>
581#ifdef __GNU_LIBRARY__
582 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 8)
583 GLIBC_28
584 #endif
585#endif
586],
587GLIBC_VERSION="2.8")
sewardj68c80c12007-11-18 14:40:02 +0000588
dirkd2e31eb2008-11-19 23:58:36 +0000589AC_EGREP_CPP([GLIBC_29], [
590#include <features.h>
591#ifdef __GNU_LIBRARY__
592 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 9)
593 GLIBC_29
594 #endif
595#endif
596],
597GLIBC_VERSION="2.9")
598
sewardj5d425e82009-02-01 19:01:11 +0000599AC_EGREP_CPP([GLIBC_210], [
600#include <features.h>
601#ifdef __GNU_LIBRARY__
602 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 10)
603 GLIBC_210
604 #endif
605#endif
606],
607GLIBC_VERSION="2.10")
608
sewardj03d86f22006-10-17 00:57:24 +0000609AC_EGREP_CPP([AIX5_LIBC], [
610#include <standards.h>
611#if defined(_AIXVERSION_510) || defined(_AIXVERSION_520) || defined(_AIXVERSION_530)
612 AIX5_LIBC
613#endif
614],
dirk07596a22008-04-25 11:33:30 +0000615GLIBC_VERSION="aix5")
daywalkere9212b32003-06-15 22:39:15 +0000616
dirk07596a22008-04-25 11:33:30 +0000617AC_MSG_CHECKING([the GLIBC_VERSION version])
sewardj03d86f22006-10-17 00:57:24 +0000618
dirk07596a22008-04-25 11:33:30 +0000619case "${GLIBC_VERSION}" in
sewardjde4a1d02002-03-22 01:27:54 +0000620 2.2)
621 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000622 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000623 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
624 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000625 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardjde4a1d02002-03-22 01:27:54 +0000626 ;;
627
sewardj08c7f012002-10-07 23:56:55 +0000628 2.3)
629 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000630 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000631 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000632 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000633 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj08c7f012002-10-07 23:56:55 +0000634 ;;
635
njn781dba52005-06-30 04:06:38 +0000636 2.4)
637 AC_MSG_RESULT(2.4 family)
638 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000639 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000640 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000641 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
njn781dba52005-06-30 04:06:38 +0000642 ;;
643
dirkaece45c2006-10-12 08:17:49 +0000644 2.5)
645 AC_MSG_RESULT(2.5 family)
646 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000647 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000648 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000649 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkaece45c2006-10-12 08:17:49 +0000650 ;;
dirkc8bd0c52007-05-23 17:39:08 +0000651 2.6)
652 AC_MSG_RESULT(2.6 family)
653 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
sewardj2c4f3dd2007-11-11 06:13:01 +0000654 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000655 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000656 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000657 ;;
658 2.7)
659 AC_MSG_RESULT(2.7 family)
660 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
dirk07596a22008-04-25 11:33:30 +0000661 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
sewardj68c80c12007-11-18 14:40:02 +0000662 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
tom0a0fcee2008-01-05 00:12:45 +0000663 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
dirkc8bd0c52007-05-23 17:39:08 +0000664 ;;
dirk07596a22008-04-25 11:33:30 +0000665 2.8)
666 AC_MSG_RESULT(2.8 family)
dirkeb939fc2008-04-27 20:38:47 +0000667 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
dirk07596a22008-04-25 11:33:30 +0000668 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
669 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
670 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
671 ;;
dirkd2e31eb2008-11-19 23:58:36 +0000672 2.9)
673 AC_MSG_RESULT(2.9 family)
674 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
675 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
676 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
677 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
678 ;;
sewardj5d425e82009-02-01 19:01:11 +0000679 2.10)
680 AC_MSG_RESULT(2.10 family)
681 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
682 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
683 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
684 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
685 ;;
sewardj03d86f22006-10-17 00:57:24 +0000686 aix5)
sewardj2f3bcd22006-12-12 01:38:15 +0000687 AC_MSG_RESULT(AIX 5.1 or 5.2 or 5.3)
688 AC_DEFINE([AIX5_LIBC], 1, [Define to 1 if you're using AIX 5.1 or 5.2 or 5.3])
sewardj03d86f22006-10-17 00:57:24 +0000689 DEFAULT_SUPP="aix5libc.supp ${DEFAULT_SUPP}"
690 ;;
dirkaece45c2006-10-12 08:17:49 +0000691
sewardjde4a1d02002-03-22 01:27:54 +0000692 *)
693 AC_MSG_RESULT(unsupported version)
sewardj5d425e82009-02-01 19:01:11 +0000694 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.10])
dirk07596a22008-04-25 11:33:30 +0000695 AC_MSG_ERROR([or AIX 5.1 or 5.2 or 5.3 GLIBC_VERSION])
sewardjde4a1d02002-03-22 01:27:54 +0000696 ;;
697esac
698
dirk07596a22008-04-25 11:33:30 +0000699AC_SUBST(GLIBC_VERSION)
sewardj535c50f2005-06-04 23:14:53 +0000700
sewardj414f3582008-07-18 20:46:00 +0000701
702# Add default suppressions for the X client libraries. Make no
703# attempt to detect whether such libraries are installed on the
704# build machine (or even if any X facilities are present); just
705# add the suppressions antidisirregardless.
706DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
707DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
gobrye721a522002-03-22 13:38:30 +0000708
sewardj5744c022008-10-19 18:58:13 +0000709# Add glibc and X11 suppressions for exp-ptrcheck
710DEFAULT_SUPP="exp-ptrcheck.supp ${DEFAULT_SUPP}"
711
sewardj2e10a682003-04-07 19:36:41 +0000712
njn7fd6d382009-01-22 21:56:32 +0000713#----------------------------------------------------------------------------
714# Checking for various library functions and other definitions
715#----------------------------------------------------------------------------
716
bart59e2f182008-04-28 16:22:53 +0000717# Check for CLOCK_MONOTONIC
718
719AC_MSG_CHECKING([for CLOCK_MONOTONIC])
720
721AC_TRY_COMPILE(
722[
723#include <time.h>
724], [
725 struct timespec t;
726 clock_gettime(CLOCK_MONOTONIC, &t);
727 return 0;
728],
729[
730AC_MSG_RESULT([yes])
731AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
732 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
733], [
734AC_MSG_RESULT([no])
735])
736
bartfea06922008-05-03 09:12:15 +0000737
738# Check for PTHREAD_MUTEX_ADAPTIVE_NP
739
740AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
741
742AC_TRY_COMPILE(
743[
744#define _GNU_SOURCE
745#include <pthread.h>
746], [
747 return (PTHREAD_MUTEX_ADAPTIVE_NP);
748],
749[
750AC_MSG_RESULT([yes])
751AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
752 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
753], [
754AC_MSG_RESULT([no])
755])
756
757
758# Check for PTHREAD_MUTEX_ERRORCHECK_NP
759
760AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
761
762AC_TRY_COMPILE(
763[
764#define _GNU_SOURCE
765#include <pthread.h>
766], [
767 return (PTHREAD_MUTEX_ERRORCHECK_NP);
768],
769[
770AC_MSG_RESULT([yes])
771AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
772 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
773], [
774AC_MSG_RESULT([no])
775])
776
777
778# Check for PTHREAD_MUTEX_RECURSIVE_NP
779
780AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
781
782AC_TRY_COMPILE(
783[
784#define _GNU_SOURCE
785#include <pthread.h>
786], [
787 return (PTHREAD_MUTEX_RECURSIVE_NP);
788],
789[
790AC_MSG_RESULT([yes])
791AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
792 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
793], [
794AC_MSG_RESULT([no])
795])
796
797
798# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
799
800AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
801
802AC_TRY_COMPILE(
803[
804#define _GNU_SOURCE
805#include <pthread.h>
806], [
807 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
808 return 0;
809],
810[
811AC_MSG_RESULT([yes])
812AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
813 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
814], [
815AC_MSG_RESULT([no])
816])
817
818
bart5e389f12008-04-05 12:53:15 +0000819# Check whether pthread_mutex_t has a member called __m_kind.
820
821AC_MSG_CHECKING([for pthread_mutex_t::__m_kind])
822
bart56730cd2008-05-11 06:41:46 +0000823AC_TRY_COMPILE(
bart5e389f12008-04-05 12:53:15 +0000824[
bart56730cd2008-05-11 06:41:46 +0000825 #include <pthread.h>
826], [
bart5e389f12008-04-05 12:53:15 +0000827 pthread_mutex_t m;
828 return m.__m_kind;
bart56730cd2008-05-11 06:41:46 +0000829], [
bart5e389f12008-04-05 12:53:15 +0000830AC_MSG_RESULT([yes])
831AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND], 1,
832 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
833], [
834AC_MSG_RESULT([no])
835])
836
837
838# Check whether pthread_mutex_t has a member called __data.__kind.
839
840AC_MSG_CHECKING([for pthread_mutex_t::__data.__kind])
841
bart56730cd2008-05-11 06:41:46 +0000842AC_TRY_COMPILE(
bart5e389f12008-04-05 12:53:15 +0000843[
bart56730cd2008-05-11 06:41:46 +0000844#include <pthread.h>
845], [
bart5e389f12008-04-05 12:53:15 +0000846 pthread_mutex_t m;
847 return m.__data.__kind;
bart56730cd2008-05-11 06:41:46 +0000848], [
bart5e389f12008-04-05 12:53:15 +0000849AC_MSG_RESULT([yes])
850AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND], 1,
851 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
852], [
853AC_MSG_RESULT([no])
854])
855
856
bart62c370e2008-05-12 18:50:51 +0000857# does this compiler support -maltivec and does it have the include file
858# <altivec.h> ?
859
860AC_MSG_CHECKING([for Altivec])
861
862safe_CFLAGS=$CFLAGS
863CFLAGS="-maltivec"
864
865AC_TRY_COMPILE(
866[
867#include <altivec.h>
868], [
869 vector unsigned int v;
870],
871[
872ac_have_altivec=yes
873AC_MSG_RESULT([yes])
874], [
875ac_have_altivec=no
876AC_MSG_RESULT([no])
877])
878CFLAGS=$safe_CFLAGS
879
880AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
881AM_CONDITIONAL([HAVE_ALTIVEC_H], [test x$ac_have_altivec = xyes])
882
883
barta50aa8a2008-04-27 06:06:57 +0000884# Check for eventfd_t, eventfd() and eventfd_read()
885AC_MSG_CHECKING([for eventfd()])
886
887AC_TRY_LINK(
888[
889#include <sys/eventfd.h>
890], [
891 eventfd_t ev;
892 int fd;
893
894 fd = eventfd(5, 0);
895 eventfd_read(fd, &ev);
896 return 0;
897],
898[
899AC_MSG_RESULT([yes])
900AC_DEFINE([HAVE_EVENTFD], 1,
901 [Define to 1 if you have the `eventfd' function.])
902AC_DEFINE([HAVE_EVENTFD_READ], 1,
903 [Define to 1 if you have the `eventfd_read' function.])
904], [
905AC_MSG_RESULT([no])
906])
907
908
njn7fd6d382009-01-22 21:56:32 +0000909#----------------------------------------------------------------------------
910# Checking for supported compiler flags.
911#----------------------------------------------------------------------------
912
sewardj535c50f2005-06-04 23:14:53 +0000913# does this compiler support -m32 ?
914AC_MSG_CHECKING([if gcc accepts -m32])
915
916safe_CFLAGS=$CFLAGS
917CFLAGS="-m32"
918
919AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +0000920 return 0;
sewardj535c50f2005-06-04 23:14:53 +0000921],
922[
923FLAG_M32="-m32"
924AC_MSG_RESULT([yes])
925], [
926FLAG_M32=""
927AC_MSG_RESULT([no])
928])
929CFLAGS=$safe_CFLAGS
930
931AC_SUBST(FLAG_M32)
932
933
sewardj03d86f22006-10-17 00:57:24 +0000934# does this compiler support -maix32 ?
935AC_MSG_CHECKING([if gcc accepts -maix32])
936
937safe_CFLAGS=$CFLAGS
938CFLAGS="-maix32"
939
940AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +0000941 return 0;
sewardj03d86f22006-10-17 00:57:24 +0000942],
943[
944FLAG_MAIX32="-maix32"
945AC_MSG_RESULT([yes])
946], [
947FLAG_MAIX32=""
948AC_MSG_RESULT([no])
949])
950CFLAGS=$safe_CFLAGS
951
952AC_SUBST(FLAG_MAIX32)
953
954
sewardj01262142006-01-04 01:20:28 +0000955# does this compiler support -m64 ?
956AC_MSG_CHECKING([if gcc accepts -m64])
957
958safe_CFLAGS=$CFLAGS
959CFLAGS="-m64"
960
961AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +0000962 return 0;
sewardj01262142006-01-04 01:20:28 +0000963],
964[
965FLAG_M64="-m64"
966AC_MSG_RESULT([yes])
967], [
968FLAG_M64=""
969AC_MSG_RESULT([no])
970])
971CFLAGS=$safe_CFLAGS
972
973AC_SUBST(FLAG_M64)
974
975
sewardj03d86f22006-10-17 00:57:24 +0000976# does this compiler support -maix64 ?
977AC_MSG_CHECKING([if gcc accepts -maix64])
978
979safe_CFLAGS=$CFLAGS
980CFLAGS="-maix64"
981
982AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +0000983 return 0;
sewardj03d86f22006-10-17 00:57:24 +0000984],
985[
986FLAG_MAIX64="-maix64"
987AC_MSG_RESULT([yes])
988], [
989FLAG_MAIX64=""
990AC_MSG_RESULT([no])
991])
992CFLAGS=$safe_CFLAGS
993
994AC_SUBST(FLAG_MAIX64)
995
996
sewardj67f1fcc2005-07-03 10:41:02 +0000997# does this compiler support -mmmx ?
998AC_MSG_CHECKING([if gcc accepts -mmmx])
999
1000safe_CFLAGS=$CFLAGS
1001CFLAGS="-mmmx"
1002
1003AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001004 return 0;
sewardj67f1fcc2005-07-03 10:41:02 +00001005],
1006[
1007FLAG_MMMX="-mmmx"
1008AC_MSG_RESULT([yes])
1009], [
1010FLAG_MMMX=""
1011AC_MSG_RESULT([no])
1012])
1013CFLAGS=$safe_CFLAGS
1014
1015AC_SUBST(FLAG_MMMX)
1016
1017
1018# does this compiler support -msse ?
1019AC_MSG_CHECKING([if gcc accepts -msse])
1020
1021safe_CFLAGS=$CFLAGS
1022CFLAGS="-msse"
1023
1024AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001025 return 0;
sewardj67f1fcc2005-07-03 10:41:02 +00001026],
1027[
1028FLAG_MSSE="-msse"
1029AC_MSG_RESULT([yes])
1030], [
1031FLAG_MSSE=""
1032AC_MSG_RESULT([no])
1033])
1034CFLAGS=$safe_CFLAGS
1035
1036AC_SUBST(FLAG_MSSE)
1037
1038
sewardj5b754b42002-06-03 22:53:35 +00001039# does this compiler support -mpreferred-stack-boundary=2 ?
1040AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
1041
daywalker3664f562003-10-17 13:43:46 +00001042safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001043CFLAGS="-mpreferred-stack-boundary=2"
1044
1045AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001046 return 0;
sewardj5b754b42002-06-03 22:53:35 +00001047],
1048[
1049PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +00001050AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +00001051], [
1052PREFERRED_STACK_BOUNDARY=""
1053AC_MSG_RESULT([no])
1054])
daywalker3664f562003-10-17 13:43:46 +00001055CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +00001056
1057AC_SUBST(PREFERRED_STACK_BOUNDARY)
1058
sewardj535c50f2005-06-04 23:14:53 +00001059
sewardjb5f6f512005-03-10 23:59:00 +00001060# does this compiler support -Wno-pointer-sign ?
bart56730cd2008-05-11 06:41:46 +00001061AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign])
sewardjb5f6f512005-03-10 23:59:00 +00001062
1063safe_CFLAGS=$CFLAGS
1064CFLAGS="-Wno-pointer-sign"
1065
1066AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001067 return 0;
sewardjb5f6f512005-03-10 23:59:00 +00001068],
1069[
1070no_pointer_sign=yes
1071AC_MSG_RESULT([yes])
1072], [
1073no_pointer_sign=no
1074AC_MSG_RESULT([no])
1075])
1076CFLAGS=$safe_CFLAGS
1077
1078if test x$no_pointer_sign = xyes; then
1079 CFLAGS="$CFLAGS -Wno-pointer-sign"
1080fi
1081
sewardj535c50f2005-06-04 23:14:53 +00001082
tom1e946682005-10-12 11:27:33 +00001083# does this compiler support -Wdeclaration-after-statement ?
bart56730cd2008-05-11 06:41:46 +00001084AC_MSG_CHECKING([if gcc accepts -Wdeclaration-after-statement])
tom1e946682005-10-12 11:27:33 +00001085
1086safe_CFLAGS=$CFLAGS
1087CFLAGS="-Wdeclaration-after-statement"
1088
1089AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001090 return 0;
tom1e946682005-10-12 11:27:33 +00001091],
1092[
tome9814c32005-10-12 11:30:43 +00001093declaration_after_statement=yes
sewardj72a547e2006-01-25 02:58:28 +00001094FLAG_WDECL_AFTER_STMT="-Wdeclaration-after-statement"
tom1e946682005-10-12 11:27:33 +00001095AC_MSG_RESULT([yes])
1096], [
tome9814c32005-10-12 11:30:43 +00001097declaration_after_statement=no
sewardj72a547e2006-01-25 02:58:28 +00001098FLAG_WDECL_AFTER_STMT=""
tom1e946682005-10-12 11:27:33 +00001099AC_MSG_RESULT([no])
1100])
1101CFLAGS=$safe_CFLAGS
1102
sewardj72a547e2006-01-25 02:58:28 +00001103AC_SUBST(FLAG_WDECL_AFTER_STMT)
1104
tome9814c32005-10-12 11:30:43 +00001105if test x$declaration_after_statement = xyes; then
tom1e946682005-10-12 11:27:33 +00001106 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1107fi
1108
sewardj00f1e622006-03-12 16:47:10 +00001109
bart9d865fa2008-06-23 12:11:49 +00001110# does this compiler support -Wno-format-zero-length ?
1111
1112AC_MSG_CHECKING([if gcc accepts -Wno-format-zero-length])
1113
1114safe_CFLAGS=$CFLAGS
1115CFLAGS="-Wno-format-zero-length"
1116
1117AC_TRY_COMPILE(
1118[ ],
1119[
1120 return 0;
1121],
1122[
1123AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [-Wno-format-zero-length])
1124AC_MSG_RESULT([yes])
1125],
1126[
1127AC_SUBST([FLAG_W_NO_FORMAT_ZERO_LENGTH], [])
1128AC_MSG_RESULT([no])
1129])
1130CFLAGS=$safe_CFLAGS
1131
1132
bart56730cd2008-05-11 06:41:46 +00001133# does this compiler support -Wextra or the older -W ?
1134
1135AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1136
1137safe_CFLAGS=$CFLAGS
1138CFLAGS="-Wextra"
1139
1140AC_TRY_COMPILE(
1141[ ],
1142[
1143 return 0;
1144],
1145[
1146AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1147AC_MSG_RESULT([-Wextra])
1148], [
1149 CFLAGS="-W"
1150 AC_TRY_COMPILE(
1151 [ ],
1152 [
1153 return 0;
1154 ],
1155 [
1156 AC_SUBST([FLAG_W_EXTRA], [-W])
1157 AC_MSG_RESULT([-W])
1158 ], [
1159 AC_SUBST([FLAG_W_EXTRA], [])
1160 AC_MSG_RESULT([not supported])
1161 ])
1162])
1163CFLAGS=$safe_CFLAGS
1164
1165
sewardja72c26d2007-05-01 13:44:08 +00001166# does this compiler support -fno-stack-protector ?
bart56730cd2008-05-11 06:41:46 +00001167AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
sewardja72c26d2007-05-01 13:44:08 +00001168
1169safe_CFLAGS=$CFLAGS
1170CFLAGS="-fno-stack-protector"
1171
1172AC_TRY_COMPILE(, [
njn9890ee12009-01-21 22:25:50 +00001173 return 0;
sewardja72c26d2007-05-01 13:44:08 +00001174],
1175[
1176no_stack_protector=yes
1177FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1178AC_MSG_RESULT([yes])
1179], [
1180no_stack_protector=no
1181FLAG_FNO_STACK_PROTECTOR=""
1182AC_MSG_RESULT([no])
1183])
1184CFLAGS=$safe_CFLAGS
1185
1186AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1187
1188if test x$no_stack_protector = xyes; then
1189 CFLAGS="$CFLAGS -fno-stack-protector"
1190fi
1191
1192
bart56730cd2008-05-11 06:41:46 +00001193# does this compiler support --param inline-unit-growth=... ?
1194
1195AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1196
1197safe_CFLAGS=$CFLAGS
1198CFLAGS="--param inline-unit-growth=900"
1199
1200AC_TRY_COMPILE(
1201[ ],
1202[
1203 return 0;
1204],
1205[
1206AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1207 ["--param inline-unit-growth=900"])
1208AC_MSG_RESULT([yes])
1209], [
1210AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1211AC_MSG_RESULT([no])
1212])
1213CFLAGS=$safe_CFLAGS
1214
1215
tomd55121e2005-12-19 12:40:13 +00001216# does this compiler support __builtin_expect?
1217AC_MSG_CHECKING([if gcc supports __builtin_expect])
bart56730cd2008-05-11 06:41:46 +00001218
tomd55121e2005-12-19 12:40:13 +00001219AC_TRY_LINK(, [
1220return __builtin_expect(1, 1) ? 1 : 0
1221],
1222[
1223ac_have_builtin_expect=yes
1224AC_MSG_RESULT([yes])
1225], [
1226ac_have_builtin_expect=no
1227AC_MSG_RESULT([no])
1228])
1229if test x$ac_have_builtin_expect = xyes ; then
1230 AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if gcc supports __builtin_expect.])
1231fi
1232
tom1e946682005-10-12 11:27:33 +00001233
sewardj00f1e622006-03-12 16:47:10 +00001234# does the ppc assembler support "mtocrf" et al?
1235AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1236
1237AC_TRY_COMPILE(, [
sewardjdd4cbe12006-03-12 17:27:44 +00001238__asm__ __volatile__("mtocrf 4,0");
1239__asm__ __volatile__("mfocrf 0,4");
sewardj00f1e622006-03-12 16:47:10 +00001240],
1241[
1242ac_have_as_ppc_mftocrf=yes
1243AC_MSG_RESULT([yes])
1244], [
1245ac_have_as_ppc_mftocrf=no
1246AC_MSG_RESULT([no])
1247])
1248if test x$ac_have_as_ppc_mftocrf = xyes ; then
1249 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1250fi
1251
1252
sewardjf0aabf82007-03-22 00:24:21 +00001253# does the x86/amd64 assembler understand SSE3 instructions?
sewardjfa18a262007-03-22 12:13:13 +00001254# Note, this doesn't generate a C-level symbol. It generates a
1255# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
sewardjf0aabf82007-03-22 00:24:21 +00001256AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1257
1258AC_TRY_COMPILE(, [
1259 do { long long int x;
1260 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1261 while (0)
1262],
1263[
1264ac_have_as_sse3=yes
1265AC_MSG_RESULT([yes])
1266], [
1267ac_have_as_sse3=no
1268AC_MSG_RESULT([no])
1269])
sewardjfa18a262007-03-22 12:13:13 +00001270
1271AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
sewardjf0aabf82007-03-22 00:24:21 +00001272
1273
sewardj6d6da5b2008-02-09 12:07:40 +00001274# Ditto for SSSE3 instructions (note extra S)
1275# Note, this doesn't generate a C-level symbol. It generates a
1276# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1277AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1278
1279AC_TRY_COMPILE(, [
1280 do { long long int x;
1281 __asm__ __volatile__(
1282 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1283 while (0)
1284],
1285[
1286ac_have_as_ssse3=yes
1287AC_MSG_RESULT([yes])
1288], [
1289ac_have_as_ssse3=no
1290AC_MSG_RESULT([no])
1291])
1292
1293AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1294
1295
sewardjb5f6f512005-03-10 23:59:00 +00001296# Check for TLS support in the compiler and linker
bartca9f2ad2008-06-02 07:14:20 +00001297if test "x${cross_compiling}" = "xno"; then
1298# Native compilation: check whether running a program using TLS succeeds.
1299# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
1300# succeeds but running programs using TLS fails.
1301AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1302 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1303 [vg_cv_tls=$enableval],
1304 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
1305 [[return foo;]])],
1306 [vg_cv_tls=yes],
1307 [vg_cv_tls=no])])])
1308else
1309# Cross-compiling: check whether linking a program using TLS succeeds.
sewardjb5f6f512005-03-10 23:59:00 +00001310AC_CACHE_CHECK([for TLS support], vg_cv_tls,
1311 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
1312 [vg_cv_tls=$enableval],
bartcddeaf52008-05-25 15:58:11 +00001313 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
sewardjb5f6f512005-03-10 23:59:00 +00001314 [[return foo;]])],
1315 [vg_cv_tls=yes],
1316 [vg_cv_tls=no])])])
bartca9f2ad2008-06-02 07:14:20 +00001317fi
sewardjb5f6f512005-03-10 23:59:00 +00001318
1319if test "$vg_cv_tls" = yes; then
1320AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
1321fi
sewardj5b754b42002-06-03 22:53:35 +00001322
sewardj535c50f2005-06-04 23:14:53 +00001323
njn7fd6d382009-01-22 21:56:32 +00001324#----------------------------------------------------------------------------
bart62f54e42008-07-28 11:35:10 +00001325# Checks for C header files.
njn7fd6d382009-01-22 21:56:32 +00001326#----------------------------------------------------------------------------
1327
sewardjde4a1d02002-03-22 01:27:54 +00001328AC_HEADER_STDC
bartf5ceec82008-04-26 07:45:10 +00001329AC_CHECK_HEADERS([ \
bart1f2b1432009-01-16 12:06:54 +00001330 asm/unistd.h \
bartf5ceec82008-04-26 07:45:10 +00001331 endian.h \
1332 mqueue.h \
1333 sys/endian.h \
1334 sys/epoll.h \
1335 sys/eventfd.h \
bartce48fa92008-04-26 10:59:46 +00001336 sys/klog.h \
bartf5ceec82008-04-26 07:45:10 +00001337 sys/poll.h \
bart71bad292008-04-27 11:43:23 +00001338 sys/signal.h \
bartf5ceec82008-04-26 07:45:10 +00001339 sys/signalfd.h \
bart71bad292008-04-27 11:43:23 +00001340 sys/syscall.h \
1341 sys/time.h \
1342 sys/types.h \
bartf5ceec82008-04-26 07:45:10 +00001343 ])
sewardjde4a1d02002-03-22 01:27:54 +00001344
njn7fd6d382009-01-22 21:56:32 +00001345#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001346# Checks for typedefs, structures, and compiler characteristics.
njn7fd6d382009-01-22 21:56:32 +00001347#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001348AC_TYPE_UID_T
1349AC_TYPE_OFF_T
1350AC_TYPE_SIZE_T
1351AC_HEADER_TIME
1352
sewardj535c50f2005-06-04 23:14:53 +00001353
njn7fd6d382009-01-22 21:56:32 +00001354#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001355# Checks for library functions.
njn7fd6d382009-01-22 21:56:32 +00001356#----------------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +00001357AC_FUNC_MEMCMP
1358AC_FUNC_MMAP
1359AC_TYPE_SIGNAL
1360
bart71bad292008-04-27 11:43:23 +00001361AC_CHECK_LIB([rt], [clock_gettime])
bart41ac62a2008-07-07 16:58:03 +00001362
bartf5ceec82008-04-26 07:45:10 +00001363AC_CHECK_FUNCS([ \
bart71bad292008-04-27 11:43:23 +00001364 clock_gettime\
bartf5ceec82008-04-26 07:45:10 +00001365 epoll_create \
1366 epoll_pwait \
bartf5ceec82008-04-26 07:45:10 +00001367 floor \
bartce48fa92008-04-26 10:59:46 +00001368 klogctl \
bartf5ceec82008-04-26 07:45:10 +00001369 mallinfo \
1370 memchr \
1371 memset \
1372 mkdir \
1373 ppoll \
bart6d45e922009-01-20 13:45:38 +00001374 pthread_barrier_init \
1375 pthread_condattr_setclock \
1376 pthread_mutex_timedlock \
1377 pthread_rwlock_timedrdlock \
1378 pthread_rwlock_timedwrlock \
1379 pthread_spin_lock \
bartf5ceec82008-04-26 07:45:10 +00001380 semtimedop \
1381 signalfd \
bart71bad292008-04-27 11:43:23 +00001382 syscall \
bartf5ceec82008-04-26 07:45:10 +00001383 strchr \
1384 strdup \
1385 strpbrk \
1386 strrchr \
1387 strstr \
1388 timerfd \
1389 utimensat \
1390 ])
sewardjde4a1d02002-03-22 01:27:54 +00001391
bart623eec32008-07-29 17:54:49 +00001392# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
1393# libraries with any shared object and/or executable. This is NOT what we
1394# want for e.g. vgpreload_core-x86-linux.so
1395LIBS=""
sewardj80637752006-03-02 13:48:21 +00001396
bart6d45e922009-01-20 13:45:38 +00001397AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
1398 [test x$ac_cv_func_pthread_barrier_init = xyes])
bart2eaa8f22009-01-20 14:01:16 +00001399AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
1400 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
bart6d45e922009-01-20 13:45:38 +00001401AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
1402 [test x$ac_cv_func_pthread_spin_lock = xyes])
1403
njn7fd6d382009-01-22 21:56:32 +00001404
1405#----------------------------------------------------------------------------
1406# MPI checks
1407#----------------------------------------------------------------------------
sewardj03d86f22006-10-17 00:57:24 +00001408# Do we have a useable MPI setup on the primary and/or secondary targets?
1409# On Linux, by default, assumes mpicc and -m32/-m64
1410# On AIX, by default, assumes mpxlc and -q32/-q64
sewardje9fa5062006-03-12 18:29:18 +00001411# Note: this is a kludge in that it assumes the specified mpicc
sewardj03d86f22006-10-17 00:57:24 +00001412# understands -m32/-m64/-q32/-q64 regardless of what is specified using
1413# --with-mpicc=.
sewardj0ad46092006-03-02 17:09:16 +00001414MPI_CC="mpicc"
njn7fd6d382009-01-22 21:56:32 +00001415if test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 \
1416 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 ; then
sewardj03d86f22006-10-17 00:57:24 +00001417 MPI_CC="mpxlc"
1418fi
1419
sewardje9fa5062006-03-12 18:29:18 +00001420mflag_primary=
njn7fd6d382009-01-22 21:56:32 +00001421if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1422 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001423 mflag_primary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001424elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1425 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX ; then
sewardje9fa5062006-03-12 18:29:18 +00001426 mflag_primary=$FLAG_M64
njn7fd6d382009-01-22 21:56:32 +00001427elif test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_AIX5 ; then
sewardj03d86f22006-10-17 00:57:24 +00001428 mflag_primary=-q32
njn7fd6d382009-01-22 21:56:32 +00001429elif test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_AIX5 ; then
sewardj03d86f22006-10-17 00:57:24 +00001430 mflag_primary=-q64
sewardje9fa5062006-03-12 18:29:18 +00001431fi
1432
sewardj03d86f22006-10-17 00:57:24 +00001433mflag_secondary=
njn7fd6d382009-01-22 21:56:32 +00001434if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1435 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
sewardj03d86f22006-10-17 00:57:24 +00001436 mflag_secondary=$FLAG_M32
njn7fd6d382009-01-22 21:56:32 +00001437elif test x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5 ; then
sewardj03d86f22006-10-17 00:57:24 +00001438 mflag_secondary=-q32
1439fi
1440
1441
sewardj0ad46092006-03-02 17:09:16 +00001442AC_ARG_WITH(mpicc,
sewardjb70a6132006-05-27 21:14:09 +00001443 [ --with-mpicc= Specify name of MPI2-ised C compiler],
sewardj0ad46092006-03-02 17:09:16 +00001444 MPI_CC=$withval
1445)
sewardj03d86f22006-10-17 00:57:24 +00001446AC_SUBST(MPI_CC)
1447
1448## See if MPI_CC works for the primary target
1449##
1450AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
sewardj0ad46092006-03-02 17:09:16 +00001451saved_CC=$CC
sewardjde4f3842006-03-09 02:41:41 +00001452saved_CFLAGS=$CFLAGS
sewardj0ad46092006-03-02 17:09:16 +00001453CC=$MPI_CC
sewardje9fa5062006-03-12 18:29:18 +00001454CFLAGS=$mflag_primary
sewardjd3fcc642006-03-09 02:49:56 +00001455AC_TRY_LINK([
sewardj1a85e602006-03-08 15:26:10 +00001456#include <mpi.h>
1457#include <stdio.h>
sewardjde4f3842006-03-09 02:41:41 +00001458],[
1459 int r = MPI_Init(NULL,NULL);
1460 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1461 return r;
1462], [
sewardj03d86f22006-10-17 00:57:24 +00001463ac_have_mpi2_pri=yes
sewardj1a85e602006-03-08 15:26:10 +00001464AC_MSG_RESULT([yes, $MPI_CC])
sewardj80637752006-03-02 13:48:21 +00001465], [
sewardj03d86f22006-10-17 00:57:24 +00001466ac_have_mpi2_pri=no
sewardj80637752006-03-02 13:48:21 +00001467AC_MSG_RESULT([no])
1468])
sewardj0ad46092006-03-02 17:09:16 +00001469CC=$saved_CC
sewardjde4f3842006-03-09 02:41:41 +00001470CFLAGS=$saved_CFLAGS
sewardj03d86f22006-10-17 00:57:24 +00001471AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
sewardj80637752006-03-02 13:48:21 +00001472
sewardj03d86f22006-10-17 00:57:24 +00001473## See if MPI_CC works for the secondary target. Complication: what if
1474## there is no secondary target? We need this to then fail.
1475## Kludge this by making MPI_CC something which will surely fail in
1476## such a case.
1477##
1478AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
1479saved_CC=$CC
1480saved_CFLAGS=$CFLAGS
njn7fd6d382009-01-22 21:56:32 +00001481if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
sewardj03d86f22006-10-17 00:57:24 +00001482 CC="$MPI_CC this will surely fail"
1483else
1484 CC=$MPI_CC
1485fi
1486CFLAGS=$mflag_secondary
1487AC_TRY_LINK([
1488#include <mpi.h>
1489#include <stdio.h>
1490],[
1491 int r = MPI_Init(NULL,NULL);
1492 r |= MPI_Type_get_contents( MPI_INT, 0,0,0, NULL,NULL,NULL );
1493 return r;
1494], [
1495ac_have_mpi2_sec=yes
1496AC_MSG_RESULT([yes, $MPI_CC])
1497], [
1498ac_have_mpi2_sec=no
1499AC_MSG_RESULT([no])
1500])
1501CC=$saved_CC
1502CFLAGS=$saved_CFLAGS
1503AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
sewardj80637752006-03-02 13:48:21 +00001504
1505
njn7fd6d382009-01-22 21:56:32 +00001506#----------------------------------------------------------------------------
1507# Other library checks
1508#----------------------------------------------------------------------------
sewardj493c4ef2008-12-13 16:45:19 +00001509# There now follow some tests for QtCore, Boost, and OpenMP. These
1510# tests are present because Drd has some regression tests that use
1511# these packages. All regression test programs all compiled only
1512# for the primary target. And so it is important that the configure
1513# checks that follow, use the correct -m32 or -m64 flag for the
1514# primary target (called $mflag_primary). Otherwise, we can end up
1515# in a situation (eg) where, on amd64-linux, the test for Boost checks
1516# for usable 64-bit Boost facilities, but because we are doing a 32-bit
1517# only build (meaning, the primary target is x86-linux), the build
1518# of the regtest programs that use Boost fails, because they are
1519# build as 32-bit (IN THIS EXAMPLE).
1520#
1521# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
1522# NEEDED BY THE REGRESSION TEST PROGRAMS.
1523
1524
bart21d3cfc2008-08-02 09:08:17 +00001525# The test below verifies whether the QtCore package been installed.
1526# This test works as follows:
1527# - If pkg-config was not installed at the time autogen.sh was run,
1528# the definition of the PKG_CHECK_EXISTS() macro will not be found by
1529# autogen.sh. Augogen.sh will generate a configure script that prints
1530# a warning about pkg-config and proceeds as if Qt4 has not been installed.
1531# - If pkg-config was installed at the time autogen.sh was run,
1532# the generated configure script will try to detect the presence of the
1533# Qt4 QtCore library by looking up compile and linker flags in the file
1534# called QtCore.pc.
1535# - pkg-config settings can be overridden via the configure variables
1536# QTCORE_CFLAGS and QTCORE_LIBS (added by the pkg-config m4 macro's to the
1537# configure script -- see also ./configure --help).
1538# - The QTCORE_CFLAGS and QTCORE_LIBS configure variables can be used even if
1539# the pkg-config executable is not present on the system on which the
1540# configure script is run.
bart41ac62a2008-07-07 16:58:03 +00001541
bart21d3cfc2008-08-02 09:08:17 +00001542ifdef(
1543 [PKG_CHECK_EXISTS],
1544 [PKG_CHECK_EXISTS(
1545 [QtCore],
1546 [
1547 PKG_CHECK_MODULES([QTCORE], [QtCore])
bart11fbd892008-09-21 15:00:58 +00001548 # Paranoia: don't trust the result reported by pkg-config, but when
1549 # pkg-config reports that QtCore has been found, verify whether linking
1550 # programs with QtCore succeeds.
1551 AC_LANG(C++)
1552 safe_CXXFLAGS="${CXXFLAGS}"
sewardj493c4ef2008-12-13 16:45:19 +00001553 CXXFLAGS="${QTCORE_CFLAGS} ${QTCORE_LIBS} $mflag_primary"
bart11fbd892008-09-21 15:00:58 +00001554 AC_TRY_LINK(
1555 [#include <QMutex>],
1556 [QMutex Mutex;],
1557 [ac_have_qtcore=yes],
1558 [
1559 AC_MSG_WARN([Although pkg-config detected Qt4, linking Qt4 programs fails. Skipping Qt4.])
1560 ac_have_qtcore=no
1561 ]
1562 )
1563 CXXFLAGS="${safe_CXXFLAGS}"
bart21d3cfc2008-08-02 09:08:17 +00001564 ],
1565 [
1566 ac_have_qtcore=no
1567 ]
1568 )
1569 ],
1570 AC_MSG_WARN([pkg-config has not been installed or is too old.])
1571 AC_MSG_WARN([Detection of Qt4 will be skipped.])
1572 [ac_have_qtcore=no]
1573)
bart41ac62a2008-07-07 16:58:03 +00001574
1575AM_CONDITIONAL([HAVE_QTCORE], [test x$ac_have_qtcore = xyes])
1576
1577
bart62f54e42008-07-28 11:35:10 +00001578# Test for QMutex::tryLock(int), which has been introduced in Qt 4.3.
1579# See also http://doc.trolltech.com/4.3/qmutex.html.
1580if test x$ac_have_qtcore = xyes; then
1581 AC_MSG_CHECKING([for Qt4 QMutex::tryLock(int)])
1582 AC_LANG(C++)
bart21d3cfc2008-08-02 09:08:17 +00001583 safe_CXXFLAGS="${CXXFLAGS}"
sewardj493c4ef2008-12-13 16:45:19 +00001584 CXXFLAGS="${QTCORE_CFLAGS} $mflag_primary"
bart62f54e42008-07-28 11:35:10 +00001585 AC_TRY_COMPILE([
1586 #include <QtCore/QMutex>
1587 ],
1588 [
1589 QMutex M;
1590 M.tryLock(1);
1591 M.unlock();
1592 return 0;
1593 ],
1594 [
1595 AC_MSG_RESULT([yes])
1596 AC_DEFINE([HAVE_QTCORE_QMUTEX_TRYLOCK_INT], [1], [Define to 1 if the installed version of Qt4 provides QMutex::tryLock(int).])
1597 ],
1598 [
1599 AC_MSG_RESULT([no])
1600 ])
bart21d3cfc2008-08-02 09:08:17 +00001601 CXXFLAGS="${safe_CXXFLAGS}"
bart62f54e42008-07-28 11:35:10 +00001602 AC_LANG(C)
1603fi
1604
1605
sewardj493c4ef2008-12-13 16:45:19 +00001606# Check whether the boost library 1.35 or later has been installed.
1607# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
1608
1609AC_MSG_CHECKING([for boost])
1610
1611AC_LANG(C++)
1612safe_CXXFLAGS=$CXXFLAGS
1613CXXFLAGS="-lboost_thread-mt $mflag_primary"
1614
1615AC_LINK_IFELSE(
1616[
1617#include <boost/thread.hpp>
1618static void thread_func(void)
1619{ }
1620int main(int argc, char** argv)
1621{
1622 boost::thread t(thread_func);
1623 return 0;
1624}
1625],
1626[
1627ac_have_boost_1_35=yes
1628AC_SUBST([BOOST_CFLAGS], [])
1629AC_SUBST([BOOST_LIBS], ["${CXXFLAGS}"])
1630AC_MSG_RESULT([yes])
1631], [
1632ac_have_boost_1_35=no
1633AC_MSG_RESULT([no])
1634])
1635
1636CXXFLAGS=$safe_CXXFLAGS
1637AC_LANG(C)
1638
1639AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
1640
1641
1642# does this compiler support -fopenmp, does it have the include file
1643# <omp.h> and does it have libgomp ?
1644
1645AC_MSG_CHECKING([for OpenMP])
1646
1647safe_CFLAGS=$CFLAGS
sewardjc876a2f2009-01-22 22:44:30 +00001648CFLAGS="-fopenmp $mflag_primary"
sewardj493c4ef2008-12-13 16:45:19 +00001649
1650AC_LINK_IFELSE(
1651[
1652#include <omp.h>
1653int main(int argc, char** argv)
1654{
1655 omp_set_dynamic(0);
1656 return 0;
1657}
1658],
1659[
1660ac_have_openmp=yes
1661AC_MSG_RESULT([yes])
1662], [
1663ac_have_openmp=no
1664AC_MSG_RESULT([no])
1665])
1666CFLAGS=$safe_CFLAGS
1667
1668AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
1669
1670
sewardjc876a2f2009-01-22 22:44:30 +00001671# does this compiler have built-in functions for atomic memory access ?
1672AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
1673
1674safe_CFLAGS=$CFLAGS
1675CFLAGS="$mflag_primary"
1676
1677AC_TRY_LINK(,
1678[
1679 int variable = 1;
1680 return (__sync_bool_compare_and_swap(&variable, 1, 2)
1681 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
1682],
1683[
1684 AC_MSG_RESULT([yes])
1685 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.])
1686],
1687[
1688 AC_MSG_RESULT([no])
1689])
1690
1691CFLAGS=$safe_CFLAGS
1692
1693
njn7fd6d382009-01-22 21:56:32 +00001694#----------------------------------------------------------------------------
1695# Ok. We're done checking.
1696#----------------------------------------------------------------------------
sewardj80637752006-03-02 13:48:21 +00001697
gobrye721a522002-03-22 13:38:30 +00001698AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +00001699 Makefile
njn25cac76cb2002-09-23 11:21:57 +00001700 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +00001701 valgrind.pc
dirk07596a22008-04-25 11:33:30 +00001702 glibc-2.X.supp
njn254d542432002-09-23 16:09:39 +00001703 docs/Makefile
njn3e986b22004-11-30 10:43:45 +00001704 docs/lib/Makefile
1705 docs/images/Makefile
njnf7c00b12005-07-19 21:46:19 +00001706 docs/internals/Makefile
njn3e986b22004-11-30 10:43:45 +00001707 docs/xml/Makefile
njn254d542432002-09-23 16:09:39 +00001708 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +00001709 tests/vg_regtest
njn107bc572009-02-16 00:42:10 +00001710 tests/os_test
njnec0c27a2005-12-10 23:11:28 +00001711 perf/Makefile
1712 perf/vg_perf
njn254d542432002-09-23 16:09:39 +00001713 include/Makefile
sewardj0f8881b2006-10-18 01:16:57 +00001714 include/vki/Makefile
njn7a6e7462002-11-09 17:53:30 +00001715 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +00001716 coregrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001717 memcheck/Makefile
1718 memcheck/tests/Makefile
njnc6168192004-11-29 13:54:10 +00001719 memcheck/tests/amd64/Makefile
njnc6168192004-11-29 13:54:10 +00001720 memcheck/tests/x86/Makefile
njn3b3b76d2009-01-19 03:44:19 +00001721 memcheck/tests/linux/Makefile
njna454ec02009-01-19 03:16:59 +00001722 memcheck/tests/x86-linux/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001723 memcheck/docs/Makefile
1724 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001725 cachegrind/tests/Makefile
njnc6168192004-11-29 13:54:10 +00001726 cachegrind/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001727 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +00001728 cachegrind/cg_annotate
weidendoa17f2a32006-03-20 10:27:30 +00001729 callgrind/Makefile
1730 callgrind/callgrind_annotate
1731 callgrind/callgrind_control
1732 callgrind/tests/Makefile
1733 callgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001734 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +00001735 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +00001736 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +00001737 massif/Makefile
nethercotec9f36922004-02-14 16:40:02 +00001738 massif/tests/Makefile
njn734b8052007-11-01 04:40:37 +00001739 massif/perf/Makefile
nethercotec9f36922004-02-14 16:40:02 +00001740 massif/docs/Makefile
njnd5a8d242007-11-02 20:44:57 +00001741 massif/ms_print
njn25cac76cb2002-09-23 11:21:57 +00001742 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +00001743 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +00001744 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +00001745 none/Makefile
1746 none/tests/Makefile
njnc6168192004-11-29 13:54:10 +00001747 none/tests/amd64/Makefile
cerion85665ca2005-06-20 15:51:07 +00001748 none/tests/ppc32/Makefile
sewardj2c48c7b2005-11-29 13:05:56 +00001749 none/tests/ppc64/Makefile
njnc6168192004-11-29 13:54:10 +00001750 none/tests/x86/Makefile
njn0458a122009-02-13 06:23:46 +00001751 none/tests/linux/Makefile
njn9bc8c002002-10-02 13:49:13 +00001752 none/docs/Makefile
sewardj99a2ceb2007-11-09 12:30:36 +00001753 exp-omega/Makefile
1754 exp-omega/tests/Makefile
1755 exp-omega/docs/Makefile
sewardj9c606bd2008-09-18 18:12:50 +00001756 exp-ptrcheck/Makefile
1757 exp-ptrcheck/tests/Makefile
1758 exp-ptrcheck/docs/Makefile
bartccf17de2008-07-04 15:14:35 +00001759 drd/Makefile
1760 drd/docs/Makefile
1761 drd/scripts/download-and-build-splash2
1762 drd/tests/Makefile
bart0b2b4622008-06-17 19:19:16 +00001763)
gobry3b777892002-04-04 09:18:39 +00001764
1765cat<<EOF
1766
njn311303f2009-02-06 03:46:50 +00001767 Maximum build arch: ${ARCH_MAX}
1768 Primary build arch: ${VGCONF_ARCH_PRI}
1769 Build OS: ${VGCONF_OS}
njn7fd6d382009-01-22 21:56:32 +00001770 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
1771 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
sewardje95d94f2008-09-19 09:02:19 +00001772 Default supp files: ${DEFAULT_SUPP}
gobry3b777892002-04-04 09:18:39 +00001773
gobry3b777892002-04-04 09:18:39 +00001774EOF