diff --git a/src/modules/readline/configure.in b/src/modules/readline/configure.in
index 3f50a2174310a9a3740f2bdee65d02ec463dbd3d..e1570857789bc9939753391500d3aa22f7c6f69a 100644
--- a/src/modules/readline/configure.in
+++ b/src/modules/readline/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.4 1998/09/20 08:33:42 hubbe Exp $
+# $Id: configure.in,v 1.5 1999/02/08 04:57:27 mast Exp $
 AC_INIT(readlinemod.c)
 AC_CONFIG_HEADER(readline_machine.h)
 AC_ARG_WITH(readline,[  --with(out)-readline   support command line editing],[],[with_readline=yes])
@@ -34,8 +34,16 @@ if test x$with_readline = xyes ; then
 
   if test $ac_cv_header_readline_h = yes -o $ac_cv_header_readline_readline_h = yes ; then
     if test $ac_cv_header_history_h = yes -o $ac_cv_header_history_history_h = yes -o $ac_cv_header_readline_history_h = yes ; then
-      AC_CHECK_LIB(termcap, tputs)
-      AC_CHECK_LIB(readline, readline)
+      AC_CHECK_LIB(readline, tputs, : , : )
+      if test $ac_cv_lib_readline_tputs = no ; then
+        AC_CHECK_LIB(termcap, tputs)
+        if test $ac_cv_lib_termcap_tputs = no ; then
+          AC_CHECK_LIB(ncurses, tputs)
+        fi
+      fi
+      if test $ac_cv_lib_readline_tputs = yes -o x$ac_cv_lib_termcap_tputs = xyes -o x$ac_cv_lib_ncurses_tputs = xyes ; then
+        AC_CHECK_LIB(readline, readline)
+      fi
     fi
   fi
 fi
diff --git a/src/modules/readline/readlinemod.c b/src/modules/readline/readlinemod.c
index d4658869e7111ec61419ba8dfa847679bd517c2d..8dc9b6ab7579f28698ce4df4d59f4715463ea26f 100644
--- a/src/modules/readline/readlinemod.c
+++ b/src/modules/readline/readlinemod.c
@@ -13,14 +13,10 @@
 #include "pike_macros.h"
 #include "threads.h"
 
-RCSID("$Id: readlinemod.c,v 1.10 1998/09/06 17:30:07 grubba Exp $");
+RCSID("$Id: readlinemod.c,v 1.11 1999/02/08 04:57:28 mast Exp $");
 
 #include <errno.h>
 
-#ifndef HAVE_LIBTERMCAP
-#undef HAVE_LIBREADLINE
-#endif
-
 #if !defined(HAVE_READLINE_H) && !defined(HAVE_READLINE_READLINE_H)
 #undef HAVE_LIBREADLINE
 #endif