From 89f200b55b309aa67c1fbfc11d4de211725348f4 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 12 Jul 2016 12:41:15 +0300 Subject: Line-editing support in gdbmtool * configure.ac: Check if GNU Readline is available. * src/Makefile.am: Add new files. * src/input-rl.c: New file. * src/input-std.c: New file. * src/gdbmtool.c (handler_param): Move declaration to the header file. (quit_handler): Call input_done. (command_tab): Add the "history" command. (command_generator): New function. (slist_new_s, slist_new_l) (slist_insert): New functions. (main): Call input_init and input_done. * src/gdbmtool.h: New protos. * src/gram.y: Use slist_insert to construct string lists. * src/lex.l (read_input): Remove. Use input_read instead. (print_prompt_at_bol): New function. (print_prompt): Remove. (make_prompt): New function. * NEWS: Document changes. * README: Document readline support. * doc/gdbm.texi: Document line editing in gdbmtool. * doc/gdbmtool.1: Likewise. --- configure.ac | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 15270b9..336e05c 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,55 @@ AC_SUBST(GDBM183_INCLUDEDIR) AM_CONDITIONAL([COMPAT_OPT], [test "$want_compat" = yes]) AM_CONDITIONAL([ENABLE_EXPORT], [test "$want_export" = yes]) +# Check for Curses libs. +for lib in ncurses curses termcap +do + AC_CHECK_LIB($lib, tputs, [CURSES_LIBS="-l$lib"; break]) +done + +AC_SUBST(CURSES_LIBS) +# Readline +AC_ARG_WITH([readline], + AC_HELP_STRING([--without-readline], + [do not use readline]), + [ +case "${withval}" in + yes) status_readline=yes ;; + no) status_readline=no ;; + *) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;; +esac],[status_readline=probe]) + +AC_SUBST(READLINE_LIBS) + +if test "$status_readline" != "no"; then + dnl FIXME This should only link in the curses libraries if it's + dnl really needed! + saved_LIBS=$LIBS + LIBS="$LIBS $CURSES_LIBS" + AC_CHECK_LIB(readline, readline, + [status_readline=yes], + [if test "$status_readline" = "yes"; then + AC_MSG_ERROR(readline requested but does not seem to be installed) + else + status_readline=no + fi]) + LIBS=$saved_LIBS + + if test "$status_readline" = "yes"; then + AC_CHECK_HEADERS(readline/readline.h, + AC_DEFINE(WITH_READLINE,1,[Enable use of readline])) + READLINE_LIBS="-lreadline $CURSES_LIBS" + saved_LIBS=$LIBS + LIBS="$LIBS $READLINE_LIBS" + AC_CHECK_FUNCS(rl_completion_matches) + LIBS=$saved_LIBS + fi +else + status_readline=no +fi + +AM_CONDITIONAL([GDBM_COND_READLINE], [test "$status_readline" = "yes"]) + # Initialize the test suite. AC_CONFIG_TESTDIR(tests) AC_CONFIG_FILES([tests/Makefile tests/atlocal po/Makefile.in]) -- cgit v1.2.1