m4/my_lib_readline: Fix check for additional libraries

MY_LIB_READLINE tries each readline-compatible library with a sequence
of additional libraries, starting with none.  If the check with none
fails, all the others checks reuse the cached result, and also fail.
Broken in commit 1cbda2c7d "client: Rewrite readline configuration",
v4.4.0.

Avoid the unwanted chaching.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-12-29 05:56:12 +01:00
parent 882379f883
commit e23d0f6259

View file

@ -1,31 +1,39 @@
AC_DEFUN([MY_LIB_READLINE], [
have_readline=no
AC_CACHE_CHECK([for a readline compatible library],
my_cv_lib_readline, [
my_lib_readline_save_LIBS="$LIBS"
for readline_lib in readline edit editline; do
for termcap_lib in "" termlib termcap curses ncurses; do
AC_CHECK_LIB([$readline_lib], [add_history],
[have_readline=yes; break 2], [], [$termcap_lib])
if test -z "$termcap_lib"; then
my_cv_lib_readline="-l$readline_lib"
else
my_cv_lib_readline="-l$readline_lib -l$termcap_lib"
fi
LIBS="$my_cv_lib_readline $my_lib_readline_save_LIBS"
AC_LINK_IFELSE([AC_LANG_CALL([], [add_history])],
[break 2], [my_cv_lib_readline=no])
done
done
])
if test "$have_readline" = yes; then
AC_CHECK_HEADER([readline/readline.h], [], [have_readline=no],
if test "$my_cv_lib_readline" != no; then
AC_CHECK_HEADER([readline/readline.h], [], [my_cv_lib_readline=no],
[AC_INCLUDES_DEFAULT])
AC_CHECK_HEADER([readline/history.h], [], [have_readline=no],
fi
if test "$my_cv_lib_readline" != no; then
AC_CHECK_HEADER([readline/history.h], [], [my_cv_lib_readline=no],
[AC_INCLUDES_DEFAULT])
fi
if test "$have_readline" = yes; then
if test "x$termcap_lib" != x; then
LIBS="-l$termcap_lib $LIBS"
fi
LIBS="-l$readline_lib $LIBS"
if test "$my_cv_lib_readline" = no; then
LIBS="$my_lib_readline_save_LIBS"
else
AC_DEFINE([HAVE_LIBREADLINE], [1],
[Define if you have libreadline])
fi
])
AC_DEFUN([MY_WITH_READLINE],
[
AC_DEFUN([MY_WITH_READLINE], [
AC_ARG_WITH([readline],
[AS_HELP_STRING([--with-readline],
[support fancy command line editing @<:@default=check@:>@])],
@ -33,8 +41,12 @@ AC_DEFUN([MY_WITH_READLINE],
[with_readline=check])
if test "x$with_readline" != xno; then
MY_LIB_READLINE
if test "x$have_readline$with_readline" = xnoyes; then
if test "x$my_cv_lib_readline$with_readline" = xnoyes; then
AC_MSG_FAILURE([--with-readline was given, but test for readline failed])
fi
with_readline="$have_readline"
if test "$my_cv_lib_readline" = no; then
with_readline=no
else
with_readline=yes
fi
fi])