blob: f3f032c17ff5946910c1c69c55ac3a59d5ef8b0a [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
njn3e884182003-04-15 13:03:23 +00002AC_INIT(coregrind/vg_main.c) # give me a source file, any source file...
sewardjde4a1d02002-03-22 01:27:54 +00003AM_CONFIG_HEADER(config.h)
sewardjaf795512003-07-26 17:50:42 +00004AM_INIT_AUTOMAKE(valgrind, 20030725)
sewardjde4a1d02002-03-22 01:27:54 +00005
gobryb0ed4672002-03-27 20:58:58 +00006AM_MAINTAINER_MODE
7
sewardjde4a1d02002-03-22 01:27:54 +00008# Checks for programs.
gobrye721a522002-03-22 13:38:30 +00009CFLAGS=""
10
sewardjde4a1d02002-03-22 01:27:54 +000011AC_PROG_LN_S
12AC_PROG_CC
13AC_PROG_CPP
njn25e49d8e72002-09-23 09:36:25 +000014AC_PROG_CXX
sewardjde4a1d02002-03-22 01:27:54 +000015AC_PROG_RANLIB
16
gobrye721a522002-03-22 13:38:30 +000017# Check for the compiler support
18if test "${GCC}" != "yes" ; then
19 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
20fi
21
sewardj2f685952002-12-22 19:32:23 +000022# figure out where perl lives
23AC_PATH_PROG(PERL, perl)
24
njn9315df32003-04-16 20:50:50 +000025# figure out where gdb lives
26AC_PATH_PROG(GDB, gdb)
njn17b85352003-04-18 12:54:24 +000027# autoheader tries to execute the 3rd string or something; I get warnings when
28# it's defined. So just leave it undefined. --njn 2002-Apr-18
29AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", "")
njn9315df32003-04-16 20:50:50 +000030
daywalker48ccca52002-04-15 00:31:58 +000031# some older automake's don't have it so try something on our own
32ifdef([AM_PROG_AS],[AM_PROG_AS],
33[
gobry1be19852002-03-26 20:44:55 +000034AS="${CC}"
35AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000036
gobry1be19852002-03-26 20:44:55 +000037ASFLAGS=""
38AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000039])
gobry3b777892002-04-04 09:18:39 +000040
41# This variable will collect the individual suppression files
42# depending on the results of autoconf
43
44DEFAULT_SUPP=""
45
46
gobrye721a522002-03-22 13:38:30 +000047# We don't want gcc 2.7
48AC_MSG_CHECKING([for a supported version of gcc])
49
daywalker870ac4c2002-05-21 00:09:48 +000050gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000051
52case "${gcc_version}" in
53 gcc-2.7.*)
54 AC_MSG_RESULT([no (${gcc_version})])
55 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
56 ;;
57
58 *)
59 AC_MSG_RESULT([ok (${gcc_version})])
60 ;;
61esac
62
gobrye721a522002-03-22 13:38:30 +000063
sewardjde4a1d02002-03-22 01:27:54 +000064# Checks for the platform
65AC_CANONICAL_HOST
66
67AC_MSG_CHECKING([for a supported CPU])
68
gobrye721a522002-03-22 13:38:30 +000069case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000070 i?86)
71 AC_MSG_RESULT([ok (${host_cpu})])
72 ;;
73
74 *)
75 AC_MSG_RESULT([no (${host_cpu})])
76 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
77 ;;
78esac
79
80AC_MSG_CHECKING([for a supported OS])
81
gobrye721a522002-03-22 13:38:30 +000082case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000083 *linux*)
84 AC_MSG_RESULT([ok (${host_os})])
85 ;;
86
87 *)
88 AC_MSG_RESULT([no (${host_os})])
89 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
90 ;;
91esac
92
93
94# Ok, this is linux. Check the kernel version
95AC_MSG_CHECKING([for the kernel version])
96
97kernel=`uname -r`
98
gobrye721a522002-03-22 13:38:30 +000099case "${kernel}" in
daywalker4fda9bf2003-08-10 13:37:01 +0000100 2.6.*)
101 AC_MSG_RESULT([2.6 family (${kernel})])
102 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
sewardj2c216242002-12-14 23:49:42 +0000103 ;;
104
sewardjde4a1d02002-03-22 01:27:54 +0000105 2.4.*)
106 AC_MSG_RESULT([2.4 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000107 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
sewardjde4a1d02002-03-22 01:27:54 +0000108 ;;
109
110 2.2.*)
111 AC_MSG_RESULT([2.2 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000112 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
sewardjde4a1d02002-03-22 01:27:54 +0000113 ;;
114
115 *)
116 AC_MSG_RESULT([unsupported (${kernel})])
jsgf855d93d2003-10-13 22:26:55 +0000117 AC_MSG_ERROR([Valgrind works on kernels 2.2, 2.4, 2.6])
sewardjde4a1d02002-03-22 01:27:54 +0000118 ;;
119esac
120
121AC_SUBST(DEFAULT_SUPP)
122
sewardjde4a1d02002-03-22 01:27:54 +0000123glibc=""
124
125AC_EGREP_CPP([GLIBC_21], [
126#include <features.h>
127#ifdef __GNU_LIBRARY__
128 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
129 GLIBC_21
130 #endif
131#endif
132],
133glibc="2.1")
134
135AC_EGREP_CPP([GLIBC_22], [
136#include <features.h>
137#ifdef __GNU_LIBRARY__
138 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
139 GLIBC_22
140 #endif
141#endif
142],
143glibc="2.2")
144
sewardj08c7f012002-10-07 23:56:55 +0000145AC_EGREP_CPP([GLIBC_23], [
146#include <features.h>
147#ifdef __GNU_LIBRARY__
148 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
149 GLIBC_23
150 #endif
151#endif
152],
153glibc="2.3")
154
daywalkere9212b32003-06-15 22:39:15 +0000155# Ok, this is linux. Check the kernel version
156AC_MSG_CHECKING([the glibc version])
157
gobrye721a522002-03-22 13:38:30 +0000158case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000159 2.1)
160 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000161 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000162 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000163 ;;
164
165 2.2)
166 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000167 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000168 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000169 ;;
170
sewardj08c7f012002-10-07 23:56:55 +0000171 2.3)
172 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000173 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
daywalker63f6f782003-05-27 00:19:52 +0000174 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.3.supp"
sewardj08c7f012002-10-07 23:56:55 +0000175 ;;
176
sewardjde4a1d02002-03-22 01:27:54 +0000177 *)
178 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000179 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000180 ;;
181esac
182
sewardj3e909ce2002-06-03 13:27:15 +0000183# APIs introduced in recent glibc versions
184
185AC_MSG_CHECKING([whether sched_param has a sched_priority member])
186AC_CACHE_VAL(vg_have_sched_priority,
187[
188AC_TRY_COMPILE([#include <pthread.h>],[
189struct sched_param p; p.sched_priority=1;],
190vg_have_sched_priority=yes,
191vg_have_sched_priority=no)
192])
193AC_MSG_RESULT($vg_have_sched_priority)
194if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000195AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000196fi
197
198AC_MSG_CHECKING([whether nfds_t is defined])
199AC_CACHE_VAL(vg_have_nfds_t,
200[
201AC_TRY_COMPILE([#include <sys/poll.h>],[
202nfds_t i=0;],
203vg_have_nfds_t=yes,
204vg_have_nfds_t=no)
205])
206AC_MSG_RESULT($vg_have_nfds_t)
207if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000208AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000209fi
210
sewardjde4a1d02002-03-22 01:27:54 +0000211# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000212# JRS 2002-06-17: this is completely bogus because it
213# detects the server version, whereas we need to know the
214# client library version. So what follows is hacked to
215# use all the X supp files regardless of what is detected.
216# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000217
gobrye721a522002-03-22 13:38:30 +0000218AC_PATH_X
219
220if test "${no_x}" != 'yes' ; then
221
222 AC_MSG_CHECKING([XFree version])
223
224 cat<<EOF > conftest.c
225#include <X11/Xlib.h>
226
227int main (int argc, char * argv [])
228{
229 Display * display = XOpenDisplay (NULL);
230
231 if (display) {
232 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
233 }
234
235 return 0;
236}
237EOF
238
239 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
240
241 if test "$?" != 0 ; then
242 AC_MSG_RESULT([cannot compile test program])
243 else
244 xfree=`./conftest`
245
246 case "${xfree}" in
247 *XFree86*)
248 ;;
249
250 *) AC_MSG_RESULT([not a XFree86 server])
251 ;;
252 esac
253
254 case "${xfree}" in
255
256 *version=4*)
257 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000258 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000259 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000260 # haaaaaaack!
261 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000262 ;;
263
264 *version=3*)
265 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000266 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000267 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000268 # haaaaaaack!
269 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000270 ;;
271
272 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000273 # haaaaaaack!
274 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
275 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000276 ;;
277 esac
278 fi
279
280 rm -f conftest conftest.c
281fi
282
sewardj2e10a682003-04-07 19:36:41 +0000283
sewardj2e10a682003-04-07 19:36:41 +0000284AC_MSG_CHECKING([if this is an NPTL-based system])
daywalker6cb58cf2003-04-17 16:58:03 +0000285safe_LIBS="$LIBS"
286LIBS="$LIBS -lpthread"
daywalker94ece2f2003-04-17 17:38:45 +0000287AC_TRY_RUN([
sewardj2e10a682003-04-07 19:36:41 +0000288#include <pthread.h>
289#include <stdio.h>
290int main (int argc, char * argv [])
291{
292 int ret;
293 pthread_mutexattr_t mutexattr;
294 ret = pthread_mutexattr_init (&mutexattr);
295 if (ret == 0) {
296 ret = pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
297 if (ret == 0) /* nptl */
sewardj2e10a682003-04-07 19:36:41 +0000298 return 0;
daywalker6cb58cf2003-04-17 16:58:03 +0000299 else /* not nptl */
300 return 1;
sewardj2e10a682003-04-07 19:36:41 +0000301 }
302 return 1;
303}
daywalker6cb58cf2003-04-17 16:58:03 +0000304],
305[
306 NPTL_THREADING="yes"
307 AC_MSG_RESULT([yes])
308],
309[
310 NPTL_THREADING="no"
311 AC_MSG_RESULT([no])
312],
313[
sewardj2e10a682003-04-07 19:36:41 +0000314 AC_MSG_RESULT([couldn't run test program])
315 NPTL_THREADING="no"
daywalker6cb58cf2003-04-17 16:58:03 +0000316])
317LIBS=$safe_LIBS
sewardj2e10a682003-04-07 19:36:41 +0000318
319AC_SUBST(NPTL_THREADING)
320
daywalker3664f562003-10-17 13:43:46 +0000321# check if the GNU as supports CFI directives
322AC_MSG_CHECKING([if gas accepts .cfi])
323AC_TRY_COMPILE(, [
324
325__asm__ __volatile__ (".cfi_startproc\n"
326 ".cfi_adjust_cfa_offset 0x0\n"
327 ".cfi_endproc\n");
328],
329[
330 AC_DEFINE_UNQUOTED([HAVE_GAS_CFI], 1, [Define if your GNU as supports .cfi])
331 AC_MSG_RESULT(yes)
332],
333 AC_MSG_RESULT(no)
334)
sewardj2e10a682003-04-07 19:36:41 +0000335
sewardj5b754b42002-06-03 22:53:35 +0000336# does this compiler support -mpreferred-stack-boundary=2 ?
337AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
338
daywalker3664f562003-10-17 13:43:46 +0000339safe_CFLAGS=$CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000340CFLAGS="-mpreferred-stack-boundary=2"
341
342AC_TRY_COMPILE(, [
343
344int main () { return 0 ; }
345
346],
347[
348PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
daywalker3664f562003-10-17 13:43:46 +0000349AC_MSG_RESULT([yes])
sewardj5b754b42002-06-03 22:53:35 +0000350], [
351PREFERRED_STACK_BOUNDARY=""
352AC_MSG_RESULT([no])
353])
daywalker3664f562003-10-17 13:43:46 +0000354CFLAGS=$safe_CFLAGS
sewardj5b754b42002-06-03 22:53:35 +0000355
356AC_SUBST(PREFERRED_STACK_BOUNDARY)
357
358
359
sewardjde4a1d02002-03-22 01:27:54 +0000360# Checks for header files.
361AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000362AC_CHECK_HEADERS([fcntl.h malloc.h stdlib.h string.h sys/socket.h sys/statfs.h sys/time.h termios.h unistd.h utime.h])
sewardjde4a1d02002-03-22 01:27:54 +0000363
364# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000365AC_TYPE_UID_T
366AC_TYPE_OFF_T
367AC_TYPE_SIZE_T
368AC_HEADER_TIME
369
370# Checks for library functions.
371AC_FUNC_MEMCMP
372AC_FUNC_MMAP
373AC_TYPE_SIGNAL
374
375AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
376
gobrye721a522002-03-22 13:38:30 +0000377AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000378 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000379 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000380 docs/Makefile
381 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000382 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000383 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000384 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000385 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000386 coregrind/Makefile
387 coregrind/demangle/Makefile
388 coregrind/docs/Makefile
389 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000390 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000391 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000392 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000393 memcheck/Makefile
394 memcheck/tests/Makefile
395 memcheck/docs/Makefile
396 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000397 cachegrind/tests/Makefile
398 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000399 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000400 corecheck/Makefile
401 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000402 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000403 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000404 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000405 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000406 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000407 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000408 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000409 none/Makefile
410 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000411 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000412)
gobry3b777892002-04-04 09:18:39 +0000413
414cat<<EOF
415
416Using the following suppressions by default:
417
418 ${DEFAULT_SUPP}
419EOF
420
421cat<<EOF > default.supp
422# This is a generated file, composed of the following suppression rules:
423#
424# ${DEFAULT_SUPP}
425#
426
427EOF
428
429for file in ${DEFAULT_SUPP} ; do
430 cat ${srcdir}/$file >> default.supp
431done