+dnl ** check for readline, for Hugs and hslibs' Readline
+dnl ncurses supersedes termcap and curses, but for compatibility,
+dnl we have to check for all...
+AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
+ AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
+ AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
+ HaveLibTermcap=NO; LibTermcap=not-installed)))
+
+if test $HaveLibTermcap = YES ; then
+ LIBS="-l$LibTermcap $LIBS"
+ AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
+fi
+
+if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
+ AC_DEFINE(HAVE_READLINE_LIBS,1)
+ LibsReadline="-lreadline -l$LibTermcap"
+else
+ AC_DEFINE(HAVE_READLINE_LIBS,0)
+ LibsReadline=
+fi
+AC_SUBST(LibsReadline)
+