blob: 798ca2388cb0140001bcca68b2bb6b9ac0ac0fa1 [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)
sewardj00863422002-10-05 15:34:55 +00004AM_INIT_AUTOMAKE(valgrind, 1.1.0)
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})])
daywalker418c7482002-10-16 13:09:26 +000093 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
sewardjde4a1d02002-03-22 01:27:54 +000094 ;;
95
96 2.2.*)
97 AC_MSG_RESULT([2.2 family (${kernel})])
daywalker418c7482002-10-16 13:09:26 +000098 AC_DEFINE([KERNEL_2_2], 1, [Define to 1 if you're using Linux 2.2.x])
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
sewardj08c7f012002-10-07 23:56:55 +0000135AC_EGREP_CPP([GLIBC_23], [
136#include <features.h>
137#ifdef __GNU_LIBRARY__
138 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3)
139 GLIBC_23
140 #endif
141#endif
142],
143glibc="2.3")
144
gobrye721a522002-03-22 13:38:30 +0000145case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000146 2.1)
147 AC_MSG_RESULT(2.1 family)
daywalker418c7482002-10-16 13:09:26 +0000148 AC_DEFINE([GLIBC_2_1], 1, [Define to 1 if you're using glibc 2.1.x])
gobry3b777892002-04-04 09:18:39 +0000149 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000150 ;;
151
152 2.2)
153 AC_MSG_RESULT(2.2 family)
daywalker418c7482002-10-16 13:09:26 +0000154 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
gobry3b777892002-04-04 09:18:39 +0000155 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000156 ;;
157
sewardj08c7f012002-10-07 23:56:55 +0000158 2.3)
159 AC_MSG_RESULT(2.3 family)
daywalker418c7482002-10-16 13:09:26 +0000160 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
sewardj08c7f012002-10-07 23:56:55 +0000161 ## Use the same suppression for as for 2.2.
162 ## This is a horrible hack that should be gotten
163 ## rid of. JRS, 20021007.
164 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
165 ;;
166
sewardjde4a1d02002-03-22 01:27:54 +0000167 *)
168 AC_MSG_RESULT(unsupported version)
sewardj08c7f012002-10-07 23:56:55 +0000169 AC_MSG_ERROR([Valgrind requires the glibc version 2.1, 2.2 or 2.3])
sewardjde4a1d02002-03-22 01:27:54 +0000170 ;;
171esac
172
sewardj3e909ce2002-06-03 13:27:15 +0000173# APIs introduced in recent glibc versions
174
175AC_MSG_CHECKING([whether sched_param has a sched_priority member])
176AC_CACHE_VAL(vg_have_sched_priority,
177[
178AC_TRY_COMPILE([#include <pthread.h>],[
179struct sched_param p; p.sched_priority=1;],
180vg_have_sched_priority=yes,
181vg_have_sched_priority=no)
182])
183AC_MSG_RESULT($vg_have_sched_priority)
184if test "$vg_have_sched_priority" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000185AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
sewardj3e909ce2002-06-03 13:27:15 +0000186fi
187
188AC_MSG_CHECKING([whether nfds_t is defined])
189AC_CACHE_VAL(vg_have_nfds_t,
190[
191AC_TRY_COMPILE([#include <sys/poll.h>],[
192nfds_t i=0;],
193vg_have_nfds_t=yes,
194vg_have_nfds_t=no)
195])
196AC_MSG_RESULT($vg_have_nfds_t)
197if test "$vg_have_nfds_t" = yes; then
daywalker418c7482002-10-16 13:09:26 +0000198AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
sewardj3e909ce2002-06-03 13:27:15 +0000199fi
200
sewardjde4a1d02002-03-22 01:27:54 +0000201# try to detect the XFree version
sewardj8ce25cd2002-06-18 01:05:58 +0000202# JRS 2002-06-17: this is completely bogus because it
203# detects the server version, whereas we need to know the
204# client library version. So what follows is hacked to
205# use all the X supp files regardless of what is detected.
206# This is really stoooopid and should be fixed properly.
sewardjde4a1d02002-03-22 01:27:54 +0000207
gobrye721a522002-03-22 13:38:30 +0000208AC_PATH_X
209
210if test "${no_x}" != 'yes' ; then
211
212 AC_MSG_CHECKING([XFree version])
213
214 cat<<EOF > conftest.c
215#include <X11/Xlib.h>
216
217int main (int argc, char * argv [])
218{
219 Display * display = XOpenDisplay (NULL);
220
221 if (display) {
222 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
223 }
224
225 return 0;
226}
227EOF
228
229 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
230
231 if test "$?" != 0 ; then
232 AC_MSG_RESULT([cannot compile test program])
233 else
234 xfree=`./conftest`
235
236 case "${xfree}" in
237 *XFree86*)
238 ;;
239
240 *) AC_MSG_RESULT([not a XFree86 server])
241 ;;
242 esac
243
244 case "${xfree}" in
245
246 *version=4*)
247 AC_MSG_RESULT([XFree 4.x family])
daywalker418c7482002-10-16 13:09:26 +0000248 AC_DEFINE([XFREE_4], 1, [Define to 1 if you're using XFree 4.x])
gobry3b777892002-04-04 09:18:39 +0000249 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000250 # haaaaaaack!
251 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
gobrye721a522002-03-22 13:38:30 +0000252 ;;
253
254 *version=3*)
255 AC_MSG_RESULT([XFree 3.x family])
daywalker418c7482002-10-16 13:09:26 +0000256 AC_DEFINE([XFREE_3], 1, [Define to 1 if you're using XFree86 3.x])
sewardj19e6a4d2002-05-22 11:58:25 +0000257 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
sewardj8ce25cd2002-06-18 01:05:58 +0000258 # haaaaaaack!
259 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000260 ;;
261
262 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
sewardj8ce25cd2002-06-18 01:05:58 +0000263 # haaaaaaack!
264 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-3.supp"
265 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000266 ;;
267 esac
268 fi
269
270 rm -f conftest conftest.c
271fi
272
sewardj5b754b42002-06-03 22:53:35 +0000273# does this compiler support -mpreferred-stack-boundary=2 ?
274AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
275
276CFLAGS="-mpreferred-stack-boundary=2"
277
278AC_TRY_COMPILE(, [
279
280int main () { return 0 ; }
281
282],
283[
284PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
285AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
286], [
287PREFERRED_STACK_BOUNDARY=""
288AC_MSG_RESULT([no])
289])
290
291AC_SUBST(PREFERRED_STACK_BOUNDARY)
292
293
294
sewardjde4a1d02002-03-22 01:27:54 +0000295# Checks for header files.
296AC_HEADER_STDC
sewardja83005f2002-06-13 16:07:51 +0000297AC_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 +0000298
299# Checks for typedefs, structures, and compiler characteristics.
sewardjde4a1d02002-03-22 01:27:54 +0000300AC_TYPE_UID_T
301AC_TYPE_OFF_T
302AC_TYPE_SIZE_T
303AC_HEADER_TIME
304
305# Checks for library functions.
306AC_FUNC_MEMCMP
307AC_FUNC_MMAP
308AC_TYPE_SIGNAL
309
310AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
311
gobrye721a522002-03-22 13:38:30 +0000312AC_OUTPUT(
sewardjde4a1d02002-03-22 01:27:54 +0000313 Makefile
njn25cac76cb2002-09-23 11:21:57 +0000314 valgrind.spec
njn254d542432002-09-23 16:09:39 +0000315 docs/Makefile
316 tests/Makefile
njnc2e7f482002-09-27 08:44:17 +0000317 tests/vg_regtest
njn251ffab942002-09-23 16:42:19 +0000318 tests/unused/Makefile
njn254d542432002-09-23 16:09:39 +0000319 include/Makefile
njn7a6e7462002-11-09 17:53:30 +0000320 auxprogs/Makefile
njn25ab726032002-09-23 16:24:41 +0000321 coregrind/Makefile
322 coregrind/demangle/Makefile
323 coregrind/docs/Makefile
324 coregrind/valgrind
njn25cac76cb2002-09-23 11:21:57 +0000325 addrcheck/Makefile
njnf2df9b52002-10-04 11:35:47 +0000326 addrcheck/tests/Makefile
njn7da8fa72002-10-03 10:38:40 +0000327 addrcheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000328 memcheck/Makefile
329 memcheck/tests/Makefile
330 memcheck/docs/Makefile
331 cachegrind/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000332 cachegrind/tests/Makefile
333 cachegrind/docs/Makefile
njnf2df9b52002-10-04 11:35:47 +0000334 cachegrind/cg_annotate
njn25cac76cb2002-09-23 11:21:57 +0000335 corecheck/Makefile
336 corecheck/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000337 corecheck/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000338 helgrind/Makefile
njnf2df9b52002-10-04 11:35:47 +0000339 helgrind/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000340 helgrind/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000341 lackey/Makefile
njnf2df9b52002-10-04 11:35:47 +0000342 lackey/tests/Makefile
njn83157fc2002-10-03 10:07:34 +0000343 lackey/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000344 none/Makefile
345 none/tests/Makefile
njn9bc8c002002-10-02 13:49:13 +0000346 none/docs/Makefile
njn25cac76cb2002-09-23 11:21:57 +0000347)
gobry3b777892002-04-04 09:18:39 +0000348
349cat<<EOF
350
351Using the following suppressions by default:
352
353 ${DEFAULT_SUPP}
354EOF
355
356cat<<EOF > default.supp
357# This is a generated file, composed of the following suppression rules:
358#
359# ${DEFAULT_SUPP}
360#
361
362EOF
363
364for file in ${DEFAULT_SUPP} ; do
365 cat ${srcdir}/$file >> default.supp
366done