3 dnl This macro checks for the presence of the readline library.
4 dnl It works also in cross-compilation environment.
6 dnl To get it into the aclocal.m4 dnl file, do this:
7 dnl aclocal -I . --verbose
9 dnl The --verbose will show all of the files that are searched
12 AC_DEFUN([wi_LIB_READLINE], [
13 dnl check for the readline.h header file
15 AC_CHECK_HEADER(readline/readline.h)
17 if test "$ac_cv_header_readline_readline_h" = yes; then
18 dnl check the readline version
20 AC_MSG_CHECKING([for GNU Readline version])
21 cat > conftest.$ac_ext <<EOF
23 #include <readline/readline.h>
24 wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR
27 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")
30 if test -n "$wi_READLINE_VERSION"; then
31 wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.')
32 wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)')
33 if test $wi_MINOR -lt 10; then
34 wi_MINOR=$(expr $wi_MINOR \* 10)
36 wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR)
38 wi_READLINE_VERSION=-1
40 AC_MSG_RESULT($wi_READLINE_VERSION)
42 dnl check for the readline library
45 # Note: $LIBCURSES is permitted to be empty.
47 for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
49 AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE])
51 LIBS="$ac_save_LIBS $LIBREADLINE"
56 #include <readline/readline.h>
59 int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */
62 wi_cv_lib_readline=yes
69 if test "$wi_cv_lib_readline" = yes; then
71 AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline])