zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: terminfo horor
@ 2003-12-18 17:05 Peter Stephenson
  2003-12-18 18:52 ` Mads Martin Joergensen
  2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
  0 siblings, 2 replies; 18+ messages in thread
From: Peter Stephenson @ 2003-12-18 17:05 UTC (permalink / raw)
  To: Zsh hackers list

Here's a first attempt.

1. Always check libraries for both basic termcap and terminfo operation.
There could possibly be problems where both are found and the linker
ends up with -ltermcap -lcurses.  If so, making --with-curses-terminfo
the default might help.  Please report experiences.  (All the systems
I've tested were happy with just one of the two.)

2. Always check for curses-related headers.  This should be benign.

3. Only compile the internals of terminfo if both curses.h and the
terminfo functions are available.  This is the neatest way of fixing
the ERR problems.  Cases where this doesn't work can be considered on
their own merit, as long as they can be tested for in configure.

4. Only compile, link and install the terminfo module at all if we
are going to make it useful.  There is no point in installing a
dynamically loaded module whose sole effect is to print "not available"
when loaded.  zmodload provides a portable way of testing for
the presence of modules, this is the right way to do it.

Successfully tested on Solaris 2.6, Solaris 8, Debian woody-ish (half
cocked distribution from the a magazine cover disk where it looks like
they just copied anything they could find, mumble), all with
curses and terminfo, and RedHat 9, without the appropriate curses
package, so no curses/terminfo.

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.42
diff -u -r1.42 zshconfig.ac
--- zshconfig.ac	13 Nov 2003 14:34:34 -0000	1.42
+++ zshconfig.ac	18 Dec 2003 16:39:15 -0000
@@ -542,8 +542,7 @@
 esac])dnl
 
 AC_SEARCH_LIBS(tgetent, [$termcap_curses_order])
-case "$LIBS" in
-*curses*)
+AC_SEARCH_LIBS(tigetflag, [$termcap_curses_order])
 AC_CHECK_HEADERS(curses.h, [],
 [AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris,
 AC_TRY_COMPILE([#include <curses.h>], [],
@@ -605,8 +604,7 @@
 #include <term.h>], [char **test = strnames; printf(*test);],
 AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
 AC_MSG_RESULT($strnames)
-]);;
-esac
+])
 
 dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require
 dnl libnsl (Network Services Library) to find yp_all
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.22
diff -u -r1.22 terminfo.c
--- Src/Modules/terminfo.c	14 Sep 2003 05:10:09 -0000	1.22
+++ Src/Modules/terminfo.c	18 Dec 2003 16:39:15 -0000
@@ -29,12 +29,18 @@
 
 #define USES_TERM_H 1
 #include "terminfo.mdh"
-#include "terminfo.pro"
 
+#if defined(HAVE_TIGETSTR) && defined(HAVE_CURSES_H)
+# define USE_TERMINFO_MODULE 1
+#else
+# undef USE_TERMINFO_MODULE
+#endif
+
+#include "terminfo.pro"
 static char terminfo_nam[] = "terminfo";
 
 /**/
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 
 /* The following two undefs are needed for Solaris 2.6 */
 # ifdef VINTR
@@ -44,9 +50,7 @@
 #  undef offsetof
 # endif
 
-# ifdef HAVE_CURSES_H
-#  include <curses.h>
-# endif
+# include <curses.h>
 # ifdef HAVE_TERM_H
 #  include <term.h>
 # endif
@@ -123,19 +127,19 @@
 }
 
 /**/
-#else /* !HAVE_TIGETSTR */
+#else /* !USE_TERMINFO_MODULE */
 
 #define bin_echoti bin_notavail
 
 /**/
-#endif /* !HAVE_TIGETSTR */
+#endif /* !USE_TERMINFO_MODULE */
 
 static struct builtin bintab[] = {
     BUILTIN("echoti", 0, bin_echoti, 1, -1, 0, NULL, NULL),
 };
 
 /**/
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 
 /* Empty dummy function for special hash parameters. */
 
@@ -361,7 +365,7 @@
 }
 
 /**/
-#endif /* HAVE_TIGETSTR */
+#endif /* USE_TERMINFO_MODULE */
 
 /**/
 int
@@ -374,7 +378,7 @@
 int
 boot_(Module m)
 {
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 # ifdef HAVE_SETUPTERM
     int errret;
 
@@ -394,7 +398,7 @@
 int
 cleanup_(Module m)
 {
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
     Param pm;
 
     if ((pm = (Param) paramtab->getnode(paramtab, terminfo_nam)) &&
Index: Src/Modules/terminfo.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v
retrieving revision 1.10
diff -u -r1.10 terminfo.mdd
--- Src/Modules/terminfo.mdd	23 Apr 2001 19:59:04 -0000	1.10
+++ Src/Modules/terminfo.mdd	18 Dec 2003 16:39:15 -0000
@@ -1,13 +1,13 @@
 name=zsh/terminfo
 
-link='if test "x$ac_cv_func_tigetstr" = xyes; then
+link='if test "x$ac_cv_func_tigetstr" = xyes -a "x$ac_cv_header_curses_h"; then
           if test "x$zsh_cv_shared_tigetstr" = xyes; then
 	      echo either
 	  else
 	      echo static
 	  fi
       else
-          echo either;
+          echo no;
       fi
 '
 load=yes

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: autoconf 2.5 (Re: PATCH: terminfo horor)
@ 2003-12-25 11:49 Borzenkov Andrey
  2004-01-08 12:25 ` Oliver Kiddle
  0 siblings, 1 reply; 18+ messages in thread
