1 dnl Check for readline and dependencies
2 dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 dnl This file is free software, distributed under the terms of the GNU
5 dnl General Public License. As a special exception to the GNU General
6 dnl Public License, this file may be distributed as part of a program
7 dnl that contains a configuration script generated by Autoconf, under
8 dnl the same distribution terms as the rest of that program.
10 dnl Defines HAVE_LIBREADLINE to 1 if a working readline setup is
11 dnl found, and sets @LIBREADLINE@ to the necessary libraries.
13 AC_DEFUN([GNUPG_CHECK_READLINE],
16 AC_HELP_STRING([--with-readline=DIR],
17 [look for the readline library in DIR]),
18 [_do_readline=$withval],[_do_readline=yes])
20 if test "$_do_readline" != "no" ; then
21 if test -d "$withval" ; then
22 CPPFLAGS="${CPPFLAGS} -I$withval/include"
23 LDFLAGS="${LDFLAGS} -L$withval/lib"
26 for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do
27 _readline_save_libs=$LIBS
28 _combo="-lreadline${_termcap:+ $_termcap}"
31 AC_MSG_CHECKING([whether readline via \"$_combo\" is present and sane])
33 AC_LINK_IFELSE(AC_LANG_PROGRAM([
35 #include <readline/readline.h>
36 #include <readline/history.h>
38 rl_completion_func_t *completer;
39 add_history("foobar");
41 rl_inhibit_completion=0;
42 rl_attempted_completion_function=NULL;
43 rl_completion_matches(NULL,NULL);
44 ]),_found_readline=yes,_found_readline=no)
46 AC_MSG_RESULT([$_found_readline])
48 LIBS=$_readline_save_libs
50 if test $_found_readline = yes ; then
51 AC_DEFINE(HAVE_LIBREADLINE,1,
52 [Define to 1 if you have a fully functional readline library.])
53 AC_SUBST(LIBREADLINE,$_combo)
59 unset _readline_save_libs