--- a/configure
+++ b/configure
@@ -10972,7 +10972,7 @@ if test "${ac_cv_lib_curses_tputs+set}" 
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcurses  $LIBS"
+#LIBS="-lcurses  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -11108,7 +11108,8 @@ if test $ac_cv_lib_ncurses_tputs = yes; 
 #define HAVE_LIBNCURSES 1
 _ACEOF
 
-  LIBS="-lncurses $LIBS"
+#  LIBS="-lncurses $LIBS"
+CURSES=-lncurses
 
 fi
 
@@ -11125,7 +11126,7 @@ if test "${ac_cv_lib_readline_main+set}"
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lreadline  $LIBS"
+LIBS="-lreadline $CURSES $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -11182,7 +11183,8 @@ if test $ac_cv_lib_readline_main = yes; 
 #define HAVE_LIBREADLINE 1
 _ACEOF
 
-  LIBS="-lreadline $LIBS"
+#  LIBS="-lreadline $LIBS"
+CURSES="$CURSES -lreadline"
 
 fi
 
@@ -11342,7 +11344,7 @@ if test "${ac_cv_lib_readline_rl_complet
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lreadline  $LIBS"
+LIBS="-lreadline $CURSES $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -11405,7 +11407,7 @@ if test $ac_cv_lib_readline_rl_completio
 #define HAVE_LIBREADLINE 1
 _ACEOF
 
-  LIBS="-lreadline $LIBS"
+#  LIBS="-lreadline $LIBS"
 
 fi