2
dnl Copyright (C) 2002-2005 Sam Steingold, Bruno Haible
3
dnl This file is free software, distributed under the terms of the GNU
4
dnl General Public License. As a special exception to the GNU General
5
dnl Public License, this file may be distributed as part of a program
6
dnl that contains a configuration script generated by Autoconf, under
7
dnl the same distribution terms as the rest of that program.
11
AC_DEFUN([CL_READLINE],[dnl
12
AC_ARG_WITH([readline],
13
AC_HELP_STRING([--with-readline],[use readline (default is YES, if present)]),
14
[ac_cv_use_readline=$withval], [ac_cv_use_readline=default])
15
ac_cv_have_readline=no
16
if test "$ac_cv_use_readline" = "no" ; then
17
AC_MSG_NOTICE([not checking for readline])
19
AC_REQUIRE([CL_TERMCAP])dnl
20
if test $ac_cv_search_tgetent != no ; then
21
AC_LIB_LINKFLAGS_BODY(readline)
22
ac_save_CPPFLAGS="$CPPFLAGS"
23
CPPFLAGS="$CPPFLAGS $INCREADLINE"
24
AC_CHECK_HEADERS(readline/readline.h)
25
if test "$ac_cv_header_readline_readline_h" != yes; then
26
CPPFLAGS="$ac_save_CPPFLAGS"
27
else # have <readline/readline.h> => check library
29
LIBS="$LIBREADLINE $LIBS"
30
AC_CHECK_FUNC(readline)dnl do not define HAVE_READLINE
31
AC_CHECK_FUNCS(rl_filename_completion_function)
32
if test "$ac_cv_func_readline" != yes ; then
34
CPPFLAGS="$ac_save_CPPFLAGS"
35
else # have readline => check modern features
36
if test $ac_cv_func_rl_filename_completion_function = no ;
37
then RL_FCF=filename_completion_function
38
else RL_FCF=rl_filename_completion_function
40
dnl READLINE_CONST is necessary for C++ compilation of stream.d
41
CL_PROTO([filename_completion_function], [
44
#include <readline/readline.h>
45
],[char* ${RL_FCF} (char *, int);], [char* ${RL_FCF}();],
46
cl_cv_proto_readline_const) ],
47
[extern char* ${RL_FCF}($cl_cv_proto_readline_const char*, int);])
48
AC_CHECK_DECLS([rl_already_prompted, rl_readline_name, rl_gnu_readline_p],,,
50
#include <readline/readline.h>])
51
AC_MSG_CHECKING(for a modern readline)
52
if test "$ac_cv_have_decl_rl_already_prompted" = yes \
53
-a "$ac_cv_have_decl_rl_gnu_readline_p" = yes; then
54
dnl LIBREADLINE has been added to LIBS.
55
AC_MSG_RESULT([found a modern GNU readline])
56
ac_cv_have_readline=yes
58
AC_MSG_RESULT([readline is too old and will not be used])
60
CPPFLAGS="$ac_save_CPPFLAGS"
65
if test "$ac_cv_have_readline" = yes; then
66
AC_DEFINE_UNQUOTED(READLINE_FILE_COMPLETE,${RL_FCF},[The readline built-in filename completion function, either rl_filename_completion_function() or filename_completion_function()])
67
AC_DEFINE_UNQUOTED(READLINE_CONST,$cl_cv_proto_readline_const,[declaration of filename_completion_function() needs const in the first argument])
68
AC_DEFINE(HAVE_READLINE,,[have a working modern GNU readline])
69
elif test "$ac_cv_use_readline" = yes; then
70
AC_MSG_FAILURE([despite --with-readline, GNU readline was not found (try --with-libreadline-prefix)])