sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | # Process this file with autoconf to produce a configure script. |
| 2 | AC_INIT(vg_clientmalloc.c) |
| 3 | AM_CONFIG_HEADER(config.h) |
sewardj | a5abdaa | 2002-04-15 16:01:47 +0000 | [diff] [blame] | 4 | AM_INIT_AUTOMAKE(valgrind, 20020414) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 5 | |
gobry | b0ed467 | 2002-03-27 20:58:58 +0000 | [diff] [blame] | 6 | AM_MAINTAINER_MODE |
| 7 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 8 | # Checks for programs. |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 9 | CFLAGS="" |
| 10 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 11 | AC_PROG_LN_S |
| 12 | AC_PROG_CC |
| 13 | AC_PROG_CPP |
| 14 | AC_PROG_RANLIB |
| 15 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 16 | # Check for the compiler support |
| 17 | if test "${GCC}" != "yes" ; then |
| 18 | AC_MSG_ERROR([Valgrind relies on GCC to be compiled]) |
| 19 | fi |
| 20 | |
daywalker | 48ccca5 | 2002-04-15 00:31:58 +0000 | [diff] [blame] | 21 | # some older automake's don't have it so try something on our own |
| 22 | ifdef([AM_PROG_AS],[AM_PROG_AS], |
| 23 | [ |
gobry | 1be1985 | 2002-03-26 20:44:55 +0000 | [diff] [blame] | 24 | AS="${CC}" |
| 25 | AC_SUBST(AS) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 26 | |
gobry | 1be1985 | 2002-03-26 20:44:55 +0000 | [diff] [blame] | 27 | ASFLAGS="" |
| 28 | AC_SUBST(ASFLAGS) |
daywalker | 48ccca5 | 2002-04-15 00:31:58 +0000 | [diff] [blame] | 29 | ]) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 30 | |
| 31 | # This variable will collect the individual suppression files |
| 32 | # depending on the results of autoconf |
| 33 | |
| 34 | DEFAULT_SUPP="" |
| 35 | |
| 36 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 37 | # We don't want gcc 2.7 |
| 38 | AC_MSG_CHECKING([for a supported version of gcc]) |
| 39 | |
| 40 | gcc_version=`${CC} --version` |
| 41 | |
| 42 | case "${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 | ;; |
| 51 | esac |
| 52 | |
| 53 | # does this compiler support -mpreferred-stack-boundary=2 ? |
| 54 | AC_MSG_CHECKING([for extra compiler options]) |
| 55 | |
| 56 | CFLAGS="-mpreferred-stack-boundary=2" |
| 57 | |
| 58 | AC_TRY_COMPILE(, [ |
| 59 | |
| 60 | int main () { return 0 ; } |
| 61 | |
| 62 | ], |
| 63 | [ |
| 64 | PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2" |
| 65 | AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY]) |
| 66 | ], [ |
| 67 | PREFERRED_STACK_BOUNDARY="" |
| 68 | AC_MSG_RESULT([none]) |
| 69 | ]) |
| 70 | |
| 71 | AC_SUBST(PREFERRED_STACK_BOUNDARY) |
| 72 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 73 | CFLAGS="-Winline -Wall -Wshadow -O -fomit-frame-pointer -g" |
| 74 | AC_SUBST(CFLAGS) |
| 75 | |
| 76 | # Checks for the platform |
| 77 | AC_CANONICAL_HOST |
| 78 | |
| 79 | AC_MSG_CHECKING([for a supported CPU]) |
| 80 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 81 | case "${host_cpu}" in |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 82 | 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 | ;; |
| 90 | esac |
| 91 | |
| 92 | AC_MSG_CHECKING([for a supported OS]) |
| 93 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 94 | case "${host_os}" in |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 95 | *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 | ;; |
| 103 | esac |
| 104 | |
| 105 | |
| 106 | # Ok, this is linux. Check the kernel version |
| 107 | AC_MSG_CHECKING([for the kernel version]) |
| 108 | |
| 109 | kernel=`uname -r` |
| 110 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 111 | case "${kernel}" in |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 112 | 2.4.*) |
| 113 | AC_MSG_RESULT([2.4 family (${kernel})]) |
| 114 | AC_DEFINE(KERNEL_2_4) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 115 | ;; |
| 116 | |
| 117 | 2.2.*) |
| 118 | AC_MSG_RESULT([2.2 family (${kernel})]) |
| 119 | AC_DEFINE(KERNEL_2_2) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 120 | ;; |
| 121 | |
| 122 | *) |
| 123 | AC_MSG_RESULT([unsupported (${kernel})]) |
| 124 | AC_MSG_ERROR([Valgrind works on kernels 2.2 and 2.4]) |
| 125 | ;; |
| 126 | esac |
| 127 | |
| 128 | AC_SUBST(DEFAULT_SUPP) |
| 129 | |
| 130 | |
| 131 | # Ok, this is linux. Check the kernel version |
| 132 | AC_MSG_CHECKING([the glibc version]) |
| 133 | |
| 134 | glibc="" |
| 135 | |
| 136 | AC_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 | ], |
| 144 | glibc="2.1") |
| 145 | |
| 146 | AC_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 | ], |
| 154 | glibc="2.2") |
| 155 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 156 | case "${glibc}" in |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 157 | 2.1) |
| 158 | AC_MSG_RESULT(2.1 family) |
| 159 | AC_DEFINE(GLIBC_2_1) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 160 | DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.1.supp" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 161 | ;; |
| 162 | |
| 163 | 2.2) |
| 164 | AC_MSG_RESULT(2.2 family) |
| 165 | AC_DEFINE(GLIBC_2_2) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 166 | DEFAULT_SUPP="${DEFAULT_SUPP} glibc-2.2.supp" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 167 | ;; |
| 168 | |
| 169 | *) |
| 170 | AC_MSG_RESULT(unsupported version) |
| 171 | AC_MSG_ERROR([Valgrind requires the glibc version 2.1 or 2.2]) |
| 172 | ;; |
| 173 | esac |
| 174 | |
| 175 | # try to detect the XFree version |
| 176 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 177 | AC_PATH_X |
| 178 | |
| 179 | if test "${no_x}" != 'yes' ; then |
| 180 | |
| 181 | AC_MSG_CHECKING([XFree version]) |
| 182 | |
| 183 | cat<<EOF > conftest.c |
| 184 | #include <X11/Xlib.h> |
| 185 | |
| 186 | int 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 | } |
| 196 | EOF |
| 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) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 218 | DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp" |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 219 | ;; |
| 220 | |
| 221 | *version=3*) |
| 222 | AC_MSG_RESULT([XFree 3.x family]) |
| 223 | AC_DEFINE(XFREE_3) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 224 | DEFAULT_SUPP="${DEFAULT_SUPP} xfree-4.supp" |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 225 | ;; |
| 226 | |
| 227 | *) AC_MSG_RESULT([unknown XFree86 server (${xfree})]) |
| 228 | ;; |
| 229 | esac |
| 230 | fi |
| 231 | |
| 232 | rm -f conftest conftest.c |
| 233 | fi |
| 234 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 235 | # Checks for header files. |
| 236 | AC_HEADER_STDC |
| 237 | AC_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. |
| 240 | AC_C_CONST |
| 241 | AC_TYPE_UID_T |
| 242 | AC_TYPE_OFF_T |
| 243 | AC_TYPE_SIZE_T |
| 244 | AC_HEADER_TIME |
| 245 | |
| 246 | # Checks for library functions. |
| 247 | AC_FUNC_MEMCMP |
| 248 | AC_FUNC_MMAP |
| 249 | AC_TYPE_SIGNAL |
| 250 | |
| 251 | AC_CHECK_FUNCS([floor memchr memset mkdir strchr strdup strpbrk strrchr strstr]) |
| 252 | |
gobry | e721a52 | 2002-03-22 13:38:30 +0000 | [diff] [blame] | 253 | AC_OUTPUT( |
| 254 | valgrind |
| 255 | valgrind.spec |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 256 | Makefile |
| 257 | docs/Makefile |
| 258 | tests/Makefile |
| 259 | demangle/Makefile) |
gobry | 3b77789 | 2002-04-04 09:18:39 +0000 | [diff] [blame] | 260 | |
| 261 | cat<<EOF |
| 262 | |
| 263 | Using the following suppressions by default: |
| 264 | |
| 265 | ${DEFAULT_SUPP} |
| 266 | EOF |
| 267 | |
| 268 | cat<<EOF > default.supp |
| 269 | # This is a generated file, composed of the following suppression rules: |
| 270 | # |
| 271 | # ${DEFAULT_SUPP} |
| 272 | # |
| 273 | |
| 274 | EOF |
| 275 | |
| 276 | for file in ${DEFAULT_SUPP} ; do |
| 277 | cat ${srcdir}/$file >> default.supp |
| 278 | done |