From: Borzenkov Andrey @ 2003-12-25 11:49 UTC (permalink / raw)
  To: 'Zsh hackers list'


> 
> The configure script is creating config.modules twice. Second time
> round when evaluating $link using the code in terminfo.mdd,
> $ac_cv_func_tigetstr was unset. It seems the configure script runs
> config.status. By running configure with --no-create, it was happy to
> build terminfo.so. Switching from autoconf 2.57 to 2.13 also solved the
> issue.
> 

looking in current zshconfig.ac it should not do it unless something else is
buggy.

> configure cats config.modules.sh into config.status using
> AC_OUTPUT_COMMANDS which is obsolete in autoconf 2.5. Using the new
> AC_CONFIG_COMMANDS doesn't help because variables like
> $ac_cv_func_tigetstr are still not set.
> 
> Does anyone understand the real point of config.status? Why does
> configure need to run it? I get the impression that it should contain
> just a duplicate of what is in config.modules as created and recreate
> it as opposed to rerunning scripts to derive its contents.
> 

I do not remember if it was me who put it in. Anyway

- autoconf 2.13 creates output files as the final step in running configure.
It is using environment variables CONFIG_FILES et al to pass information
which files are to be created further down

- autoconf 2.5 does not create anything in configure. Instead the sole point
of configure script is to create config.status - and it is config.status
that finally does (should do) the job of creating files, making
substitutions etc

apparently zshconfig.ac  tries to detect 2.5 by checking if
$CONFIG_FILES$CONFIG_HEADERS is empty; if it is it dumps config.modules.sh
into config.status. Hmm ... and runs it once more after that ... that looks
strange.

> We really ought to ditch support for autoconf 2.13 in the 4.1 branch.
> Not having a mixture will just make things simpler.
>

yes. 2.5 makes many things simpler and more consistent. OTOH I remember I
have tried to switch over to 2.5 way - doing job in config.status - and
failed for some reasons (do not remember exactly) - I guess I attempted to
move creation of all makefiles into config.status instead of creating
makefiles during make run. Also it definitely was not portable across
2.13/2.5

we could try it once more if 2.13 compatibility is not an issue.

-andrey


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: autoconf 2.5 (Re: PATCH: terminfo horor)
@ 2003-12-25 12:17 Borzenkov Andrey
  2004-01-05 12:34 ` Peter Stephenson
  0 siblings, 1 reply; 18+ messages in thread
From: Borzenkov Andrey @ 2003-12-25 12:17 UTC (permalink / raw)
  To: 'Zsh hackers list'


> >
> > The configure script is creating config.modules twice. Second time
> > round when evaluating $link using the code in terminfo.mdd,
> > $ac_cv_func_tigetstr was unset. It seems the configure script runs
> > config.status. By running configure with --no-create, it was happy to
> > build terminfo.so. Switching from autoconf 2.57 to 2.13 also solved the
> > issue.
> >
> 
> looking in current zshconfig.ac it should not do it unless something else
> is
> buggy.
> 
> > configure cats config.modules.sh into config.status using
> > AC_OUTPUT_COMMANDS which is obsolete in autoconf 2.5. Using the new
> > AC_CONFIG_COMMANDS doesn't help because variables like
> > $ac_cv_func_tigetstr are still not set.
> >
> > Does anyone understand the real point of config.status? Why does
> > configure need to run it? I get the impression that it should contain
> > just a duplicate of what is in config.modules as created and recreate
> > it as opposed to rerunning scripts to derive its contents.
> >
> 
> I do not remember if it was me who put it in. Anyway
> 

it was Bart in 17659,17661; if config.modules.sh is really called twice it
means we have 2.5 that does define those variables it is not supposed to.

The problem is cache variables are not defined in config.status nor is
config.cache garanteed to exist (2.5 does not cache by default). Meaning we
cannot rely on them and have to add some status variable that is set by
configure.

What I intended was to allow modules to supply "configure plugins" to make
whatever checks are needed; then configure could simply emit list modules to
build without generating (mostly identical) makefile fragments for every
module. Hmm ... it does look suspiciously similar to linux kernel, does not
it? :)

But it is near to impossible to create such plugins as shell scripts
(autoconf simply does not support it).

What is possible is to provide configure snippets and make Util/preconfig to
generate modules.m4 that includes them' modules.m4 would then be included by
zshconfig.ac. Unfortunately it is not easy to handle dependencies (i.e.
module added or removed after modules.m4 has been created). 

-andrey

> - autoconf 2.13 creates output files as the final step in running
> configure.
> It is using environment variables CONFIG_FILES et al to pass information
> which files are to be created further down
> 
> - autoconf 2.5 does not create anything in configure. Instead the sole
> point
> of configure script is to create config.status - and it is config.status
> that finally does (should do) the job of creating files, making
> substitutions etc
> 
> apparently zshconfig.ac  tries to detect 2.5 by checking if
> $CONFIG_FILES$CONFIG_HEADERS is empty; if it is it dumps config.modules.sh
> into config.status. Hmm ... and runs it once more after that ... that
> looks
> strange.
> 
> > We really ought to ditch support for autoconf 2.13 in the 4.1 branch.
> > Not having a mixture will just make things simpler.
> >
> 
> yes. 2.5 makes many things simpler and more consistent. OTOH I remember I
> have tried to switch over to 2.5 way - doing job in config.status - and
> failed for some reasons (do not remember exactly) - I guess I attempted to
> move creation of all makefiles into config.status instead of creating
> makefiles during make run. Also it definitely was not portable across
> 2.13/2.5
> 
> we could try it once more if 2.13 compatibility is not an issue.
> 
> -andrey


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: autoconf 2.5 (Re: PATCH: terminfo horor)
@ 2004-01-08 15:20 Borzenkov Andrey
  2004-01-08 16:11 ` Oliver Kiddle
  0 siblings, 1 reply; 18+ messages in thread
From: Borzenkov Andrey @ 2004-01-08 15:20 UTC (permalink / raw)
  To: 'Oliver Kiddle', 'Zsh hackers list'

> 
> > - autoconf 2.5 does not create anything in configure. Instead the sole
> point
> > of configure script is to create config.status - and it is config.status
> > that finally does (should do) the job of creating files, making
> > substitutions etc
> 
> Taking that, what we should probably do is have configure not create
> any config.modules files but have it do the work of config.modules.sh,
> putting the results directly into config.status in such a way that
> config.status will create the config.modules file.
> 

