m4: ax_lib_readline.m4: Use readline libraries when linking add_history test program

Up till now the AC_LANG_CALL() was just checking if program which
uses the add_history call can be correctly linked without passing
required libraries (e.g. -libreadline to LIBS variable).

This commit fixes this issue as now the add_history can be found as it
is now available in any of passed libs.
This commit is contained in:
Lukasz Majewski 2021-03-12 19:37:53 +01:00 committed by Thomas Haller
parent 11d59f81cf
commit 552e00990d
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -94,11 +94,15 @@ AC_DEFUN([AX_LIB_READLINE], [
AC_DEFINE(HAVE_LIBREADLINE, 1,
[Define if you have a readline compatible library])
AC_CHECK_HEADERS(readline.h readline/readline.h)
ORIG_LIBS="$LIBS"
LIBS="$ORIG_LIBS $ax_cv_lib_readline"
AC_CACHE_CHECK([whether readline supports history],
ax_cv_lib_readline_history, [
ax_cv_lib_readline_history="no"
AC_LINK_IFELSE([AC_LANG_CALL([], [add_history])], [ax_cv_lib_readline_history="yes"])
])
LIBS=$ORIG_LIBS
if test "$ax_cv_lib_readline_history" = "yes"; then
AC_DEFINE(HAVE_READLINE_HISTORY, 1,
[Define if your readline library has \`add_history'])