4
# PANDORA_HAVE_LIBREADLINE
8
# Searches for a readline compatible library. If found, defines
9
# `HAVE_LIBREADLINE'. If the found library has the `add_history'
10
# function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
11
# locations of the necessary include files and sets `HAVE_READLINE_H'
12
# or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
13
# 'HAVE_HISTORY_H' if the corresponding include files exists.
15
# The libraries that may be readline compatible are `libedit',
16
# `libeditline' and `libreadline'. Sometimes we need to link a
17
# termcap library for readline to work, this macro tests these cases
18
# too by trying to link with `libtermcap', `libcurses' or
19
# `libncurses' before giving up.
21
# Here is an example of how to use the information provided by this
22
# macro to perform the necessary includes or declarations in a C
25
# #ifdef HAVE_LIBREADLINE
26
# # if defined(HAVE_READLINE_READLINE_H)
27
# # include <readline/readline.h>
28
# # elif defined(HAVE_READLINE_H)
29
# # include <readline.h>
30
# # else /* !defined(HAVE_READLINE_H) */
31
# extern char *readline ();
32
# # endif /* !defined(HAVE_READLINE_H) */
33
# char *cmdline = NULL;
34
# #else /* !defined(HAVE_READLINE_READLINE_H) */
36
# #endif /* HAVE_LIBREADLINE */
38
# #ifdef HAVE_READLINE_HISTORY
39
# # if defined(HAVE_READLINE_HISTORY_H)
40
# # include <readline/history.h>
41
# # elif defined(HAVE_HISTORY_H)
42
# # include <history.h>
43
# # else /* !defined(HAVE_HISTORY_H) */
44
# extern void add_history ();
45
# extern int write_history ();
46
# extern int read_history ();
47
# # endif /* defined(HAVE_READLINE_HISTORY_H) */
49
# #endif /* HAVE_READLINE_HISTORY */
55
# Based on VL_LIB_READLINE from Ville Laurikari
59
# Copyright (C) 2009 Monty Taylor
60
# Copyright (C) 2002 Ville Laurikari <vl@iki.fi>
62
# Copying and distribution of this file, with or without
63
# modification, are permitted in any medium without royalty provided
64
# the copyright notice and this notice are preserved.
66
AC_DEFUN([PANDORA_CHECK_TIOCGWINSZ],[
67
AC_CACHE_CHECK([for TIOCGWINSZ in sys/ioctl.h],
68
[pandora_cv_tiocgwinsz_in_ioctl],[
71
#include <sys/types.h>
72
#include <sys/ioctl.h>
77
pandora_cv_tiocgwinsz_in_ioctl=yes
79
pandora_cv_tiocgwinsz_in_ioctl=no
82
AS_IF([test "$pandora_cv_tiocgwinsz_in_ioctl" = "yes"],[
83
AC_DEFINE([GWINSZ_IN_SYS_IOCTL], [1],
84
[READLINE: your system defines TIOCGWINSZ in sys/ioctl.h.])
88
AC_DEFUN([PANDORA_CHECK_RL_COMPENTRY], [
89
AC_CACHE_CHECK([defined rl_compentry_func_t], [pandora_cv_rl_compentry],[
93
#include "readline/readline.h"
95
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
98
pandora_cv_rl_compentry=yes
100
pandora_cv_rl_compentry=no
103
AS_IF([test "$pandora_cv_rl_compentry" = "yes"],[
104
AC_DEFINE([HAVE_RL_COMPENTRY], [1],
105
[Does system provide rl_compentry_func_t])
108
save_CXXFLAGS="${CXXFLAGS}"
109
CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
111
AC_CACHE_CHECK([rl_compentry_func_t works], [pandora_cv_rl_compentry_works],[
115
#include "readline/readline.h"
117
rl_completion_entry_function= (rl_compentry_func_t*)NULL;
120
pandora_cv_rl_compentry_works=yes
122
pandora_cv_rl_compentry_works=no
125
AS_IF([test "$pandora_cv_rl_compentry_works" = "yes"],[
126
AC_DEFINE([HAVE_WORKING_RL_COMPENTRY], [1],
127
[Does system provide an rl_compentry_func_t that is usable])
129
CXXFLAGS="${save_CXXFLAGS}"
134
AC_DEFUN([PANDORA_CHECK_RL_COMPLETION_FUNC], [
135
AC_CACHE_CHECK([defined rl_completion_func_t], [pandora_cv_rl_completion],[
139
#include "readline/readline.h"
141
rl_completion_func_t *func1= (rl_completion_func_t*)0;
144
pandora_cv_rl_completion=yes
146
pandora_cv_rl_completion=no
149
AS_IF([test "$pandora_cv_rl_completion" = "yes"],[
150
AC_DEFINE([HAVE_RL_COMPLETION], [1],
151
[Does system provide rl_completion_func_t])
155
AC_DEFUN([_PANDORA_SEARCH_LIBREADLINE], [
160
AC_CACHE_CHECK([for a readline compatible library],
163
for readline_lib in readline edit editline; do
164
for termcap_lib in "" termcap curses ncurses; do
165
if test -z "$termcap_lib"; then
166
TRY_LIB="-l$readline_lib"
168
TRY_LIB="-l$readline_lib -l$termcap_lib"
170
LIBS="$ORIG_LIBS $TRY_LIB"
171
AC_TRY_LINK_FUNC(readline, ac_cv_libreadline="$TRY_LIB")
172
if test -n "$ac_cv_libreadline"; then
176
if test -n "$ac_cv_libreadline"; then
180
if test -z "$ac_cv_libreadline"; then
181
ac_cv_libreadline="no"
186
if test "$ac_cv_libreadline" != "no"; then
187
AC_DEFINE(HAVE_LIBREADLINE, 1,
188
[Define if you have a readline compatible library])
189
AC_CHECK_HEADERS(readline.h readline/readline.h)
190
AC_CACHE_CHECK([whether readline supports history],
191
ac_cv_libreadline_history, [
192
ac_cv_libreadline_history="no"
193
AC_TRY_LINK_FUNC(add_history, ac_cv_libreadline_history="yes")
195
if test "$ac_cv_libreadline_history" = "yes"; then
196
AC_DEFINE(HAVE_READLINE_HISTORY, 1,
197
[Define if your readline library has \`add_history'])
198
AC_CHECK_HEADERS(history.h readline/history.h)
201
PANDORA_CHECK_RL_COMPENTRY
202
PANDORA_CHECK_RL_COMPLETION_FUNC
203
PANDORA_CHECK_TIOCGWINSZ
206
READLINE_LIBS="${LIBS}"
208
AC_SUBST(READLINE_LIBS)
210
AM_CONDITIONAL(HAVE_LIBREADLINE, [test "x${ac_cv_libreadline}" = "xyes"])
213
AC_DEFUN([_PANDORA_HAVE_LIBREADLINE],[
215
AC_ARG_ENABLE([libreadline],
216
[AS_HELP_STRING([--disable-libreadline],
217
[Build with libreadline support @<:@default=on@:>@])],
218
[ac_enable_libreadline="$enableval"],
219
[ac_enable_libreadline="yes"])
221
_PANDORA_SEARCH_LIBREADLINE
225
AC_DEFUN([PANDORA_HAVE_LIBREADLINE],[
226
AC_REQUIRE([_PANDORA_HAVE_LIBREADLINE])
229
AC_DEFUN([_PANDORA_REQUIRE_LIBREADLINE],[
230
ac_enable_libreadline="yes"
231
_PANDORA_SEARCH_LIBREADLINE
233
AS_IF([test "x$ac_cv_libreadline" = "xno"],
234
AC_MSG_ERROR([libreadline is required for ${PACKAGE}. On Debian this can be found in libreadline5-dev. On RedHat this can be found in readline-devel.]))
238
AC_DEFUN([PANDORA_REQUIRE_LIBREADLINE],[
239
AC_REQUIRE([_PANDORA_REQUIRE_LIBREADLINE])