5.0.3 release candidate 1 - was: Re: [GRASS5] Roadmap: Numbering

Glynn Clements glynn.clements at virgin.net
Thu Aug 28 02:09:25 EDT 2003


Markus Neteler wrote:

> > >>Concerning the readline support:
> > >
> > >>When adding -lncurses the test passes. Could be add -lncurses to
> > >>the config script (how) for the test?
> > >
> > >
> > > http://grass.itc.it/pipermail/grass5/2003-August/006104.html
> > >
> > 
> > The biggest problem is not that you need to specify additional ldflags
> > before configure, but that it isn't documented.
> > 
> > Would it not be possible to have
> > - --with-readline=(curses|ncurses|termcap|tinfo), and when it is not
> > specified, get the dependency information from libreadline?
> > 
> > In either case, the error message should mention that you need (to
> > specify) a library to use.
> > 
> [...]
> 
> A quick check how the "R" project solves the same problem:
> 
> config.log:
>  configure:11627: checking for rl_callback_read_char in -lreadline
>  configure:11658: gcc -o conftest -O3 -I/usr/local/include -L/usr/local/lib conftest.c -lreadline  -ldl -lncurses -lm  >&5
>  configure:11661: $? = 0

> This indicates (to me) that $LIBS already contains -lncurses so
> that the -lreadline test passes.
> 
> The relevant part in configure.ac looks like this:
> [...]
> ## AC_CHECK_LIBM computes LIBM but does not add to LIBS, hence we do
> ## the following as well.
> AC_CHECK_LIB(m, sin)
> AC_CHECK_LIB(ncurses, main, [],
>              AC_CHECK_LIB(termcap, main, [],
>                           AC_CHECK_LIB(termlib, main)))
> AC_CHECK_LIB(dl, dlopen)
> 
> ## Readline.
> if test "${use_readline}" = yes; then
>   AC_CHECK_LIB(readline, rl_callback_read_char)
>   use_readline="${ac_cv_lib_readline_rl_callback_read_char}"
> fi
> [...]

It appears that R simply accumulates libraries; every library which is
found is unconditionally used in every subsequent check. For GRASS,
this could result in every single module having a dependency upon all
of TIFF, JPEG, PNG, X11, Motif, GD, GDBM, ..., which would be rather
undesirable.

As for simply using curses:

1. Curses might not include the termcap functions (tgetnum() etc). 
These functions are lower-level than curses itself, and may be in a
separate library (e.g. libtermcap or libtinfo).

2. Curses may provide these functions, but provide versions which use
the "wrong" database (e.g. provide versions which use termcap, when
the system's only adequate terminal database is terminfo, or
vice-versa).

3. Curses may be overkill; if suitable implementations are available
from libtermcap or libtinfo, those should be used instead, as they are
much smaller and simpler (and may have fewer dependencies) than
curses.

4. It's possible that some versions of readline *might* use different
functions (i.e. the terminfo interface, tigetnum() etc).

Autoconf is designed to produce *an* answer; where there are several
answers, it's completely incapable of determining which is the *right*
answer. This isn't a problem in cases where there's only likely to be
one answer, but the termcap functions definitely aren't such a case;
it is common for them to be available from multiple libraries, and the
implementations are often different (i.e. termcap vs terminfo).

OTOH, the current situation regarding readline support for r.mapcalc
is basically: if it works, good, if it doesn't, tough. While
arbitrarily adding plausible libraries isn't ideal, it won't actually
make the situation any worse in this case (other than the inevitable
problem of increased complexity, namely that you exchange simple bug
reports for complex bug reports).

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list