chiark / gitweb /
gpg agent threading bugs: Add some `xxx' comments.
[gnupg2.git] / m4 / readline.m4
1 dnl Check for readline and dependencies
2 dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 dnl
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.
9 dnl
10 dnl Defines HAVE_LIBREADLINE to 1 if a working readline setup is
11 dnl found, and sets @LIBREADLINE@ to the necessary libraries.
12
13
14 AC_DEFUN([GNUPG_CHECK_READLINE],
15 [
16   AC_ARG_WITH(readline,
17      AC_HELP_STRING([--with-readline=DIR],
18         [look for the readline library in DIR]),
19      [_do_readline=$withval],[_do_readline=yes])
20
21   gnupg_cv_have_readline=no
22   if test "$_do_readline" != "no" ; then
23      if test -d "$withval" ; then
24         CPPFLAGS="${CPPFLAGS} -I$withval/include"
25         LDFLAGS="${LDFLAGS} -L$withval/lib"
26      fi
27
28      for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do
29         _readline_save_libs=$LIBS
30         _combo="-lreadline${_termcap:+ $_termcap}"
31         LIBS="$LIBS $_combo"
32
33         AC_MSG_CHECKING([whether readline via \"$_combo\" is present and sane])
34
35         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
36 #include <stdio.h>
37 #include <readline/readline.h>
38 #include <readline/history.h>
39 ]],[[
40 rl_completion_func_t *completer;
41 add_history("foobar");
42 rl_catch_signals=0;
43 rl_inhibit_completion=0;
44 rl_attempted_completion_function=NULL;
45 rl_completion_matches(NULL,NULL);
46 ]])],[_found_readline=yes],[_found_readline=no])
47
48         AC_MSG_RESULT([$_found_readline])
49
50         LIBS=$_readline_save_libs
51
52         if test $_found_readline = yes ; then
53            AC_DEFINE(HAVE_LIBREADLINE,1,
54               [Define to 1 if you have a fully functional readline library.])
55            AC_SUBST(LIBREADLINE,$_combo)
56            gnupg_cv_have_readline=yes
57            break
58         fi
59      done
60
61      unset _termcap
62      unset _readline_save_libs
63      unset _combo
64      unset _found_readline
65   fi
66 ])dnl