right; but to do it we need make configure puts into config.status (or as
init part of running config.modules.sh) information that modules may need to
make decision. Using cache variables was big mistake to start with :(

that was one reason I thought about those config.snippets.

doing that also allows to simply put commands for every module in it's own
configure section using init commands that *do* depend on cache variables,
like

AC_CONFIG_COMMANDS([zsh/terminfo], [
link='if test x$have_tigetstr = xyes; then
          if test x$shared_tigetstr = xyes; then
              echo either
          else
              echo static
          fi
      else
          echo either;
      fi
'
echo name=zsh/terminfo modfile=zsh/terminfo.mdd link=$link auto=yes load=no
>> ${CONFIG_MODULES}], [
have_tigetstr=$ac_cv_func_tigetstr
shared_tigetstr=$zsh_cv_shared_tigetstr
CONFIG_MODULES=$CONFIG_MODULES
])

where the last argument does initialization.

This can't be generated dynamically because tag (first argument) must be
static :(

So the options currently are to either put all needed variables from all
modules into config.modules.sh or run it out of configure.


-andrey


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: autoconf 2.5 (Re: PATCH: terminfo horor)
@ 2004-01-09  9:31 Borzenkov Andrey
  2004-01-14 16:01 ` Oliver Kiddle
  0 siblings, 1 reply; 18+ messages in thread
From: Borzenkov Andrey @ 2004-01-09  9:31 UTC (permalink / raw)
  To: 'Oliver Kiddle', 'Zsh hackers list'

> Andrey wrote:
> >
> > right; but to do it we need make configure puts into config.status (or
> as
> > init part of running config.modules.sh) information that modules may
> need to
> > make decision. Using cache variables was big mistake to start with :(
> 
> Why do the decisions modules make need to be re-made when config.status
> runs? Can't we just evaluate decisions once, in configure, and store the
> answers in config.status?
> 

well, that's what it always did actually :)

before starting to hack around configure we probably need to define the
final goal. For module build some options are

- module source location (in-tree vs. off-tree)
- module detection (pre-configure, configure, post-configure)
- module configuration (single configure possibly built from different
sources vs. per-module configure)
- build time (in-tree vs. off-tree)

having modules always in tree makes it possible to automate module detection
completely; i.e. Makfefile can just always rescan for changed modules and
rebuild necessary files if list has changed.

Supporting them off-tree facilitates independent modules development but I
have a feeling it is unlikely to be an issue in the near future :)

Having separate per-module configure has one problem of passing results of
main configure testing down because 2.5 disables caching by default. I could
not find suitable solution to this problem unless recent autoconf has
changed it. Besides to really utilize autoconf features list of
sub-configure has to be statically included in top-level script. Advantage
it has is that user can just drop in module source and does not need to
worry about having suitable autoconf version

Having module detection in configure (as is done currently) prevents adding
per-module configure checks (at least, using autoconf language).

So overall I am inclined to the build process that

- assumes all modules in-tree
- builds initial modules list as part of preconfig and adds rule to Makefile
to recheck and rebuild it later
- (re-)builds configure from snippets optionally supplied by modules
- provides --with-modules and --with-static-modules (with wildcard support)
to control which modules are included and which are built statically into
zsh, eliminating any auto-generated file editing.

Comments?

-andrey


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: autoconf 2.5 (Re: PATCH: terminfo horor)
@ 2004-01-15  8:36 Borzenkov Andrey
  0 siblings, 0 replies; 18+ messages in thread
From: Borzenkov Andrey @ 2004-01-15  8:36 UTC (permalink / raw)
  To: 'Peter Stephenson', 'Zsh hackers list'

> 
> Oliver Kiddle wrote:
> > The main goal I had in mind was just for the thing to actually compile
> > on my machine without messy fiddling.
> 
> This will do fine for now.  Otherwise it's probably never going to happen.
> 

OK, in this case your patch was the right thing. I am still curious as to
why this change was done in the first place.

Regards

-andrey


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

end of thread, other threads:[~2004-01-15  8:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-18 17:05 PATCH: terminfo horor Peter Stephenson
2003-12-18 18:52 ` Mads Martin Joergensen
2003-12-18 19:35   ` Peter Stephenson
2003-12-18 21:58     ` Mads Martin Joergensen
2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
2003-12-19 11:14   ` Peter Stephenson
2003-12-19 12:41     ` Mads Martin Joergensen
2003-12-25 11:49 Borzenkov Andrey
2004-01-08 12:25 ` Oliver Kiddle
2004-01-08 13:15   ` Peter Stephenson
2003-12-25 12:17 Borzenkov Andrey
2004-01-05 12:34 ` Peter Stephenson
2004-01-08 15:20 Borzenkov Andrey
2004-01-08 16:11 ` Oliver Kiddle
2004-01-09  9:31 Borzenkov Andrey
2004-01-14 16:01 ` Oliver Kiddle
2004-01-14 16:24   ` Peter Stephenson
2004-01-15  8:36 Borzenkov Andrey

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).