1 dnl Search for libfailmalloc to use for testing
2 AC_DEFUN([CHECK_FAILMALLOC],[dnl
3 dnl Libtool sets the default library paths
6 failmalloc_requested= dnl Either implicitly or explicitly
7 AC_ARG_WITH(failmalloc, [ --with-failmalloc=PATH use Failmalloc for tests], [
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=""
15 failmalloc_search_path="$withval"
18 ], [failmalloc_search_path="$sys_lib_search_path_spec"]
20 libfailmalloc_file=libfailmalloc.so.0
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"
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"], [])
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
43 if test -n "$path_provided"; then
44 AC_MSG_ERROR([$libfailmalloc_file was not found at $failmalloc_search_path])
46 if test x"$cross_compiling" != x"no"; then
47 AC_MSG_RESULT([no (cross compiling)])
53 AC_SUBST(FAILMALLOC_PATH)
54 AM_CONDITIONAL(USE_FAILMALLOC, [test x"$FAILMALLOC_PATH" != x])