From: Markus Armbruster Date: Tue, 29 Dec 2020 04:56:12 +0000 (+0100) Subject: m4/my_lib_readline: Fix check for additional libraries X-Git-Tag: v4.4.1~50 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=55ff9cce0975f6cdd75922719d3d1653ea20c2ef 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 --- diff --git a/m4/my_lib_readline.m4 b/m4/my_lib_readline.m4 index 37fedec56..34452215c 100644 --- a/m4/my_lib_readline.m4 +++ b/m4/my_lib_readline.m4 @@ -1,40 +1,52 @@ AC_DEFUN([MY_LIB_READLINE], [ - have_readline=no - 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]) + 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 + 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 - 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_ARG_WITH([readline], - [AS_HELP_STRING([--with-readline], - [support fancy command line editing @<:@default=check@:>@])], - [], - [with_readline=check]) - if test "x$with_readline" != xno; then - MY_LIB_READLINE - if test "x$have_readline$with_readline" = xnoyes; then - AC_MSG_FAILURE([--with-readline was given, but test for readline failed]) - fi - with_readline="$have_readline" - fi]) +AC_DEFUN([MY_WITH_READLINE], [ + AC_ARG_WITH([readline], + [AS_HELP_STRING([--with-readline], + [support fancy command line editing @<:@default=check@:>@])], + [], + [with_readline=check]) + if test "x$with_readline" != xno; then + MY_LIB_READLINE + if test "x$my_cv_lib_readline$with_readline" = xnoyes; then + AC_MSG_FAILURE([--with-readline was given, but test for readline failed]) + fi + if test "$my_cv_lib_readline" = no; then + with_readline=no + else + with_readline=yes + fi + fi])