Make curses.h inclusion conditional as in the original patch #1012280.
Backported to 2.3.
diff --git a/configure.in b/configure.in
index 5c9fa3d..f5f4ffc 100644
--- a/configure.in
+++ b/configure.in
@@ -968,7 +968,11 @@
 AC_HEADER_MAJOR
 
 # On Solaris, term.h requires curses.h
-AC_CHECK_HEADERS(term.h,,,[#include <curses.h>])
+AC_CHECK_HEADER(term.h,,,[
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+])
 
 # checks for typedefs
 was_it_defined=no