Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Check for libtinfo after libncurses #1322

Closed
wants to merge 1 commit into from

3 participants

@geoff-codes

@gentoo: This seems like a possible [unusual, or mis-] configuration of your system ncurses library?

From the ncurses INSTALL file:

--with-termlib[=XXX]
When building the ncurses library, organize as two parts: the curses library (libncurses) and the low-level terminfo library (libtinfo). This is done to accommodate applications that use only the latter.

But I'd put it more alone the lines of:

Configure in a way such that -lncurses will be missing symbols unless you also -ltinfo.

Fish needs more than just libtinfo to (fully) function properly, as it's largely a curses-based shell.
What's properly needed, if configured this way, is both the tinfo and curses libs, not one or the other.

Rather than use the configuration option above, the typical configuration today is to symlink your installed ncurses headers and libraries as lib[n]curses[t][w], libtinfo[t][w], and/or libtic[t][w], as compatibility requires.
See here, for instance.

However, configure.ac should be looking for libncursesw before libncurses.
I believe this had been added at one point, but it seems to possibly have been inadvertently reverted.

@zanchey @ridiculousfish Re: #1271, perhaps Gentoo should be a candidate distro for this option?

@zanchey
Collaborator

I'm also curious to the rationale behind this change; I couldn't find any easy way to understand what has changed in Gentoo.

As far as I can tell, fish doesn't actually use more than libtinfo. I'm not 100% certain, but I think the only curses functions required are setupterm, del_curterm, tparm, and tputs.

I'm not sure about libncursesw. I can't see that it has ever been checked for; I also can't see that there are wide-character versions of any of the above functions, so there would be little point in linking against it.

@geoff-codes

I'm not sure about libncursesw.

I had thought it made it in with an early PR of mine. Its not all that important; except if a default install of nucrses has been configured with --enable-widec then everything gets appended with a w. Most (all?) distros will just symlink/rename for this, so it would be unlikely to be of much consequence.

I think the only curses functions required are setupterm, del_curterm, tparm, and tputs.

I believe the WINCH functions are derived from nucrses as well? (There's a fallback SIGWINCH handler, but I'm not sure how that works exactly.)

As far as I can tell, fish doesn't actually use more than libtinfo.

In terms of 'which libraries resolve which symbol names,', I think you're right. My super-scientific rationale for

Fish needs more than just libtinfo to (fully) function properly

Is really just along the lines of:

  • I certainly can't seem to get it to build with only the tinfo library.
  • When you build ncurses, all the utils (tic infocmp etc) will only link libtinfo, but anything that actually does anything graphically also link libncurses.

Anyway, if this were merged, I think it should be in the form of: (with libtinfo in the last part), no?
AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])

@jer-gentoo

ncurses has properly supported building a separate terminal info library for more than a decade, and Gentoo Linux added optional support for this configuration in 2013 (see https://bugs.gentoo.org/show_bug.cgi?id=452532). A tracker bug (https://bugs.gentoo.org/show_bug.cgi?id=457530) was set up to aid in getting existing packages to support this entirely valid but apparently still novel configuration.

You are looking for a setupterm() in libncurses and libcurses, which is fine for most configurations, and fish doesn't use anything special in terms of line drawing or other advanced stuff that [n]curses support. With a split libncurses/libtinfo configuration, setupterm() is not available in libncurses, but in libtinfo, and fish runs fine when linked solely against libtinfo.

The correct check (with my patch) is therefore to first try libncurses, then libtinfo and then libcurses, which does this:

1) For systems without the split libncurses/libtinfo, this changes nothing.
2) For systems with that split configuration, the configure script will fail to find setupterm() in libncurses, but will succeed with libtinfo.
3) For systems without ncurses, it will try libcurses instead.
4) Failing 3), configure will fail.

I don't see what wide ncurses (libncursesw) has to do with this - it's a different issue altogether that isn't caused/exemplified/fixed by/with this patch.

@zanchey
Collaborator

OK, that's what I was trying to establish. (To quote: "ah, Gentoo".) I agree that ncursesw is a separate issue and I'll merge this shortly.

Really we should be using pkg-config for ncurses (which tells me that the right way to link on my system is with -lncurses -ltinfo), but supporting that fully across platforms which don't have pkg-config seems to be hard.

@zanchey zanchey closed this in 5f11854
@zanchey zanchey added this to the next-minor milestone
@zanchey zanchey self-assigned this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2014
  1. @jer-gentoo
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  configure.ac
View
2  configure.ac
@@ -408,7 +408,7 @@ AC_DEFINE(
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
-AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
+AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
AC_SEARCH_LIBS( [nan], [m], [AC_DEFINE( [HAVE_NAN], [1], [Define to 1 if you have the nan function])] )
if test x$local_gettext != xno; then
Something went wrong with that request. Please try again.