cf36a3a6f943dcc79d50ed26e6630e742769ab01
[gnulib.git] / m4 / libsigsegv.m4
1 # libsigsegv.m4 serial 2
2 dnl Copyright (C) 2002-2003, 2008 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Bruno Haible, Sam Steingold.
8
9 AC_DEFUN([gl_LIBSIGSEGV],
10 [
11   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
12   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
13   AC_REQUIRE([AC_LIB_RPATH])
14
15   dnl Search for libsigsegv and define LIBSIGSEGV, LTLIBSIGSEGV and INCSIGSEGV
16   dnl accordingly.
17   AC_LIB_LINKFLAGS_BODY([sigsegv])
18
19   dnl Add $INCSIGSEGV to CPPFLAGS before performing the following checks,
20   dnl because if the user has installed libsigsegv and not disabled its use
21   dnl via --without-libsigsegv-prefix, he wants to use it.
22   gl_save_CPPFLAGS="$CPPFLAGS"
23   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCSIGSEGV])
24
25   AC_CACHE_CHECK([for libsigsegv], gl_cv_lib_sigsegv, [
26     gl_cv_lib_sigsegv="no, consider installing GNU libsigsegv"
27     gl_save_LIBS="$LIBS"
28     LIBS="$LIBS $LIBSIGSEGV"
29     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sigsegv.h>]],
30       [sigsegv_deinstall_handler();])],
31       [gl_cv_lib_sigsegv=yes])
32     LIBS="$gl_save_LIBS"
33   ])
34   if test "$gl_cv_lib_sigsegv" = yes; then
35     AC_DEFINE([HAVE_LIBSIGSEGV], 1,
36       [Define if you have the libsigsegv library.])
37     AC_MSG_CHECKING([how to link with libsigsegv])
38     AC_MSG_RESULT([$LIBSIGSEGV])
39   else
40     dnl If $LIBSIGSEGV didn't lead to a usable library, we don't need
41     dnl $INCSIGSEGV either.
42     CPPFLAGS="$gl_save_CPPFLAGS"
43     LIBSIGSEGV=
44     LTLIBSIGSEGV=
45   fi
46   AC_SUBST(LIBSIGSEGV)
47   AC_SUBST(LTLIBSIGSEGV)
48 ])