blob: 2912b15d66493cae93f20f1659a55ae515f8c3fe [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
njn25ab726032002-09-23 16:24:41 +00002AC_INIT(coregrind/vg_clientmalloc.c) # give me a source file, any source file...
sewardjde4a1d02002-03-22 01:27:54 +00003AM_CONFIG_HEADER(config.h)
sewardj32f5b3f2002-12-22 19:26:30 +00004AM_INIT_AUTOMAKE(valgrind, 1.9.3)
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
daywalker48ccca52002-04-15 00:31:58 +000025# some older automake's don't have it so try something on our own
26ifdef([AM_PROG_AS],[AM_PROG_AS],
27[
gobry1be19852002-03-26 20:44:55 +000028AS="${CC}"
29AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000030
gobry1be19852002-03-26 20:44:55 +000031ASFLAGS=""
32AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000033])
gobry3b777892002-04-04 09:18:39 +000034
35# This variable will collect the individual suppression files
36# depending on the results of autoconf
37
38DEFAULT_SUPP=""
39
40
gobrye721a522002-03-22 13:38:30 +000041# We don't want gcc 2.7
42AC_MSG_CHECKING([for a supported version of gcc])
43
daywalker870ac4c2002-05-21 00:09:48 +000044gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000045
46case "${gcc_version}" in
47 gcc-2.7.*)
48 AC_MSG_RESULT([no (${gcc_version})])
49 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
50 ;;
51
52 *)
53 AC_MSG_RESULT([ok (${gcc_version})])
54 ;;
55esac
56
gobrye721a522002-03-22 13:38:30 +000057
sewardjde4a1d02002-03-22 01:27:54 +000058# Checks for the platform
59AC_CANONICAL_HOST
60
61AC_MSG_CHECKING([for a supported CPU])
62
gobrye721a522002-03-22 13:38:30 +000063case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000064 i?86)
65 AC_MSG_RESULT([ok (${host_cpu})])
66 ;;
67
68 *)
69 AC_MSG_RESULT([no (${host_cpu})])
70 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
71 ;;
72esac
73
74AC_MSG_CHECKING([for a supported OS])
75
gobrye721a522002-03-22 13:38:30 +000076case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000077 *linux*)
78 AC_MSG_RESULT([ok (${host_os})])
79 ;;
80
81 *)
82 AC_MSG_RESULT([no (${host_os})])
83 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
84 ;;
85esac
86
87
88# Ok, this is linux. Check the kernel version
89AC_MSG_CHECKING([for the kernel version])
90
91kernel=`uname -r`
92
gobrye721a522002-03-22 13:38:30 +000093case "${kernel}" in
sewardj2c216242002-12-14 23:49:42 +000094 2.5.*)
95 AC_MSG_RESULT([2.5 family (${kernel})])
96 AC_DEFINE([KERNEL_2_5], 1, [Define to 1 if you're using Linux 2.5.x])
97 ;;
98
sewardjde4a1d02002-03-22 01:27:54 +000099 2.4.*)
100 AC_MSG_RESULT([2.4 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000101 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
sewardjde4a1d02002-03-22 01:27:54 +0000102 ;;
103
104 2.2.*)
105 AC_MSG_RESULT([2.2 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +0000106 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
sewardjde4a1d02002-03-22 01:27:54 +0000107 ;;
108
109 *)
110 AC_MSG_RESULT([unsupported (${kernel})])
111 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
112 ;;
113esac
114
115AC_SUBST(DEFAULT_SUPP)
116
117
118# Ok, this is linux. Check the kernel version
119AC_MSG_CHECKING([the glibc version])
120
121glibc=""
122
123AC_EGREP_CPP([GLIBC_21], [
124#include <features.h>
125#ifdef __GNU_LIBRARY__
126 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
127 GLIBC_21
128 #endif
129#endif
130],
131glibc="2.1")
132
133AC_EGREP_CPP([GLIBC_22], [
134#include <features.h>
135#ifdef __GNU_LIBRARY__
136 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
137 GLIBC_22
138 #endif
139#endif
140],
141glibc="2.2")
142
sewardj08c7f012002-10-07 23:56:55 +0000143AC_EGREP_CPP([GLIBC_23], [
144#include <features.h>
145#ifdef __GNU_LIBRARY__
146 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
147 GLIBC_23
148 #endif
149#endif
150],
151glibc="2.3")
152
gobrye721a522002-03-22 13:38:30 +0000153case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000154 2.1)
155 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000156 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000157 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000158 ;;
159
160 2.2)
161 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000162 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000163 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000164 ;;
165
sewardj08c7f012002-10-07 23:56:55 +0000166 2.3)
167 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000168 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj08c7f012002-10-07 23:56:55 +0000169 ## Use the same suppression for as for 2.2.
170 ## This is a horrible hack that should be gotten
171 ## rid of. JRS, 20021007.
172 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
173 ;;
174
sewardjde4a1d02002-03-22 01:27:54 +0000175 *)
176 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000177 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000178 ;;
179esac
180
sewardj3e909ce2002-06-03 13:27:15 +0000181# APIs introduced in recent glibc versions
182
183AC_MSG_CHECKING([whether sched_param has a sched_priority member])
184AC_CACHE_VAL(vg_have_sched_priority,
185[
186AC_TRY_COMPILE([#include <pthread.h>],[
187struct sched_param p; p.sched_priority=1;],
188vg_have_sched_priority=yes,
189vg_have_sched_priority=no)
190])
191AC_MSG_RESULT($vg_have_sched_priority)
192if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000193AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000194fi
195
196AC_MSG_CHECKING([whether nfds_t is defined])
197AC_CACHE_VAL(vg_have_nfds_t,
198[
199AC_TRY_COMPILE([#include <sys/poll.h>],[
200nfds_t i=0;],
201vg_have_nfds_t=yes,
202vg_have_nfds_t=no)
203])
204AC_MSG_RESULT($vg_have_nfds_t)
205if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000206AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000207fi
208
sewardjde4a1d02002-03-22 01:27:54 +0000209# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000210# JRS 2002-06-17: this is completely bogus because it
211# detects the server version, whereas we need to know the
212# client library version. So what follows is hacked to
213# use all the X supp files regardless of what is detected.
214# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000215
gobrye721a522002-03-22 13:38:30 +0000216AC_PATH_X
217
218if test "${no_x}" != 'yes' ; then
219
220 AC_MSG_CHECKING([XFree version])
221
222 cat<<EOF > conftest.c
223#include <X11/Xlib.h>
224
225int main (int argc, char * argv [])
226{
227 Display * display = XOpenDisplay (NULL);
228
229 if (display) {
230 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
231 }
232
233 return 0;
234}
235EOF
236
237 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
238
239 if test "$?" != 0 ; then
240 AC_MSG_RESULT([cannot compile test program])
241 else
242 xfree=`./conftest`
243
244 case "${xfree}" in
245 *XFree86*)
246 ;;
247
248 *) AC_MSG_RESULT([not a XFree86 server])
249 ;;
250 esac
251
252 case "${xfree}" in
253
254 *version=4*)
255 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000256 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000257 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000258 # haaaaaaack!
259 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000260 ;;
261
262 *version=3*)
263 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000264 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000265 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000266 # haaaaaaack!
267 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000268 ;;
269
270 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000271 # haaaaaaack!
272 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
273 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000274 ;;
275 esac
276 fi
277
278 rm -f conftest conftest.c
279fi
280
sewardj5b754b42002-06-03 22:53:35 +0000281# does this compiler support -mpreferred-stack-boundary=2 ?
282AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
283
284CFLAGS="-mpreferred-stack-boundary=2"
285
286AC_TRY_COMPILE(, [
287
288int main () { return 0 ; }
289
290],
291[
292PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
293AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
294], [
295PREFERRED_STACK_BOUNDARY=""
296AC_MSG_RESULT([no])
297])
298
299AC_SUBST(PREFERRED_STACK_BOUNDARY)
300
301
302
sewardjde4a1d02002-03-22 01:27:54 +0000303# Checks for header files.
304AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000305AC_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 +0000306
307# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000308AC_TYPE_UID_T
309AC_TYPE_OFF_T
310AC_TYPE_SIZE_T
311AC_HEADER_TIME
312
313# Checks for library functions.
314AC_FUNC_MEMCMP
315AC_FUNC_MMAP
316AC_TYPE_SIGNAL
317
318AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
319
gobrye721a522002-03-22 13:38:30 +0000320AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000321 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000322 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000323 docs/Makefile
324 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000325 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000326 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000327 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000328 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000329 coregrind/Makefile
330 coregrind/demangle/Makefile
331 coregrind/docs/Makefile
332 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000333 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000334 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000335 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000336 memcheck/Makefile
337 memcheck/tests/Makefile
338 memcheck/docs/Makefile
339 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000340 cachegrind/tests/Makefile
341 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000342 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000343 corecheck/Makefile
344 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000345 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000346 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000347 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000348 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000349 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000350 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000351 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000352 none/Makefile
353 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000354 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000355)
gobry3b777892002-04-04 09:18:39 +0000356
357cat<<EOF
358
359Using the following suppressions by default:
360
361 ${DEFAULT_SUPP}
362EOF
363
364cat<<EOF > default.supp
365# This is a generated file, composed of the following suppression rules:
366#
367# ${DEFAULT_SUPP}
368#
369
370EOF
371
372for file in ${DEFAULT_SUPP} ; do
373 cat ${srcdir}/$file >> default.supp
374done