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