public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] configure: exit with an error if no termcap lib is installed
@ 2022-07-21  8:51 Christophe Lyon
  2022-07-22 20:35 ` Keith Seitz
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Lyon @ 2022-07-21  8:51 UTC (permalink / raw)
  To: gdb-patches

The termcap detection code in aclocal.m4 (BASH_CHECK_LIB_TERMCAP)
defaults to "gnutermcap" if none of the usual libraries is available
(termcap, tinfo, curses, ncurses, ncursesw).

Then it sets TERMCAP_LIB to "./lib/termcap/libtermcap.a", so it
expects that libtermcap.a is present under lib/termcap in the build
directory.

In fact, this is generally not the case (we do not manually install
libtermcap in the build tree), so it's better to stop with an error
message.
---
 readline/README                | 3 +++
 readline/readline/configure    | 2 +-
 readline/readline/configure.ac | 3 +--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/readline/README b/readline/README
index 54e1c72b197..20b12b6d8a9 100644
--- a/readline/README
+++ b/readline/README
@@ -16,3 +16,6 @@ update this file.
 Individual upstream readline patches can be directly imported using
 "git am".  You can see the current patch level by looking at
 readline/patchlevel.
+
+Local patches:
+- configure: exit with an error if no termcap lib is installed
diff --git a/readline/readline/configure b/readline/readline/configure
index 6ea4545e26f..b162eb374a1 100755
--- a/readline/readline/configure
+++ b/readline/readline/configure
@@ -6367,7 +6367,7 @@ if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
 	if test "$prefer_curses" = yes; then
 		TERMCAP_LIB=-lcurses
 	else
-		TERMCAP_LIB=-ltermcap	#default
+		as_fn_error $? "missing required termcap lib or equivalent" "$LINENO" 5
 	fi
 fi
 # Windows ncurses installation
diff --git a/readline/readline/configure.ac b/readline/readline/configure.ac
index 912c99b6575..4e2102e8198 100644
--- a/readline/readline/configure.ac
+++ b/readline/readline/configure.ac
@@ -207,8 +207,7 @@ if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
 	if test "$prefer_curses" = yes; then
 		TERMCAP_LIB=-lcurses
 	else
-		TERMCAP_LIB=-ltermcap	#default
-	fi
+		AC_MSG_ERROR(missing required termcap lib or equivalent)	fi
 fi
 # Windows ncurses installation
 if test "$TERMCAP_LIB" = "-lncurses"; then
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] configure: exit with an error if no termcap lib is installed
  2022-07-21  8:51 [PATCH] configure: exit with an error if no termcap lib is installed Christophe Lyon
@ 2022-07-22 20:35 ` Keith Seitz
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Seitz @ 2022-07-22 20:35 UTC (permalink / raw)
  To: Christophe Lyon, gdb-patches

Hi,

On 7/21/22 01:51, Christophe Lyon via Gdb-patches wrote:
> The termcap detection code in aclocal.m4 (BASH_CHECK_LIB_TERMCAP)
> defaults to "gnutermcap" if none of the usual libraries is available
> (termcap, tinfo, curses, ncurses, ncursesw).
> 
> Then it sets TERMCAP_LIB to "./lib/termcap/libtermcap.a", so it
> expects that libtermcap.a is present under lib/termcap in the build
> directory.
> 
> In fact, this is generally not the case (we do not manually install
> libtermcap in the build tree), so it's better to stop with an error
> message.

Thanks for the patch! I've been bitten by this once or twice, so I
welcome this change. Kudos, too, for following  the documented procedure
and updating readline/README.

Just two quick questions.

Regarding the patch itself, my (admittedly hasty) reading of BASH_CHECK_LIB_TERMCAP
(in aclocal.m4) is that if "--with-curses" is supplied and is not available,
bash_cv_termcap_lib will (also) be set to "gnutermcap". [More pedantically, if *no*
satisfactory library was found.]

The following if .. elif .. blocks essentially ignore "gnutermcap" when "prefer_curses"
is set, and the code falls through to the final "else," setting "TERMCAP_LIB=-lcurses".

Back in configure.ac, we have

> @@ -6367,7 +6367,7 @@ if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
>  	if test "$prefer_curses" = yes; then
>  		TERMCAP_LIB=-lcurses
>  	else
> -		TERMCAP_LIB=-ltermcap	#default
> +		as_fn_error $? "missing required termcap lib or equivalent" "$LINENO" 5
>  	fi
>  fi

I don't see how we can get TERMCAP_LIB set to "./lib/termcap/libtermcap.a"
and have prefer_curses. That appears to be dead code.

However, I think this still misses issuing the error when --with-curses is supplied.
Naively, one well-placed AC_MSG_ERROR should do it, but maybe readline
developers have a reason to do this?

Having said that, have you attempted to get this patch merged upstream? Above
questions aside, in the long run, it would be best to get this merged there. That
would greatly reduce the burden of maintaining/carrying/merging these local
patches.

Keith


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-22 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21  8:51 [PATCH] configure: exit with an error if no termcap lib is installed Christophe Lyon
2022-07-22 20:35 ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).