- `m4/ax_lib_readline.m4` was already aware of "$with_readline".
Move the entire handling of the parameter inside the AX_LIB_READLINE
macro.
This lets our fork of ax_lib_readline.m4 further deviate from upstream
version, but it's already so different that this is no new problem.
- raise an error if the user requested --with-readline=libreadline|libedit
but the library was not found.
- only allow yes|no for --with-nmcli argument. But still default to
"yes", which will always require one libreadline library to be
detected. In particular, don't automatically disable nmcli if
libreadline is not available, because building without nmcli
should be an explicit choice. That is like before.
- update the "$with_readline" variable for the "auto" case to reflect
what was detected.
This commit provides support for --with-readline=auto|libreadline|libedit|none option
for the configure script.
It allows building the NetworkManager's nmcli tool with libedit instead
of libreadline.
With --with-readline=auto the system looks for any eligible readline library
to use.
Moreover, in this commit all required defines are provided (e.g.
HAVE_EDITLINE_READLINE) to allow correct buil of the code.
The add_history function is available on both - libreadline and libedit.
The read difference between those two libraries is that for libedit the
history_set_history_state is missing.
On that basis one can assess if we do have history from libreadline or
from libedit.
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.
The macro always overwrites LIBS and the result is that every binary
links against libreadline.
Instead, save the library to READLINE_LIBS.
See also: 94274c6fcd ('build: fix wrongly linking against libreadline in all applications')
Fixes: af360238be ('m4/ax_lib_readline.m4: Update after running aclocal')
Every Makefile in the subtrees would include -lreadline
as part of LIBS, hence every application would link against
the library.
This was broken since we added 'm4/ax_lib_readline.m4'.
Fixes: 29297f8531
Not all distros build their readline linked with a termcap library,
since apps are (apparently) supposed to choose one for themselves
and explicitly link to it when using readline. So add some checks
to figure out whether readline is already linked, and if not, prefer
ncurses since we use that for nmtui already.
ax_lib_readline based off:
http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html