blob: 7f2ea3efe8726fe9523c7146f7274d1feb733ada [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)
sewardje5521a52003-04-23 21:17:24 +00004AM_INIT_AUTOMAKE(valgrind, cvs-head-2003-04-23)
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
sewardj2c216242002-12-14 23:49:42 +0000100 2.5.*)
101 AC_MSG_RESULT([2.5 family (${kernel})])
102 AC_DEFINE([KERNEL_2_5], 1, [Define to 1 if you're using Linux 2.5.x])
103 ;;
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})])
117 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
118 ;;
119esac
120
121AC_SUBST(DEFAULT_SUPP)
122
daywalker9e686662003-06-01 23:44:50 +0000123AC_PROG_EGREP
sewardjde4a1d02002-03-22 01:27:54 +0000124
125# Ok, this is linux. Check the kernel version
126AC_MSG_CHECKING([the glibc version])
127
128glibc=""
129
130AC_EGREP_CPP([GLIBC_21], [
131#include <features.h>
132#ifdef __GNU_LIBRARY__
133 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
134 GLIBC_21
135 #endif
136#endif
137],
138glibc="2.1")
139
140AC_EGREP_CPP([GLIBC_22], [
141#include <features.h>
142#ifdef __GNU_LIBRARY__
143 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
144 GLIBC_22
145 #endif
146#endif
147],
148glibc="2.2")
149
sewardj08c7f012002-10-07 23:56:55 +0000150AC_EGREP_CPP([GLIBC_23], [
151#include <features.h>
152#ifdef __GNU_LIBRARY__
153 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
154 GLIBC_23
155 #endif
156#endif
157],
158glibc="2.3")
159
gobrye721a522002-03-22 13:38:30 +0000160case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000161 2.1)
162 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000163 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000164 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000165 ;;
166
167 2.2)
168 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000169 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000170 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000171 ;;
172
sewardj08c7f012002-10-07 23:56:55 +0000173 2.3)
174 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000175 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
daywalker63f6f782003-05-27 00:19:52 +0000176 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.3.supp"
sewardj08c7f012002-10-07 23:56:55 +0000177 ;;
178
sewardjde4a1d02002-03-22 01:27:54 +0000179 *)
180 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000181 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000182 ;;
183esac
184
sewardj3e909ce2002-06-03 13:27:15 +0000185# APIs introduced in recent glibc versions
186
187AC_MSG_CHECKING([whether sched_param has a sched_priority member])
188AC_CACHE_VAL(vg_have_sched_priority,
189[
190AC_TRY_COMPILE([#include <pthread.h>],[
191struct sched_param p; p.sched_priority=1;],
192vg_have_sched_priority=yes,
193vg_have_sched_priority=no)
194])
195AC_MSG_RESULT($vg_have_sched_priority)
196if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000197AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000198fi
199
200AC_MSG_CHECKING([whether nfds_t is defined])
201AC_CACHE_VAL(vg_have_nfds_t,
202[
203AC_TRY_COMPILE([#include <sys/poll.h>],[
204nfds_t i=0;],
205vg_have_nfds_t=yes,
206vg_have_nfds_t=no)
207])
208AC_MSG_RESULT($vg_have_nfds_t)
209if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000210AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000211fi
212
sewardjde4a1d02002-03-22 01:27:54 +0000213# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000214# JRS 2002-06-17: this is completely bogus because it
215# detects the server version, whereas we need to know the
216# client library version. So what follows is hacked to
217# use all the X supp files regardless of what is detected.
218# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000219
gobrye721a522002-03-22 13:38:30 +0000220AC_PATH_X
221
222if test "${no_x}" != 'yes' ; then
223
224 AC_MSG_CHECKING([XFree version])
225
226 cat<<EOF > conftest.c
227#include <X11/Xlib.h>
228
229int main (int argc, char * argv [])
230{
231 Display * display = XOpenDisplay (NULL);
232
233 if (display) {
234 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
235 }
236
237 return 0;
238}
239EOF
240
241 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
242
243 if test "$?" != 0 ; then
244 AC_MSG_RESULT([cannot compile test program])
245 else
246 xfree=`./conftest`
247
248 case "${xfree}" in
249 *XFree86*)
250 ;;
251
252 *) AC_MSG_RESULT([not a XFree86 server])
253 ;;
254 esac
255
256 case "${xfree}" in
257
258 *version=4*)
259 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000260 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000261 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000262 # haaaaaaack!
263 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000264 ;;
265
266 *version=3*)
267 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000268 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000269 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000270 # haaaaaaack!
271 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000272 ;;
273
274 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000275 # haaaaaaack!
276 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
277 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000278 ;;
279 esac
280 fi
281
282 rm -f conftest conftest.c
283fi
284
sewardj2e10a682003-04-07 19:36:41 +0000285
sewardj2e10a682003-04-07 19:36:41 +0000286AC_MSG_CHECKING([if this is an NPTL-based system])
daywalker6cb58cf2003-04-17 16:58:03 +0000287safe_LIBS="$LIBS"
288LIBS="$LIBS -lpthread"
daywalker94ece2f2003-04-17 17:38:45 +0000289AC_TRY_RUN([
sewardj2e10a682003-04-07 19:36:41 +0000290#include <pthread.h>
291#include <stdio.h>
292int main (int argc, char * argv [])
293{
294 int ret;
295 pthread_mutexattr_t mutexattr;
296 ret = pthread_mutexattr_init (&mutexattr);
297 if (ret == 0) {
298 ret = pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
299 if (ret == 0) /* nptl */
sewardj2e10a682003-04-07 19:36:41 +0000300 return 0;
daywalker6cb58cf2003-04-17 16:58:03 +0000301 else /* not nptl */
302 return 1;
sewardj2e10a682003-04-07 19:36:41 +0000303 }
304 return 1;
305}
daywalker6cb58cf2003-04-17 16:58:03 +0000306],
307[
308 NPTL_THREADING="yes"
309 AC_MSG_RESULT([yes])
310],
311[
312 NPTL_THREADING="no"
313 AC_MSG_RESULT([no])
314],
315[
sewardj2e10a682003-04-07 19:36:41 +0000316 AC_MSG_RESULT([couldn't run test program])
317 NPTL_THREADING="no"
daywalker6cb58cf2003-04-17 16:58:03 +0000318])
319LIBS=$safe_LIBS
sewardj2e10a682003-04-07 19:36:41 +0000320
321AC_SUBST(NPTL_THREADING)
322
323
sewardj5b754b42002-06-03 22:53:35 +0000324# does this compiler support -mpreferred-stack-boundary=2 ?
325AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
326
327CFLAGS="-mpreferred-stack-boundary=2"
328
329AC_TRY_COMPILE(, [
330
331int main () { return 0 ; }
332
333],
334[
335PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
336AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
337], [
338PREFERRED_STACK_BOUNDARY=""
339AC_MSG_RESULT([no])
340])
341
342AC_SUBST(PREFERRED_STACK_BOUNDARY)
343
344
345
sewardjde4a1d02002-03-22 01:27:54 +0000346# Checks for header files.
347AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000348AC_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 +0000349
350# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000351AC_TYPE_UID_T
352AC_TYPE_OFF_T
353AC_TYPE_SIZE_T
354AC_HEADER_TIME
355
356# Checks for library functions.
357AC_FUNC_MEMCMP
358AC_FUNC_MMAP
359AC_TYPE_SIGNAL
360
361AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
362
gobrye721a522002-03-22 13:38:30 +0000363AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000364 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000365 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000366 docs/Makefile
367 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000368 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000369 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000370 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000371 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000372 coregrind/Makefile
373 coregrind/demangle/Makefile
374 coregrind/docs/Makefile
375 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000376 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000377 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000378 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000379 memcheck/Makefile
380 memcheck/tests/Makefile
381 memcheck/docs/Makefile
382 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000383 cachegrind/tests/Makefile
384 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000385 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000386 corecheck/Makefile
387 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000388 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000389 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000390 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000391 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000392 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000393 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000394 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000395 none/Makefile
396 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000397 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000398)
gobry3b777892002-04-04 09:18:39 +0000399
400cat<<EOF
401
402Using the following suppressions by default:
403
404 ${DEFAULT_SUPP}
405EOF
406
407cat<<EOF > default.supp
408# This is a generated file, composed of the following suppression rules:
409#
410# ${DEFAULT_SUPP}
411#
412
413EOF
414
415for file in ${DEFAULT_SUPP} ; do
416 cat ${srcdir}/$file >> default.supp
417done