New module 'libsigsegv'.
[gnulib.git] / m4 / libsigsegv.m4
1 # libsigsegv.m4 serial 1
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_PREREQ(2.61)
10
11 AC_DEFUN([gl_LIBSIGSEGV],
12 [
13   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
14   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
15   AC_REQUIRE([AC_LIB_RPATH])
16
17   dnl Search for libsigsegv and define LIBSIGSEGV, LTLIBSIGSEGV and INCSIGSEGV
18   dnl accordingly.
19   AC_LIB_LINKFLAGS_BODY([sigsegv])
20
21   dnl Add $INCSIGSEGV to CPPFLAGS before performing the following checks,
22   dnl because if the user has installed libsigsegv and not disabled its use
23   dnl via --without-libsigsegv-prefix, he wants to use it.
24   gl_save_CPPFLAGS="$CPPFLAGS"
25   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCSIGSEGV])
26
27   AC_CACHE_CHECK([for libsigsegv], gl_cv_lib_sigsegv, [
28     gl_cv_lib_sigsegv="no, consider installing GNU libsigsegv"
29     gl_save_LIBS="$LIBS"
30     LIBS="$LIBS $LIBSIGSEGV"
31     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sigsegv.h>]],
32       [sigsegv_deinstall_handler();])],
33       [gl_cv_lib_sigsegv=yes])
34     LIBS="$gl_save_LIBS"
35   ])
36   if test "$gl_cv_lib_sigsegv" = yes; then
37     AC_DEFINE([HAVE_LIBSIGSEGV], 1,
38       [Define if you have the libsigsegv library.])
39     AC_MSG_CHECKING([how to link with libsigsegv])
40     AC_MSG_RESULT([$LIBSIGSEGV])
41   else
42     dnl If $LIBSIGSEGV didn't lead to a usable library, we don't need
43     dnl $INCSIGSEGV either.
44     CPPFLAGS="$gl_save_CPPFLAGS"
45     LIBSIGSEGV=
46     LTLIBSIGSEGV=
47   fi
48   AC_SUBST(LIBSIGSEGV)
49   AC_SUBST(LTLIBSIGSEGV)
50 ])