1 dnl This macro will check for the presence of the readline library.
2 dnl To get it into the aclocal.m4 dnl file, do this:
3 dnl aclocal -I . --verbose
5 dnl The --verbose will show all of the files that are searched
8 AC_DEFUN([wi_LIB_READLINE], [
9 dnl check for the readline.h header file
11 AC_CHECK_HEADER(readline/readline.h)
13 if test "$ac_cv_header_readline_readline_h" = yes; then
14 dnl check the readline version
16 cat > conftest.$ac_ext <<EOF
18 #include <readline/readline.h>
19 wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR
22 wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION *\([[0-9\]][[0-9\]]*\) *\([[0-9\]][[0-9\]]*\)$/\1.\2/p")
25 if test -n "$wi_READLINE_VERSION"; then
26 wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.')
27 wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*$\)')
28 if test $wi_MINOR -lt 10; then
29 wi_MINOR=$(expr $wi_MINOR \* 10)
31 wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR)
33 wi_READLINE_VERSION=-1
36 dnl check for the readline library
39 # Note: $LIBCURSES is permitted to be empty.
41 for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
43 AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE])
45 LIBS="$ac_save_LIBS $LIBREADLINE"
50 #include <readline/readline.h>
54 rl_function_of_keyseq(NULL, NULL, NULL);
56 wi_cv_lib_readline=yes
63 if test "$wi_cv_lib_readline" = yes; then
65 AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline])