blob: 97b68382481847b7c99a2b4cb359eaab09e17b68 [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)
njn25cac76cb2002-09-23 11:21:57 +00004AM_INIT_AUTOMAKE(valgrind, HEAD)
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
daywalker48ccca52002-04-15 00:31:58 +000022# some older automake's don't have it so try something on our own
23ifdef([AM_PROG_AS],[AM_PROG_AS],
24[
gobry1be19852002-03-26 20:44:55 +000025AS="${CC}"
26AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000027
gobry1be19852002-03-26 20:44:55 +000028ASFLAGS=""
29AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000030])
gobry3b777892002-04-04 09:18:39 +000031
32# This variable will collect the individual suppression files
33# depending on the results of autoconf
34
35DEFAULT_SUPP=""
36
37
gobrye721a522002-03-22 13:38:30 +000038# We don't want gcc 2.7
39AC_MSG_CHECKING([for a supported version of gcc])
40
daywalker870ac4c2002-05-21 00:09:48 +000041gcc_version=`${CC} --version | head -n 1`
gobrye721a522002-03-22 13:38:30 +000042
43case "${gcc_version}" in
44 gcc-2.7.*)
45 AC_MSG_RESULT([no (${gcc_version})])
46 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
47 ;;
48
49 *)
50 AC_MSG_RESULT([ok (${gcc_version})])
51 ;;
52esac
53
gobrye721a522002-03-22 13:38:30 +000054
sewardjde4a1d02002-03-22 01:27:54 +000055# Checks for the platform
56AC_CANONICAL_HOST
57
58AC_MSG_CHECKING([for a supported CPU])
59
gobrye721a522002-03-22 13:38:30 +000060case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000061 i?86)
62 AC_MSG_RESULT([ok (${host_cpu})])
63 ;;
64
65 *)
66 AC_MSG_RESULT([no (${host_cpu})])
67 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
68 ;;
69esac
70
71AC_MSG_CHECKING([for a supported OS])
72
gobrye721a522002-03-22 13:38:30 +000073case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000074 *linux*)
75 AC_MSG_RESULT([ok (${host_os})])
76 ;;
77
78 *)
79 AC_MSG_RESULT([no (${host_os})])
80 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
81 ;;
82esac
83
84
85# Ok, this is linux. Check the kernel version
86AC_MSG_CHECKING([for the kernel version])
87
88kernel=`uname -r`
89
gobrye721a522002-03-22 13:38:30 +000090case "${kernel}" in
sewardjde4a1d02002-03-22 01:27:54 +000091 2.4.*)
92 AC_MSG_RESULT([2.4 family (${kernel})])
93 AC_DEFINE(KERNEL_2_4)
sewardjde4a1d02002-03-22 01:27:54 +000094 ;;
95
96 2.2.*)
97 AC_MSG_RESULT([2.2 family (${kernel})])
98 AC_DEFINE(KERNEL_2_2)
sewardjde4a1d02002-03-22 01:27:54 +000099 ;;
100
101 *)
102 AC_MSG_RESULT([unsupported (${kernel})])
103 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
104 ;;
105esac
106
107AC_SUBST(DEFAULT_SUPP)
108
109
110# Ok, this is linux. Check the kernel version
111AC_MSG_CHECKING([the glibc version])
112
113glibc=""
114
115AC_EGREP_CPP([GLIBC_21], [
116#include <features.h>
117#ifdef __GNU_LIBRARY__
118 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
119 GLIBC_21
120 #endif
121#endif
122],
123glibc="2.1")
124
125AC_EGREP_CPP([GLIBC_22], [
126#include <features.h>
127#ifdef __GNU_LIBRARY__
128 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
129 GLIBC_22
130 #endif
131#endif
132],
133glibc="2.2")
134
gobrye721a522002-03-22 13:38:30 +0000135case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000136 2.1)
137 AC_MSG_RESULT(2.1 family)
138 AC_DEFINE(GLIBC_2_1)
gobry3b777892002-04-04 09:18:39 +0000139 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000140 ;;
141
142 2.2)
143 AC_MSG_RESULT(2.2 family)
144 AC_DEFINE(GLIBC_2_2)
gobry3b777892002-04-04 09:18:39 +0000145 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000146 ;;
147
148 *)
149 AC_MSG_RESULT(unsupported version)
150 AC_MSG_ERROR([Valgrind requires the glibc version 2.1 or 2.2])
151 ;;
152esac
153
sewardj3e909ce2002-06-03 13:27:15 +0000154# APIs introduced in recent glibc versions
155
156AC_MSG_CHECKING([whether sched_param has a sched_priority member])
157AC_CACHE_VAL(vg_have_sched_priority,
158[
159AC_TRY_COMPILE([#include <pthread.h>],[
160struct sched_param p; p.sched_priority=1;],
161vg_have_sched_priority=yes,
162vg_have_sched_priority=no)
163])
164AC_MSG_RESULT($vg_have_sched_priority)
165if test "$vg_have_sched_priority" = yes; then
166AC_DEFINE(HAVE_SCHED_PRIORITY)
167fi
168
169AC_MSG_CHECKING([whether nfds_t is defined])
170AC_CACHE_VAL(vg_have_nfds_t,
171[
172AC_TRY_COMPILE([#include <sys/poll.h>],[
173nfds_t i=0;],
174vg_have_nfds_t=yes,
175vg_have_nfds_t=no)
176])
177AC_MSG_RESULT($vg_have_nfds_t)
178if test "$vg_have_nfds_t" = yes; then
179AC_DEFINE(HAVE_NFDS_T)
180fi
181
sewardjde4a1d02002-03-22 01:27:54 +0000182# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000183# JRS 2002-06-17: this is completely bogus because it
184# detects the server version, whereas we need to know the
185# client library version. So what follows is hacked to
186# use all the X supp files regardless of what is detected.
187# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000188
gobrye721a522002-03-22 13:38:30 +0000189AC_PATH_X
190
191if test "${no_x}" != 'yes' ; then
192
193 AC_MSG_CHECKING([XFree version])
194
195 cat<<EOF > conftest.c
196#include <X11/Xlib.h>
197
198int main (int argc, char * argv [])
199{
200 Display * display = XOpenDisplay (NULL);
201
202 if (display) {
203 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
204 }
205
206 return 0;
207}
208EOF
209
210 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
211
212 if test "$?" != 0 ; then
213 AC_MSG_RESULT([cannot compile test program])
214 else
215 xfree=`./conftest`
216
217 case "${xfree}" in
218 *XFree86*)
219 ;;
220
221 *) AC_MSG_RESULT([not a XFree86 server])
222 ;;
223 esac
224
225 case "${xfree}" in
226
227 *version=4*)
228 AC_MSG_RESULT([XFree 4.x family])
229 AC_DEFINE(XFREE_4)
gobry3b777892002-04-04 09:18:39 +0000230 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000231 # haaaaaaack!
232 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000233 ;;
234
235 *version=3*)
236 AC_MSG_RESULT([XFree 3.x family])
237 AC_DEFINE(XFREE_3)
sewardj19e6a4d2002-05-22 11:58:25 +0000238 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000239 # haaaaaaack!
240 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000241 ;;
242
243 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000244 # haaaaaaack!
245 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
246 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000247 ;;
248 esac
249 fi
250
251 rm -f conftest conftest.c
252fi
253
sewardj5b754b42002-06-03 22:53:35 +0000254# does this compiler support -mpreferred-stack-boundary=2 ?
255AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
256
257CFLAGS="-mpreferred-stack-boundary=2"
258
259AC_TRY_COMPILE(, [
260
261int main () { return 0 ; }
262
263],
264[
265PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
266AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
267], [
268PREFERRED_STACK_BOUNDARY=""
269AC_MSG_RESULT([no])
270])
271
272AC_SUBST(PREFERRED_STACK_BOUNDARY)
273
274
275
sewardjde4a1d02002-03-22 01:27:54 +0000276# Checks for header files.
277AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000278AC_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 +0000279
280# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000281AC_TYPE_UID_T
282AC_TYPE_OFF_T
283AC_TYPE_SIZE_T
284AC_HEADER_TIME
285
286# Checks for library functions.
287AC_FUNC_MEMCMP
288AC_FUNC_MMAP
289AC_TYPE_SIGNAL
290
291AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
292
gobrye721a522002-03-22 13:38:30 +0000293AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000294 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000295 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000296 docs/Makefile
297 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000298 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000299 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000300 include/Makefile
njn25ab726032002-09-23 16:24:41 +0000301 coregrind/Makefile
302 coregrind/demangle/Makefile
303 coregrind/docs/Makefile
304 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000305 addrcheck/Makefile
306 memcheck/Makefile
307 memcheck/tests/Makefile
308 memcheck/docs/Makefile
309 cachegrind/Makefile
310 cachegrind/cg_annotate
311 cachegrind/tests/Makefile
312 cachegrind/docs/Makefile
313 corecheck/Makefile
314 corecheck/tests/Makefile
315 helgrind/Makefile
316 lackey/Makefile
317 none/Makefile
318 none/tests/Makefile
319)
gobry3b777892002-04-04 09:18:39 +0000320
321cat<<EOF
322
323Using the following suppressions by default:
324
325 ${DEFAULT_SUPP}
326EOF
327
328cat<<EOF > default.supp
329# This is a generated file, composed of the following suppression rules:
330#
331# ${DEFAULT_SUPP}
332#
333
334EOF
335
336for file in ${DEFAULT_SUPP} ; do
337 cat ${srcdir}/$file >> default.supp
338done