From 73c99473244c61c9bccdc3b35516ec89bf8cadc5 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 10 Nov 2013 04:50:52 +0000 Subject: [PATCH] Rewrite the termcap/terminfo detection logic in configure. The new logic is considerably shorter and simpler, and should mean that terminfo is properly used in preference to termcap on NetBSD. This also allows us to include term.h in term.c, where the system definition of tparm() lives on some systems (NetBSD is one such). The new logic also means we link against libtinfo in preference to libncurses, which should mean a little less memory used at runtime and a fraction faster startup time. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@434 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 5 ++++ configure.in | 78 ++++++++++++++++------------------------------------ 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/Changelog b/Changelog index 4449c39..78311e3 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,10 @@ [Changes 1.2c01] +* Rewrite termcap/terminfo detection logic in configure and include term.h + in term.c for the system definition of tparm(). This fixes a crash on + NetBSD x86-64 (reported by jeezy), and should also ensure that terminfo + is used in preference to termcap on NetBSD. (caf) + * Fix output when built against termcap. (caf) * Fix STATUS_NOTIFY so that it appears in the right window. (caf) diff --git a/configure.in b/configure.in index 475d5e5..d024641 100644 --- a/configure.in +++ b/configure.in @@ -603,62 +603,30 @@ AC_DEFINE_UNQUOTED(_VERSION_, "$_VERSION_", Define short BitchX version here.) AC_SUBST(EXTRAS) AC_SUBST(INSTALL_EXTRAS) -dnl Check for setupterm/tgetent. *DO NOT* check on CYGWIN or EMXOS2 because +dnl Check for setupterm/tgetent. *DO NOT* check on EMXOS2 because dnl term support is built-in. -if test -z "$CYGWIN" -a -z "$EMXOS2" -a -z "$MINGWIN32"; then - AC_MSG_CHECKING(whether to use use tgetent or setupterm) - AC_ARG_WITH(tgetent, - [ --with-tgetent Use tgetent (termcap) instead of setupterm (ncurses) ], - [ AC_MSG_RESULT(tgetent) - AC_CHECK_LIB(tinfo, tgetent, tinfo=1; LIBS="-ltinfo $LIBS", - AC_CHECK_LIB(mytinfo, tgetent, tinfo=1; LIBS="-lmytinfo $LIBS", - AC_CHECK_LIB(termcap, tgetent, termcap=1; LIBS="-ltermcap $LIBS", - AC_CHECK_LIB(termlib, tgetent, termlib=1; LIBS="-ltermlib $LIBS", - AC_CHECK_LIB(curses, tgetent, curses=1; LIBS="-lcurses $LIBS", - AC_MSG_WARN(cannot find tgetent - trying setupterm) - AC_CHECK_LIB(ncurses, setupterm, ncurses=1; LIBS="-lncurses $LIBS", - AC_CHECK_LIB(curses, setupterm, ncurses=1; LIBS="-lcurses $LIBS", - AC_CHECK_LIB(tinfo, setupterm, tinfo=1; LIBS="-ltinfo $LIBS", - AC_MSG_ERROR(cannot find tgetent or setupterm)))))))))], - [ AC_MSG_RESULT(setupterm) - AC_CHECK_LIB(ncurses, setupterm, ncurses=1; LIBS="-lncurses $LIBS", - AC_CHECK_LIB(curses, setupterm, curses=1; LIBS="-lcurses $LIBS", - AC_CHECK_LIB(tinfo, tgetent, tinfo=1; LIBS="-ltinfo $LIBS", - AC_CHECK_LIB(mytinfo, tgetent, tinfo=1; LIBS="-lmytinfo $LIBS", - AC_CHECK_LIB(tinfo, setupterm, tinfo=1; LIBS="-ltinfo $LIBS", - AC_MSG_WARN(cannot find setupterm - trying tgetent) - AC_CHECK_LIB(termlib, tgetent, termlib=1; LIBS="-ltermlib $LIBS", - AC_CHECK_LIB(termcap, tgetent, termcap=1; LIBS="-ltermcap $LIBS", - AC_CHECK_LIB(curses, tgetent, curses=1; LIBS="-lcurses $LIBS", - AC_MSG_ERROR(cannot find setupterm or tgetent)))))))))]) - - dnl Check for tputs and tparm. - if test x"$ncurses" = x"1"; then - AC_CHECK_DECLARATION(tparm, tparm, [tparm( | |)], ncurses.h, TPARM_DECLARED) - AC_CHECK_LIB(ncurses, tparm, AC_DEFINE(HAVE_TPARM, 1, Define this if you have the tparm function in an included lib.),) - AC_CHECK_HEADERS(ncurses.h ncurses/termcap.h termcap.h) - AC_CHECK_DECLARATION(tputs, tputs, [tputs( | |)], ncurses/termcap.h, TPUTS_DECLARED) - AC_CHECK_DECLARATION(tputs, tputs, [tputs( | |)], termcap.h, TPUTS_DECLARED) - AC_CHECK_LIB(ncurses, tputs, AC_DEFINE(HAVE_TPUTS, 1, Define this if you have the tputs function in an included lib.),) - fi - if test x"$curses" = x"1"; then - AC_CHECK_HEADERS(curses.h termcap.h) - AC_CHECK_DECLARATION(tparm, tparm, [tparm( | |)], curses.h, TPARM_DECLARED) - AC_CHECK_LIB(curses, tparm, AC_DEFINE(HAVE_TPARM, 1, Define this if you have the tparm function in an included lib.),) - AC_CHECK_DECLARATION(tputs, tputs, [tputs( | |)], curses.h, TPUTS_DECLARED) - AC_CHECK_LIB(curses, tputs, AC_DEFINE(HAVE_TPUTS, 1, Define this if you have the tputs function in an included lib.),) - AC_CHECK_DECLARATION(tputs, tputs, [tputs( | |)], termcap.h, TPUTS_DECLARED) - fi - if test x"$termcap" = x"1"; then - AC_CHECK_HEADERS(termcap.h) - AC_CHECK_DECLARATION(tparm, tparm, [tparm( | |)], termcap.h, TPARM_DECLARED) - AC_CHECK_LIB(termcap, tparm, AC_DEFINE(HAVE_TPARM, 1, Define this if you have the tparm function in an included lib.),) - AC_CHECK_DECLARATION(tputs, tputs, [tputs( | |)], termcap.h, TPUTS_DECLARED) - AC_CHECK_LIB(termcap, tputs, AC_DEFINE(HAVE_TPUTS, 1, Define this if you have the tputs function in an included lib.),) - fi -fi -if test x"$ncurses" = x"1" -o x"$tinfo" = x"1"; then - AC_DEFINE(HAVE_TERMINFO, 1, Define this if you have terminfo support.) +if test -z "$EMXOS2" -a -z "$MINGWIN32"; then + AC_MSG_CHECKING(whether to use use termcap in preference to terminfo) + AC_ARG_WITH(termcap, + [ --with-termcap Use termcap in preference to terminfo], + [ AC_MSG_RESULT(yes) + AC_SEARCH_LIBS([tgetent], [termcap termlib curses], [], + AC_MSG_ERROR([Cannot find termcap.]))], + [ AC_MSG_RESULT(no) + AC_SEARCH_LIBS([setupterm], [tinfo terminfo ncurses curses mytinfo], + AC_DEFINE(HAVE_TERMINFO, 1, [Define this if you have terminfo support.]), + [AC_MSG_WARN([Cannot find terminfo, falling back to termcap.]) + AC_SEARCH_LIBS([tgetent], [termcap termlib curses], [], + AC_MSG_ERROR([Cannot find terminfo or termcap - try installing the ncurses-dev / ncurses-devel package.]))])]) + AC_CHECK_FUNCS([tparm]) + AC_CHECK_HEADERS([ncurses.h curses.h]) + AC_CHECK_HEADERS([ncurses/termcap.h termcap.h ncurses/term.h term.h], [], [], + [[#if defined(HAVE_NCURSES_H) + #include + #elif defined(HAVE_CURSES_H) + #include + #endif + ]]) fi dnl Check for Tcl.