zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: Link with curses if (and even) if it doesn't provide tgetent
Date: Wed, 23 Oct 2019 19:18:01 +0200	[thread overview]
Message-ID: <CAKc7PVDVrbGPDz_juHBrnH_tYe_d8_5yUgrnOy3CTTjCeNFgsw@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVDN0WSyyOQdBnOVtgSppTrOTzeGoPYyJTHyNg9qMCsbAA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2256 bytes --]

Hello,
I've revised the patch. It has been seriously upgraded:
- the checks against the termcap & terminfo functions is being ran
again explicitly before deciding to link with ncurses,
- more functions are being checked, namely all that I've found tests
in the configure for, i.e.: besides tgetent and tigetflag, also
tigetstr and tigetnum,
- I've also extended the normal- i.e.: previous test with the tigetstr
function, as it seems to be most important, because it's the function
that's being tested for when --with-term-lib=... is being used.

Besides, the update adding tinfow to the searched libs is preserved.

I think that the patch is important. Ncurses is being drilled out of
termcap & terminfo functions, and this means that the zsh/curses
module will never be built.

On Thu, 3 Oct 2019 at 16:39, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hello,
> I've noticed that on Gentoo the zsh built doesn't include the curses
> module. Closer look revealed the cause: the ncurses libraries
> (ncursesw and ncurses) don't provide the call tgetent (nor tigetflag),
> only tinfo does provide it. I guess this is the next step in splitting
> libtinfo out of ncurses.
>
> But this means that the binary can be linked to both ncurses and
> tinfo. I've also checked that linking against such tgetent-lacking
> ncurses and termcap works with no problems.
>
> The patch does:
> - it allows the normal flow of the checks with no changes,
> - in the "if we need to ignore ncurses" check it adds, in case of
> positive resolution of the test, an additional check that verifies for
> initscr() in any of ncursesw, ncurses, curses and if this check is
> positive, it then allows to link against that found curses library,
> - it also adds libtinfow (side to libtinfo) to the terminal libraries
> searched, as such library exists on the Gentoo system.
>
> This way the zsh/curses module builds OK.
>
> I attach the git-format-patch file.
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org



-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: 0001-configure-Try-to-link-with-a-curses-library-if-it-do.patch.txt --]
[-- Type: text/plain, Size: 4377 bytes --]

From 5b7d43abe3f01d3a72301f9b44faf28cafe5da27 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Wed, 23 Oct 2019 19:06:40 +0200
Subject: [PATCH] =?UTF-8?q?configure=20=E2=80=93=C2=A0Try=20to=20link=20wi?=
 =?UTF-8?q?th=20a=20curses=20library=20if=20it=20doesn't=20contain=20the?=
 =?UTF-8?q?=20tercamp=20&=20terminfo=20functions?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 configure.ac | 57 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index b31b1d958..8fd4d452f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -774,7 +774,7 @@ AS_HELP_STRING([--with-term-lib=LIBS],[search space-separated LIBS for terminal
   termcap_curses_order="$withval"
   AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order])
 else
-  termcap_curses_order="$ncursesw_test $ncurses_test tinfo termcap curses"
+  termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses"
 fi],
 [case "$host_os" in
   solaris*)
@@ -783,7 +783,7 @@ fi],
    DL_EXT="${DL_EXT=sl}"
    termcap_curses_order="Hcurses $ncursesw_test $ncurses_test curses termcap" ;;
   *)
-   termcap_curses_order="$ncursesw_test $ncurses_test tinfo termcap curses" ;;
+   termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses" ;;
 esac])dnl
 
 AH_TEMPLATE([ZSH_NO_XOPEN],
@@ -807,6 +807,8 @@ dnl That's so that on systems where termcap and [n]curses are
 dnl both available and both contain termcap functions, while
 dnl only [n]curses contains terminfo functions, we only link against
 dnl [n]curses.
+LIBS_save_pre_term="$LIBS"
+AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order])
 AC_SEARCH_LIBS(tigetflag, [$termcap_curses_order])
 AC_SEARCH_LIBS(tgetent, [$termcap_curses_order],
   true,
@@ -831,7 +833,56 @@ AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses,
   zsh_cv_ignore_ncurses=no
   ;;
   *)
-  zsh_cv_ignore_ncurses=yes
+    dnl The lack of -lncurses in the $LIBS might be the result of passing
+    dnl --with-term-lib=^ncurses option. To address this, a test for the tgetent
+    dnl and other functions is ran here, possibly for the second time, just to
+    dnl ensure that the ncurses library doesn't have them.
+    LIBS_save="$LIBS"
+    dnl Remember (the values are used later, around line 3005) and remove the cache
+    ac_cv_search_tigetstr_SAVE="$ac_cv_search_tigetstr"
+    ac_cv_search_tigetnum_SAVE="$ac_cv_search_tigetnum"
+    ac_cv_search_tigetflag_SAVE="$ac_cv_search_tigetflag"
+    ac_cv_search_tgetent_SAVE="$ac_cv_search_tgetent"
+    unset ac_cv_search_tigetstr ac_cv_search_tigetnum ac_cv_search_tigetflag ac_cv_search_tgetent
+    LIBS="$LIBS_save_pre_term"
+
+    dnl Run the checks for all four used terminal functions
+    AC_SEARCH_LIBS(tigetstr, [ncursesw ncurses curses])
+    AC_SEARCH_LIBS(tigetnum, [ncursesw ncurses curses])
+    AC_SEARCH_LIBS(tigetflag, [ncursesw ncurses curses])
+    AC_SEARCH_LIBS(tgetent, [ncursesw ncurses curses])
+    LIBS_result="$LIBS"
+
+    LIBS="$LIBS_save"
+    dnl Restore the cache
+    ac_cv_search_tigetstr="$ac_cv_search_tigetstr_SAVE"
+    ac_cv_search_tigetnum="$ac_cv_search_tigetnum_SAVE"
+    ac_cv_search_tigetflag="$ac_cv_search_tigetflag_SAVE"
+    ac_cv_search_tgetent="$ac_cv_search_tgetent_SAVE"
+
+    case $LIBS_result in
+      *-lncurses*|*-lcurses*)
+        dnl Yes we need to ignore ncurses, its tgetent or tigetflag might
+        dnl conflict with the one from the selected terminal library
+        zsh_cv_ignore_ncurses=yes
+        ;;
+      *)
+        dnl If the tgetent nor tigetflag weren't found in the libncurses*.so, then
+        dnl there will be no conflict with the other terminal library selected (e.g.
+        dnl libtinfo) and it's possible to link ncurses provided that it is working
+        dnl - it is here verified that it has initscr() function to check that
+        AC_SEARCH_LIBS(initscr, [ncursesw ncurses curses])
+        case $LIBS in
+          *-lncurses*|*-lcurses*)
+            dnl No need to ignore curses - it is working and it doesn't
+            dnl have tgetent nor tigetflag
+            zsh_cv_ignore_ncurses=no
+          ;;
+          *)
+            zsh_cv_ignore_ncurses=yes
+          ;;
+        esac
+    esac
   ;;
 esac])
 
-- 
2.21.0


  reply	other threads:[~2019-10-23 17:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 14:39 Sebastian Gniazdowski
2019-10-23 17:18 ` Sebastian Gniazdowski [this message]
2019-10-24 13:01   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVDVrbGPDz_juHBrnH_tYe_d8_5yUgrnOy3CTTjCeNFgsw@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).