• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl Search for libfailmalloc to use for testing
2AC_DEFUN([CHECK_FAILMALLOC],[dnl
3  dnl Libtool sets the default library paths
4  LT_INIT([win32-dll])
5  path_provided=
6  failmalloc_requested=  dnl Either implicitly or explicitly
7  AC_ARG_WITH(failmalloc, [  --with-failmalloc=PATH  use Failmalloc for tests], [
8      failmalloc_requested=1
9      if test x"$withval" = "x" -o x"$withval" = x"yes"; then
10        failmalloc_search_path="$sys_lib_search_path_spec"
11      elif test x"$withval" = x"no"; then
12        failmalloc_search_path=""
13        failmalloc_requested=
14      else
15        failmalloc_search_path="$withval"
16        path_provided=1
17      fi
18    ], [failmalloc_search_path="$sys_lib_search_path_spec"]
19  )
20  libfailmalloc_file=libfailmalloc.so.0
21  FAILMALLOC_PATH=
22
23  dnl Skip the check if we're cross-compiling, unless the user explicitly requested it
24  if test x"$cross_compiling" = x"no" -o x"$failmalloc_requested" = x"1"; then
25    dnl Check if the argument is a directory
26    for d in $failmalloc_search_path; do
27        AC_CHECK_FILE([$d/$libfailmalloc_file], [
28          FAILMALLOC_PATH="$d/$libfailmalloc_file"
29          break
30        ], [])
31    done
32    if test -z "$FAILMALLOC_PATH" -a -n "$path_provided"; then
33      dnl Check if the argument is a file
34      AC_CHECK_FILE([$failmalloc_search_path], [FAILMALLOC_PATH="$failmalloc_search_path"], [])
35    fi
36  fi
37
38  AC_MSG_CHECKING([for failmalloc])
39  dnl Make sure AC_CHECK_FILE didn't find a directory by mistake
40  if test -n "$FAILMALLOC_PATH" -a -f "$FAILMALLOC_PATH"; then
41    AC_MSG_RESULT([yes])
42  else
43    if test -n "$path_provided"; then
44      AC_MSG_ERROR([$libfailmalloc_file was not found at $failmalloc_search_path])
45    else
46      if test x"$cross_compiling" != x"no"; then
47        AC_MSG_RESULT([no (cross compiling)])
48      else
49        AC_MSG_RESULT([no])
50      fi
51    fi
52  fi
53  AC_SUBST(FAILMALLOC_PATH)
54  AM_CONDITIONAL(USE_FAILMALLOC, [test x"$FAILMALLOC_PATH" != x])
55])
56
57