From a8a567fc46fca4ca10a23016e2fe9055669b9102 Mon Sep 17 00:00:00 2001
From: Ian Dinwoodie <dinwoodieian@gmail.com>
Date: Wed, 29 Jan 2020 23:58:13 -0500
Subject: [PATCH] Ncursesw should link with tinfow.

This patch is a response to issue #219.

Signed-off-by: Ian Dinwoodie <dinwoodieian@gmail.com>
---
 config/readline_check_version.m4 | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/config/readline_check_version.m4 b/config/readline_check_version.m4
index 567bfbd4..01e61c28 100644
--- a/config/readline_check_version.m4
+++ b/config/readline_check_version.m4
@@ -7,10 +7,23 @@ AC_MSG_CHECKING(which library has the termcap functions)
 _bash_needmsg=
 fi
 AC_CACHE_VAL(bash_cv_termcap_lib,
-[AC_CHECK_LIB(]$curses_lib_name[, tgetent, bash_cv_termcap_lib=lib]$curses_lib_name[,
-  [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
-    [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
-      bash_cv_termcap_lib=gnutermcap)])])])
+[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
+if test "$curses_lib_name" = "ncursesw"; then
+	[AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
+		[AC_CHECK_LIB(tinfow, tgetent, bash_cv_termcap_lib=libtinfow)]
+	)]
+elif test "$curses_lib_name" = "ncurses"; then
+	[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
+		[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo)]
+	)]
+elif test "$curses_lib_name" = "curses"; then
+	[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses)]
+else
+	[AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
+		bash_cv_termcap_lib=gnutermcap
+	)]
+fi
+)])
 if test "X$_bash_needmsg" = "Xyes"; then
 AC_MSG_CHECKING(which library has the termcap functions)
 fi
@@ -19,6 +32,9 @@ if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
 LDFLAGS="$LDFLAGS -L./lib/termcap"
 TERMCAP_LIB="./lib/termcap/libtermcap.a"
 TERMCAP_DEP="./lib/termcap/libtermcap.a"
+elif test $bash_cv_termcap_lib = libtinfow; then
+TERMCAP_LIB=-ltinfow
+TERMCAP_DEP=
 elif test $bash_cv_termcap_lib = libtinfo; then
 TERMCAP_LIB=-ltinfo
 TERMCAP_DEP=
