Add readline.
[pspp] / m4 / readline.m4
1 # readline.m4 serial 1
2 dnl Copyright (C) 2005 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 AC_DEFUN([gl_FUNC_READLINE],
8 [
9   AC_LIBSOURCES([readline.c, readline.h])
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 libreadline and define LIBREADLINE, LTLIBREADLINE and
16   dnl INCREADLINE accordingly.
17   AC_LIB_LINKFLAGS_BODY([readline])
18
19   dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
20   dnl because if the user has installed libreadline and not disabled its use
21   dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
22   dnl will then succeed.
23   am_save_CPPFLAGS="$CPPFLAGS"
24   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
25
26   AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
27     gl_cv_lib_readline=no
28     am_save_LIBS="$LIBS"
29     LIBS="$LIBS $LIBREADLINE"
30     AC_TRY_LINK([#include <stdio.h>
31 #include <readline/readline.h>],
32       [readline((char*)0);],
33       gl_cv_lib_readline=yes)
34     LIBS="$am_save_LIBS"
35   ])
36   if test "$gl_cv_lib_readline" = yes; then
37     AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline() library.])
38   fi
39   if test "$gl_cv_lib_readline" = yes; then
40     AC_MSG_CHECKING([how to link with libreadline])
41     AC_MSG_RESULT([$LIBREADLINE])
42   else
43     dnl If $LIBREADLINE didn't lead to a usable library, we don't need $INCREADLINE
44     dnl either.
45     CPPFLAGS="$am_save_CPPFLAGS"
46     LIBREADLINE=
47     LTLIBREADLINE=
48   fi
49   AC_SUBST(LIBREADLINE)
50   AC_SUBST(LTLIBREADLINE)
51
52   AC_CHECK_HEADERS(readline/readline.h)
53
54   if test $gl_cv_lib_readline = no; then
55     AC_LIBOBJ(readline)
56     gl_PREREQ_READLINE
57   fi
58 ])
59
60 # Prerequisites of lib/readline.c.
61 AC_DEFUN([gl_PREREQ_READLINE], [
62   :
63 ])