Do not assume -ltermcap, check for tgetent() instead

This is a followup patch for issue #8.  When the user elects
to enable Termcap checks for window resizing we need to check
what library on the system provides this functionality.  Do
not assume -ltermcap, but instead check for tgetent() in all
possible libraries.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2016-06-01 07:14:11 +02:00
parent f66e8cc151
commit e02339c3ae
2 changed files with 10 additions and 6 deletions

View File

@ -83,8 +83,17 @@ AC_ARG_ENABLE(termcap,
[AS_HELP_STRING([--enable-termcap], [Use termcap library to query terminal size.])],
AC_DEFINE([CONFIG_USE_TERMCAP], 1, [Define to use the termcap library for terminal size.]))
AM_CONDITIONAL([USE_LIBTERMCAP], [test "$enable_termcap" != no])
AM_CFLAGS="-std=gnu99 $inline_cflags -W -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow -Wcast-qual"
AC_SUBST(AM_CFLAGS)
# Check for a termcap compatible library if enabled
AS_IF([test "$enable_termcap" != no],
AC_CHECK_LIB(termcap, tgetent, , [
AC_CHECK_LIB(tinfo, tgetent, , [
AC_CHECK_LIB(curses, tgetent, , [
AC_CHECK_LIB(ncurses, tgetent, , [
AC_MSG_ERROR([Cannot find a termcap capable library, try installing Ncurses.])])
])
])
]))
AC_OUTPUT

View File

@ -4,8 +4,3 @@ noinst_PROGRAMS = testit cli
LDADD = $(top_builddir)/src/libeditline.la
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
AM_LDFLAGS = -static
if USE_LIBTERMCAP
LDADD += -ltermcap
endif