blob: 62359e7dc1a87fcc961289a15141a45c77b20aca [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001# Process this file with autoconf to produce a configure script.
2AC_INIT(vg_clientmalloc.c)
3AM_CONFIG_HEADER(config.h)
sewardja5abdaa2002-04-15 16:01:47 +00004AM_INIT_AUTOMAKE(valgrind, 20020414)
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
14AC_PROG_RANLIB
15
gobrye721a522002-03-22 13:38:30 +000016# Check for the compiler support
17if test "${GCC}" != "yes" ; then
18 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
19fi
20
daywalker48ccca52002-04-15 00:31:58 +000021# some older automake's don't have it so try something on our own
22ifdef([AM_PROG_AS],[AM_PROG_AS],
23[
gobry1be19852002-03-26 20:44:55 +000024AS="${CC}"
25AC_SUBST(AS)
gobry3b777892002-04-04 09:18:39 +000026
gobry1be19852002-03-26 20:44:55 +000027ASFLAGS=""
28AC_SUBST(ASFLAGS)
daywalker48ccca52002-04-15 00:31:58 +000029])
gobry3b777892002-04-04 09:18:39 +000030
31# This variable will collect the individual suppression files
32# depending on the results of autoconf
33
34DEFAULT_SUPP=""
35
36
gobrye721a522002-03-22 13:38:30 +000037# We don't want gcc 2.7
38AC_MSG_CHECKING([for a supported version of gcc])
39
40gcc_version=`${CC} --version`
41
42case "${gcc_version}" in
43 gcc-2.7.*)
44 AC_MSG_RESULT([no (${gcc_version})])
45 AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
46 ;;
47
48 *)
49 AC_MSG_RESULT([ok (${gcc_version})])
50 ;;
51esac
52
53# does this compiler support -mpreferred-stack-boundary=2 ?
54AC_MSG_CHECKING([for extra compiler options])
55
56CFLAGS="-mpreferred-stack-boundary=2"
57
58AC_TRY_COMPILE(, [
59
60int main () { return 0 ; }
61
62],
63[
64PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2"
65AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY])
66], [
67PREFERRED_STACK_BOUNDARY=""
68AC_MSG_RESULT([none])
69])
70
71AC_SUBST(PREFERRED_STACK_BOUNDARY)
72
sewardjde4a1d02002-03-22 01:27:54 +000073CFLAGS="-Winline -Wall -Wshadow -O -fomit-frame-pointer -g"
74AC_SUBST(CFLAGS)
75
76# Checks for the platform
77AC_CANONICAL_HOST
78
79AC_MSG_CHECKING([for a supported CPU])
80
gobrye721a522002-03-22 13:38:30 +000081case "${host_cpu}" in
sewardjde4a1d02002-03-22 01:27:54 +000082 i?86)
83 AC_MSG_RESULT([ok (${host_cpu})])
84 ;;
85
86 *)
87 AC_MSG_RESULT([no (${host_cpu})])
88 AC_MSG_ERROR([Valgrind is ix86 specific. Sorry])
89 ;;
90esac
91
92AC_MSG_CHECKING([for a supported OS])
93
gobrye721a522002-03-22 13:38:30 +000094case "${host_os}" in
sewardjde4a1d02002-03-22 01:27:54 +000095 *linux*)
96 AC_MSG_RESULT([ok (${host_os})])
97 ;;
98
99 *)
100 AC_MSG_RESULT([no (${host_os})])
101 AC_MSG_ERROR([Valgrind is Linux specific. Sorry])
102 ;;
103esac
104
105
106# Ok, this is linux. Check the kernel version
107AC_MSG_CHECKING([for the kernel version])
108
109kernel=`uname -r`
110
gobrye721a522002-03-22 13:38:30 +0000111case "${kernel}" in
sewardjde4a1d02002-03-22 01:27:54 +0000112 2.4.*)
113 AC_MSG_RESULT([2.4 family (${kernel})])
114 AC_DEFINE(KERNEL_2_4)
sewardjde4a1d02002-03-22 01:27:54 +0000115 ;;
116
117 2.2.*)
118 AC_MSG_RESULT([2.2 family (${kernel})])
119 AC_DEFINE(KERNEL_2_2)
sewardjde4a1d02002-03-22 01:27:54 +0000120 ;;
121
122 *)
123 AC_MSG_RESULT([unsupported (${kernel})])
124 AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4])
125 ;;
126esac
127
128AC_SUBST(DEFAULT_SUPP)
129
130
131# Ok, this is linux. Check the kernel version
132AC_MSG_CHECKING([the glibc version])
133
134glibc=""
135
136AC_EGREP_CPP([GLIBC_21], [
137#include <features.h>
138#ifdef __GNU_LIBRARY__
139 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
140 GLIBC_21
141 #endif
142#endif
143],
144glibc="2.1")
145
146AC_EGREP_CPP([GLIBC_22], [
147#include <features.h>
148#ifdef __GNU_LIBRARY__
149 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2)
150 GLIBC_22
151 #endif
152#endif
153],
154glibc="2.2")
155
gobrye721a522002-03-22 13:38:30 +0000156case "${glibc}" in
sewardjde4a1d02002-03-22 01:27:54 +0000157 2.1)
158 AC_MSG_RESULT(2.1 family)
159 AC_DEFINE(GLIBC_2_1)
gobry3b777892002-04-04 09:18:39 +0000160 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000161 ;;
162
163 2.2)
164 AC_MSG_RESULT(2.2 family)
165 AC_DEFINE(GLIBC_2_2)
gobry3b777892002-04-04 09:18:39 +0000166 DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp"
sewardjde4a1d02002-03-22 01:27:54 +0000167 ;;
168
169 *)
170 AC_MSG_RESULT(unsupported version)
171 AC_MSG_ERROR([Valgrind requires the glibc version 2.1 or 2.2])
172 ;;
173esac
174
175# try to detect the XFree version
176
gobrye721a522002-03-22 13:38:30 +0000177AC_PATH_X
178
179if test "${no_x}" != 'yes' ; then
180
181 AC_MSG_CHECKING([XFree version])
182
183 cat<<EOF > conftest.c
184#include <X11/Xlib.h>
185
186int main (int argc, char * argv [])
187{
188 Display * display = XOpenDisplay (NULL);
189
190 if (display) {
191 printf ("%s version=%d\n", ServerVendor (display), VendorRelease (display));
192 }
193
194 return 0;
195}
196EOF
197
198 ${CC} -o conftest conftest.c -I${x_includes} -L${x_libraries} -lX11 >&5 2>&1
199
200 if test "$?" != 0 ; then
201 AC_MSG_RESULT([cannot compile test program])
202 else
203 xfree=`./conftest`
204
205 case "${xfree}" in
206 *XFree86*)
207 ;;
208
209 *) AC_MSG_RESULT([not a XFree86 server])
210 ;;
211 esac
212
213 case "${xfree}" in
214
215 *version=4*)
216 AC_MSG_RESULT([XFree 4.x family])
217 AC_DEFINE(XFREE_4)
gobry3b777892002-04-04 09:18:39 +0000218 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000219 ;;
220
221 *version=3*)
222 AC_MSG_RESULT([XFree 3.x family])
223 AC_DEFINE(XFREE_3)
gobry3b777892002-04-04 09:18:39 +0000224 DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp"
gobrye721a522002-03-22 13:38:30 +0000225 ;;
226
227 *) AC_MSG_RESULT([unknown XFree86 server (${xfree})])
228 ;;
229 esac
230 fi
231
232 rm -f conftest conftest.c
233fi
234
sewardjde4a1d02002-03-22 01:27:54 +0000235# Checks for header files.
236AC_HEADER_STDC
237AC_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])
238
239# Checks for typedefs, structures, and compiler characteristics.
240AC_C_CONST
241AC_TYPE_UID_T
242AC_TYPE_OFF_T
243AC_TYPE_SIZE_T
244AC_HEADER_TIME
245
246# Checks for library functions.
247AC_FUNC_MEMCMP
248AC_FUNC_MMAP
249AC_TYPE_SIGNAL
250
251AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr])
252
gobrye721a522002-03-22 13:38:30 +0000253AC_OUTPUT(
254 valgrind
255 valgrind.spec
sewardjde4a1d02002-03-22 01:27:54 +0000256 Makefile
257 docs/Makefile
258 tests/Makefile
259 demangle/Makefile)
gobry3b777892002-04-04 09:18:39 +0000260
261cat<<EOF
262
263Using the following suppressions by default:
264
265 ${DEFAULT_SUPP}
266EOF
267
268cat<<EOF > default.supp
269# This is a generated file, composed of the following suppression rules:
270#
271# ${DEFAULT_SUPP}
272#
273
274EOF
275
276for file in ${DEFAULT_SUPP} ; do
277 cat ${srcdir}/$file >> default.supp
278done