From: Taylor R Campbell Date: Sun, 8 Aug 2010 01:53:07 +0000 (+0000) Subject: Add configure option `--with-termcap=LIB' to select termcap library. X-Git-Tag: 20101212-Gtk~116 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=7c431e6212ba047e4c8a0eec1178aa252ed733bd;p=mit-scheme.git Add configure option `--with-termcap=LIB' to select termcap library. LIB=no disables any termcap library (causing the use of the built-in termcap emulation); LIB=yes, the default, makes configure choose whatever termcap library looks best. I wanted to go further and make the termcap primitives dynamically loadable, so that the compile-time choice of termcap library can be made just for some prtermcap.so module separately from the libraries against which the microcode is linked, but uxtty.c uses termcap for screen-clearing and window-sizing. If ^L worked everywhere to clear the screen, and TIOCGWINSZ worked everywhere to find the screen dimensions, then we could get rid of those uses of termcap and move it off to a module. But alas, that is not the case. E.g., ^L doesn't clear the screen in screen. --- diff --git a/src/microcode/configure.ac b/src/microcode/configure.ac index 7f930cfda..a1364e4e9 100644 --- a/src/microcode/configure.ac +++ b/src/microcode/configure.ac @@ -158,6 +158,11 @@ AC_ARG_WITH([libpq], [Use PostgreSQL libpq library if available [[yes]]])) : ${with_libpq='yes'} +AC_ARG_WITH([termcap], + AS_HELP_STRING([--with-termcap], + [Use a termcap library if available [[yes]]])) +: ${with_termcap='yes'} + dnl For reasons I don't understand, it is necessary to use dnl quadigraphs here instead of [[ ... ]]. AC_ARG_WITH([macosx-version], @@ -686,64 +691,72 @@ dnl database, we can emulate `tparam' -- either in terms of `tparm' or dnl by pretending we know the format -- without bringing in the local dnl termcap reimplementation. -AC_CHECK_LIB([ncurses], [tgetent], [have_ncurses=yes]) -AC_CHECK_LIB([ncurses], [tparm], [have_ncurses_tparm=yes]) -AC_CHECK_LIB([ncurses], [tparam], [have_ncurses_tparam=yes]) -AC_CHECK_LIB([curses], [tgetent], [have_curses=yes]) -AC_CHECK_LIB([curses], [tparm], [have_curses_tparm=yes]) -AC_CHECK_LIB([curses], [tparam], [have_curses_tparam=yes]) -AC_CHECK_LIB([termcap], [tgetent], [have_termcap=yes]) -AC_CHECK_LIB([termcap], [tparm], [have_termcap_tparm=yes]) -AC_CHECK_LIB([termcap], [tparam], [have_termcap_tparam=yes]) - -if test "x${have_ncurses}" = xyes; then - termcap_library=ncurses -elif test "x${have_curses_tparm}" != xyes \ - || test "x${have_curses_tparam}" != xyes -then - if test "x${have_termcap}" = xyes; then - termcap_library=termcap +if test "x${with_termcap}" = xyes; then + + AC_CHECK_LIB([ncurses], [tgetent], [have_ncurses=yes]) + AC_CHECK_LIB([ncurses], [tparm], [have_ncurses_tparm=yes]) + AC_CHECK_LIB([ncurses], [tparam], [have_ncurses_tparam=yes]) + AC_CHECK_LIB([curses], [tgetent], [have_curses=yes]) + AC_CHECK_LIB([curses], [tparm], [have_curses_tparm=yes]) + AC_CHECK_LIB([curses], [tparam], [have_curses_tparam=yes]) + AC_CHECK_LIB([termcap], [tgetent], [have_termcap=yes]) + AC_CHECK_LIB([termcap], [tparm], [have_termcap_tparm=yes]) + AC_CHECK_LIB([termcap], [tparam], [have_termcap_tparam=yes]) + + if test "x${have_ncurses}" = xyes; then + with_termcap=ncurses + elif test "x${have_curses_tparm}" != xyes \ + || test "x${have_curses_tparam}" != xyes + then + if test "x${have_termcap}" = xyes; then + with_termcap=termcap + elif test "x${have_curses}" = xyes; then + with_termcap=curses + fi + dnl This is a little unusual (that we have either `tparm' or `tparam' + dnl from `-lcurses', but not `tgetent'), but we should check anyway. elif test "x${have_curses}" = xyes; then - termcap_library=curses + with_termcap=curses + elif test "x${have_termcap}" = xyes; then + with_termcap=termcap + fi + +elif test "x${with_termcap}" != xno; then + + lib=${with_termcap} + AC_CHECK_LIB([${lib}], [tgetent], [eval have_${lib}=yes]) + AC_CHECK_LIB([${lib}], [tparm], [eval have_${lib}_tparm=yes]) + AC_CHECK_LIB([${lib}], [tparam], [eval have_${lib}_tparam=yes]) + + if eval test "\"x\${have_${lib}}\"" != xyes; then + AC_MSG_ERROR([No tgetent in termcap library: ${with_termcap}]) fi -dnl This is a little unusual (that we have either `tparm' or `tparam' -dnl from `-lcurses', but not `tgetent'), but we should check anyway. -elif test "x${have_curses}" = xyes; then - termcap_library=curses -elif test "x${have_termcap}" = xyes; then - termcap_library=termcap + fi -case ${termcap_library} in -curses) - AC_CHECK_HEADERS([curses.h term.h]) - LIBS="-lcurses ${LIBS}" - ;; -ncurses) - dnl ncurses sometimes uses ncurses.h and sometimes uses curses.h. - dnl We use whichever one is available, preferring the more - dnl specifically named one. - AC_CHECK_HEADERS([ncurses.h curses.h term.h]) - LIBS="-lncurses ${LIBS}" - ;; -termcap) - LIBS="-ltermcap ${LIBS}" - ;; -esac +dnl Go for whatever header files we can. +AC_CHECK_HEADERS([ncurses.h curses.h term.h]) -if test "x${termcap_library}" = xno; then +case "${with_termcap}" in +yes) + AC_MSG_WARN([No termcap library found; will emulate it]) OPTIONAL_BASES="${OPTIONAL_BASES} termcap tparam" -else - eval have_tparam=\$have_${termcap_library}_tparam + ;; +no) ;; +*) + LIBS="-l${with_termcap} ${LIBS}" + eval have_tparam=\$have_${with_termcap}_tparam if test "x${have_tparam}" != xyes; then - eval have_tparm=\$have_${termcap_library}_tparm + eval have_tparm=\$have_${with_termcap}_tparm if test "x${have_tparm}" = xyes; then + AC_MSG_WARN([No tparam found; will emulate it from terminfo tparm]) OPTIONAL_BASES="${OPTIONAL_BASES} terminfo" else + AC_MSG_WARN([No tparam found; will emulate it]) OPTIONAL_BASES="${OPTIONAL_BASES} tparam" fi fi -fi +esac dnl The OpenSSL crypto library provides support for blowfish and MD5. if test "${with_openssl}" != no; then