From e02339c3aefc481acb1422dd89527f608ae17238 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 1 Jun 2016 07:14:11 +0200 Subject: [PATCH] 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 --- configure.ac | 11 ++++++++++- examples/Makefile.am | 5 ----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 96cd0e0..00b1b25 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/examples/Makefile.am b/examples/Makefile.am index db231d9..f7726bc 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -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 -