If there is no libtermcap all the readline tests failed.
This inappropriately disabled some capabilities which exist.

Now test for readline in -lreadline, if not found there, try it
in -ltermcap only if not in -lreadline.  If both libraries are
required, there will need to be more work, but I'm not sure
under what conditions both libraries would be required.
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 47723de..7b24f37 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -275,9 +275,15 @@
 /* Define to 1 if you have the <libintl.h> header file. */
 #undef HAVE_LIBINTL_H
 
+/* Define to 1 if you have the `readline' library (-lreadline). */
+#undef HAVE_LIBREADLINE
+
 /* Define to 1 if you have the `resolv' library (-lresolv). */
 #undef HAVE_LIBRESOLV
 
+/* Define to 1 if you have the `termcap' library (-ltermcap). */
+#undef HAVE_LIBTERMCAP
+
 /* Define to 1 if you have the <libutil.h> header file. */
 #undef HAVE_LIBUTIL_H