From 7f986ab20ee38fc3b5c97da8ad1dbacb941ea57b Mon Sep 17 00:00:00 2001
From: Michael Sarahan <msarahan@gmail.com>
Date: Wed, 2 May 2018 11:31:57 -0500
Subject: [PATCH] Also look in libtinfo for tgetent

---
 configure    | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 configure.ac |  8 +++++---
 2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index a274b99..8b72d4d 100755
--- a/configure
+++ b/configure
@@ -12580,7 +12580,54 @@ _ACEOF
   LIBS="-ltermcap $LIBS"
 
 else
-  as_fn_error $? "libncurses, libcurses, or libtermcap is required!" "$LINENO" 5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5
+$as_echo_n "checking for tgetent in -ltinfo... " >&6; }
+if ${ac_cv_lib_tinfo_tgetent+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltinfo  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char tgetent ();
+int
+main ()
+{
+return tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_tinfo_tgetent=yes
+else
+  ac_cv_lib_tinfo_tgetent=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5
+$as_echo "$ac_cv_lib_tinfo_tgetent" >&6; }
+if test "x$ac_cv_lib_tinfo_tgetent" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBTINFO 1
+_ACEOF
+
+  LIBS="-ltinfo $LIBS"
+
+else
+  as_fn_error $? "libncurses, libcurses, libtermcap or libtinfo is required!" "$LINENO" 5
+
+fi
+
 
 fi
 
diff --git a/configure.ac b/configure.ac
index 1d02505..6462197 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,9 +47,11 @@ AC_PROG_AWK
 EL_MANTYPE
 
 AC_CHECK_LIB(ncurses, tgetent,,
-  [AC_CHECK_LIB(curses, tgetent,,
-    [AC_CHECK_LIB(termcap, tgetent,,
-      [AC_MSG_ERROR([libncurses, libcurses, or libtermcap is required!])]
+  [AC_CHECK_LIB(tinfo, tgetent,,
+    [AC_CHECK_LIB(curses, tgetent,,
+      [AC_CHECK_LIB(termcap, tgetent,,
+        [AC_MSG_ERROR([libncurses, libcurses, libtermcap or libtinfo is required!])]
+      )]
     )]
   )]
 )
-- 
2.19.1

