blob: 8d81164b8afac52574fd31062e698683c8961f6e [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
jsewarddc0b4e82004-08-31 16:26:27 +00002AC_INIT(Valgrind, 2.3.0.CVS, valgrind-users@lists.sourceforge.net)
thughes6dbad732004-08-29 09:46:38 +00003AC_CONFIG_SRCDIR(coregrind/vg_main.c)
sewardjde4a1d02002-03-22 01:27:54 +00004AM_CONFIG_HEADER(config.h)
thughes6dbad732004-08-29 09:46:38 +00005AM_INIT_AUTOMAKE
sewardjde4a1d02002-03-22 01:27:54 +00006
gobryb0ed4672002-03-27 20:58:58 +00007AM_MAINTAINER_MODE
8
sewardjde4a1d02002-03-22 01:27:54 +00009# Checks for programs.
gobrye721a522002-03-22 13:38:30 +000010CFLAGS=""
11
sewardjde4a1d02002-03-22 01:27:54 +000012AC_PROG_LN_S
13AC_PROG_CC
thughesa92ffd52004-11-01 09:50:57 +000014AM_PROG_CC_C_O
sewardjde4a1d02002-03-22 01:27:54 +000015AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000016AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000017AC_PROG_RANLIB
18
gobrye721a522002-03-22 13:38:30 +000019# Check for the compiler support
20if test "${GCC}" != "yes" ; then
21 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
22fi
23
sewardj2f685952002-12-22 19:32:23 +000024# figure out where perl lives
25AC_PATH_PROG(PERL, perl)
26
njn9315df32003-04-16 20:50:50 +000027# figure out where gdb lives
28AC_PATH_PROG(GDB, gdb)
njn17b85352003-04-18 12:54:24 +000029# autoheader tries to execute the 3rd string or something; I get warnings when
30# it's defined. So just leave it undefined. --njn 2002-Apr-18
31AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", "")
njn9315df32003-04-16 20:50:50 +000032
daywalker48ccca52002-04-15 00:31:58 +000033# some older automake's don't have it so try something on our own
34ifdef([AM_PROG_AS],[AM_PROG_AS],
35[
gobry1be19852002-03-26 20:44:55 +000036AS="${CC}"
37AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000038
gobry1be19852002-03-26 20:44:55 +000039ASFLAGS=""
40AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000041])
gobry3b777892002-04-04 09:18:39 +000042
43# This variable will collect the individual suppression files
44# depending on the results of autoconf
45
46DEFAULT_SUPP=""
47
48
gobrye721a522002-03-22 13:38:30 +000049# We don't want gcc 2.7
50AC_MSG_CHECKING([for a supported version of gcc])
51
daywalker870ac4c2002-05-21 00:09:48 +000052gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000053
54case "${gcc_version}" in
55 gcc-2.7.*)
56 AC_MSG_RESULT([no (${gcc_version})])
57 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
58 ;;
59
60 *)
61 AC_MSG_RESULT([ok (${gcc_version})])
62 ;;
63esac
64
gobrye721a522002-03-22 13:38:30 +000065
sewardjde4a1d02002-03-22 01:27:54 +000066# Checks for the platform
67AC_CANONICAL_HOST
68
69AC_MSG_CHECKING([for a supported CPU])
nethercote888ecb72004-08-23 14:54:40 +000070AC_SUBST(VG_ARCH)
nethercote2b72e942004-10-25 14:05:56 +000071AC_SUBST(KICKSTART_BASE)
nethercotecf4d9972004-10-25 15:21:00 +000072AC_SUBST(ARCH_CORE_AM_CFLAGS)
73AC_SUBST(ARCH_TOOL_AM_CFLAGS)
nethercote8df0a402004-10-25 19:20:14 +000074AC_SUBST(ARCH_CORE_AM_CCASFLAGS)
sewardjde4a1d02002-03-22 01:27:54 +000075
gobrye721a522002-03-22 13:38:30 +000076case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000077 i?86)
78 AC_MSG_RESULT([ok (${host_cpu})])
nethercote888ecb72004-08-23 14:54:40 +000079 VG_ARCH="x86"
nethercote2b72e942004-10-25 14:05:56 +000080 KICKSTART_BASE="0xb0000000"
nethercotecf4d9972004-10-25 15:21:00 +000081 ARCH_CORE_AM_CFLAGS="-fomit-frame-pointer @PREFERRED_STACK_BOUNDARY@ -DELFSZ=32"
82 ARCH_TOOL_AM_CFLAGS="-fomit-frame-pointer @PREFERRED_STACK_BOUNDARY@"
nethercote8df0a402004-10-25 19:20:14 +000083 ARCH_CORE_AM_CCASFLAGS=""
sewardjde4a1d02002-03-22 01:27:54 +000084 ;;
85
nethercote9bcc9062004-10-13 13:50:01 +000086 powerpc*)
87 AC_MSG_RESULT([no (${host_cpu})])
nethercoteda8735a2004-10-19 14:24:42 +000088 VG_ARCH="ppc"
nethercote2b72e942004-10-25 14:05:56 +000089 KICKSTART_BASE="0x70000000"
nethercotecf4d9972004-10-25 15:21:00 +000090 ARCH_CORE_AM_CFLAGS="-DELFSZ=32"
91 ARCH_TOOL_AM_CFLAGS="-fpic"
nethercote8df0a402004-10-25 19:20:14 +000092 ARCH_CORE_AM_CCASFLAGS="-Wa,-maltivec"
nethercote9bcc9062004-10-13 13:50:01 +000093 AC_MSG_ERROR([PowerPC not supported. Sorry])
94 ;;
95
sewardjde4a1d02002-03-22 01:27:54 +000096 *)
97 AC_MSG_RESULT([no (${host_cpu})])
nethercote81d5c662004-10-13 13:18:51 +000098 AC_MSG_ERROR([Unsupported host architecture. Sorry])
sewardjde4a1d02002-03-22 01:27:54 +000099 ;;
100esac
101
102AC_MSG_CHECKING([for a supported OS])
nethercote888ecb72004-08-23 14:54:40 +0000103AC_SUBST(VG_OS)
sewardjde4a1d02002-03-22 01:27:54 +0000104
gobrye721a522002-03-22 13:38:30 +0000105case "${host_os}" in
mueller8c68e042004-01-03 15:21:14 +0000106 *linux*)
sewardjde4a1d02002-03-22 01:27:54 +0000107 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000108 VG_OS="linux"
mueller8c68e042004-01-03 15:21:14 +0000109
110 # Ok, this is linux. Check the kernel version
111 AC_MSG_CHECKING([for the kernel version])
112
113 kernel=`uname -r`
114
115 case "${kernel}" in
116 2.6.*)
117 AC_MSG_RESULT([2.6 family (${kernel})])
118 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
119 ;;
120
121 2.4.*)
122 AC_MSG_RESULT([2.4 family (${kernel})])
123 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
124 ;;
125
mueller8c68e042004-01-03 15:21:14 +0000126 *)
127 AC_MSG_RESULT([unsupported (${kernel})])
nethercote4fa681f2004-11-08 17:51:39 +0000128 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
mueller8c68e042004-01-03 15:21:14 +0000129 ;;
130 esac
131
132 ;;
133
134 *freebsd*)
135 AC_MSG_RESULT([ok (${host_os})])
nethercote888ecb72004-08-23 14:54:40 +0000136 VG_OS="freebsd"
sewardjde4a1d02002-03-22 01:27:54 +0000137 ;;
138
139 *)
140 AC_MSG_RESULT([no (${host_os})])
mueller8c68e042004-01-03 15:21:14 +0000141 AC_MSG_ERROR([Valgrind is operating system specific. Sorry. Please consider doing a port.])
sewardjde4a1d02002-03-22 01:27:54 +0000142 ;;
143esac
144
nethercote888ecb72004-08-23 14:54:40 +0000145AC_MSG_CHECKING([for a supported CPU/OS combination])
146AC_SUBST(VG_PLATFORM)
147
148VG_PLATFORM="$VG_ARCH-$VG_OS"
149
150case $VG_PLATFORM in
151 x86-linux)
152 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
153 ;;
154
155 *)
156 AC_MSG_RESULT([no (${host_cpu}-${host_os})])
157 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doin
158g a port.])
159 ;;
160esac
sewardjde4a1d02002-03-22 01:27:54 +0000161
sewardjde4a1d02002-03-22 01:27:54 +0000162AC_SUBST(DEFAULT_SUPP)
163
sewardjde4a1d02002-03-22 01:27:54 +0000164glibc=""
165
166AC_EGREP_CPP([GLIBC_21], [
167#include <features.h>
168#ifdef __GNU_LIBRARY__
169 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
170 GLIBC_21
171 #endif
172#endif
173],
174glibc="2.1")
175
176AC_EGREP_CPP([GLIBC_22], [
177#include <features.h>
178#ifdef __GNU_LIBRARY__
179 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
180 GLIBC_22
181 #endif
182#endif
183],
184glibc="2.2")
185
sewardj08c7f012002-10-07 23:56:55 +0000186AC_EGREP_CPP([GLIBC_23], [
187#include <features.h>
188#ifdef __GNU_LIBRARY__
189 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
190 GLIBC_23
191 #endif
192#endif
193],
194glibc="2.3")
195
daywalkere9212b32003-06-15 22:39:15 +0000196AC_MSG_CHECKING([the glibc version])
197
gobrye721a522002-03-22 13:38:30 +0000198case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000199 2.1)
200 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000201 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000202 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000203 ;;
204
205 2.2)
206 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000207 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000208 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000209 ;;
210
sewardj08c7f012002-10-07 23:56:55 +0000211 2.3)
212 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000213 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
daywalker63f6f782003-05-27 00:19:52 +0000214 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.3.supp"
sewardj08c7f012002-10-07 23:56:55 +0000215 ;;
216
sewardjde4a1d02002-03-22 01:27:54 +0000217 *)
218 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000219 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000220 ;;
221esac
222
sewardj3e909ce2002-06-03 13:27:15 +0000223# APIs introduced in recent glibc versions
224
225AC_MSG_CHECKING([whether sched_param has a sched_priority member])
226AC_CACHE_VAL(vg_have_sched_priority,
227[
228AC_TRY_COMPILE([#include <pthread.h>],[
229struct sched_param p; p.sched_priority=1;],
230vg_have_sched_priority=yes,
231vg_have_sched_priority=no)
232])
233AC_MSG_RESULT($vg_have_sched_priority)
234if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000235AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000236fi
237
nethercote3d260f62004-10-31 19:39:18 +0000238# We don't know how to detect the X client library version
239# (detecting the server version is easy, bu no help). So we
240# just use a hack: always include the suppressions for both
241# versions 3 and 4.
gobrye721a522002-03-22 13:38:30 +0000242AC_PATH_X
gobrye721a522002-03-22 13:38:30 +0000243if test "${no_x}" != 'yes' ; then
nethercote3d260f62004-10-31 19:39:18 +0000244 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
245 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000246fi
247
sewardj2e10a682003-04-07 19:36:41 +0000248
sewardj5b754b42002-06-03 22:53:35 +0000249# does this compiler support -mpreferred-stack-boundary=2 ?
250AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
251
daywalker3664f562003-10-17 13:43:46 +0000252safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000253CFLAGS="-mpreferred-stack-boundary=2"
254
255AC_TRY_COMPILE(, [
sewardj5b754b42002-06-03 22:53:35 +0000256int main () { return 0 ; }
sewardj5b754b42002-06-03 22:53:35 +0000257],
258[
259PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000260AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000261], [
262PREFERRED_STACK_BOUNDARY=""
263AC_MSG_RESULT([no])
264])
daywalker3664f562003-10-17 13:43:46 +0000265CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000266
267AC_SUBST(PREFERRED_STACK_BOUNDARY)
268
269
nethercote7f390022004-10-25 17:18:24 +0000270# Check for PIE support in the compiler and linker
271AC_CACHE_CHECK([for PIE support], vg_cv_pie,
272 [safe_CFLAGS=$CFLAGS
273 CFLAGS="$CFLAGS -fpie"
274 safe_LDFLAGS=$LDFLAGS
275 LDFLAGS="$LDFLAGS -pie"
276 AC_TRY_LINK([int foo;],
277 [],
278 [vg_cv_pie=yes],
279 [vg_cv_pie=no])
280 CFLAGS=$safe_CFLAGS
281 LDFLAGS=$safe_LDFLAGS])
282if test "$vg_cv_pie" = yes; then
283AC_DEFINE([HAVE_PIE], 1, [can create position-independent executables])
284fi
285AM_CONDITIONAL(USE_PIE, test "$vg_cv_pie" = "yes")
286
sewardj5b754b42002-06-03 22:53:35 +0000287
sewardjde4a1d02002-03-22 01:27:54 +0000288# Checks for header files.
289AC_HEADER_STDC
nethercote3d260f62004-10-31 19:39:18 +0000290AC_CHECK_HEADERS([sys/endian.h endian.h mqueue.h])
sewardjde4a1d02002-03-22 01:27:54 +0000291
292# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000293AC_TYPE_UID_T
294AC_TYPE_OFF_T
295AC_TYPE_SIZE_T
296AC_HEADER_TIME
thughesebed9982004-06-12 17:25:25 +0000297AC_CHECK_TYPES(__pthread_unwind_buf_t,,,[#include <pthread.h>])
sewardjde4a1d02002-03-22 01:27:54 +0000298
299# Checks for library functions.
300AC_FUNC_MEMCMP
301AC_FUNC_MMAP
302AC_TYPE_SIGNAL
303
thughesbeb6eb92004-06-14 12:33:43 +0000304AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr semtimedop])
sewardjde4a1d02002-03-22 01:27:54 +0000305
gobrye721a522002-03-22 13:38:30 +0000306AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000307 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000308 valgrind.spec
muellerbddd6072003-11-19 21:50:07 +0000309 valgrind.pc
njn254d542432002-09-23 16:09:39 +0000310 docs/Makefile
311 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000312 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000313 tests/unused/Makefile
nethercotee90c6832004-10-18 18:07:49 +0000314 include/valgrind.h
njn254d542432002-09-23 16:09:39 +0000315 include/Makefile
nethercotec06e2132004-09-03 13:45:29 +0000316 include/x86/Makefile
nethercote73b526f2004-10-31 18:48:21 +0000317 include/linux/Makefile
318 include/x86-linux/Makefile
njn7a6e7462002-11-09 17:53:30 +0000319 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000320 coregrind/Makefile
321 coregrind/demangle/Makefile
322 coregrind/docs/Makefile
fitzhardinge98abfc72003-12-16 02:05:15 +0000323 coregrind/x86/Makefile
nethercotef94fe2f2004-09-10 14:23:59 +0000324 coregrind/x86-linux/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000325 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000326 addrcheck/tests/Makefile
nethercotebfd20192004-10-19 18:54:11 +0000327 addrcheck/tests/x86/Makefile
njn7da8fa72002-10-03 10:38:40 +0000328 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000329 memcheck/Makefile
330 memcheck/tests/Makefile
nethercotebfd20192004-10-19 18:54:11 +0000331 memcheck/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000332 memcheck/docs/Makefile
333 cachegrind/Makefile
nethercoteb35a8b92004-09-11 16:45:27 +0000334 cachegrind/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000335 cachegrind/tests/Makefile
nethercotea255d802004-10-19 17:00:59 +0000336 cachegrind/tests/x86/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000337 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000338 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000339 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000340 helgrind/tests/Makefile
nethercotebfd20192004-10-19 18:54:11 +0000341 helgrind/tests/x86/Makefile
njn83157fc2002-10-03 10:07:34 +0000342 helgrind/docs/Makefile
nethercotec9f36922004-02-14 16:40:02 +0000343 massif/Makefile
344 massif/hp2ps/Makefile
345 massif/tests/Makefile
346 massif/docs/Makefile
347 corecheck/Makefile
348 corecheck/tests/Makefile
349 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000350 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000351 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000352 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000353 none/Makefile
354 none/tests/Makefile
nethercotebfd20192004-10-19 18:54:11 +0000355 none/tests/x86/Makefile
njn9bc8c002002-10-02 13:49:13 +0000356 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000357)
gobry3b777892002-04-04 09:18:39 +0000358
359cat<<EOF
360
361Using the following suppressions by default:
362
363 ${DEFAULT_SUPP}
364EOF
365
366cat<<EOF > default.supp
367# This is a generated file, composed of the following suppression rules:
368#
369# ${DEFAULT_SUPP}
370#
371
372EOF
373
374for file in ${DEFAULT_SUPP} ; do
375 cat ${srcdir}/$file >> default.supp
376done