1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
Autoconf Macro: ac_lib_readline
8
<link rel="stylesheet" type="text/css" href="autoconf-archive.css">
11
<table summary="web navigation" style="width:100%;">
14
<td style="width:25%;" align="center" valign="top">
15
<a href="http://autoconf-archive.cryp.to/ac_lib_readline.m4">Download M4
18
<td style="width:25%;" align="center" valign="top">
20
"http://git.cryp.to/autoconf-archive?a=history;f=ac_lib_readline.m4">Macro
23
<td style="width:25%;" align="center" valign="top">
24
<a href="macros-by-category.html">Category Index</a>
26
<td style="width:25%;" align="center" valign="top">
27
<form method="get" action="http://www.google.com/search">
29
<input name="sitesearch" value="autoconf-archive.cryp.to" type=
30
"hidden"><a href="http://www.google.com/">Search</a>: <input name="q"
31
size="10" maxlength="255" type="text">
46
Renamed to <a href="vl_lib_readline.html">VL_LIB_READLINE</a>.
51
<p class="indent" style="white-space:nowrap;">
52
<code>AC_LIB_READLINE</code>
59
Searches for a readline compatible library. If found, defines
60
`HAVE_LIBREADLINE'. If the found library has the `add_history' function,
61
sets also `HAVE_READLINE_HISTORY'. Also checks for the locations of the
62
necessary include files and sets `HAVE_READLINE_H' or
63
`HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
64
'HAVE_HISTORY_H' if the corresponding include files exists.
67
The libraries that may be readline compatible are `libedit', `libeditline'
68
and `libreadline'. Sometimes we need to link a termcap library for readline
69
to work, this macro tests these cases too by trying to link with
70
`libtermcap', `libcurses' or `libncurses' before giving up.
73
Here is an example of how to use the information provided by this macro to
74
perform the necessary includes or declarations in a C file:
77
#include <config.h>
79
#ifdef HAVE_LIBREADLINE
80
#if defined(HAVE_READLINE_READLINE_H)
81
#include <readline/readline.h>
82
#elif defined(HAVE_READLINE_H)
83
#include <readline.h>
84
#else /* !defined(HAVE_READLINE_H) */
85
extern char *readline ();
86
#endif /* !defined(HAVE_READLINE_H) */
88
#else /* !defined(HAVE_READLINE_READLINE_H) */
90
#endif /* HAVE_LIBREADLINE */
92
#ifdef HAVE_READLINE_HISTORY
93
#if defined(HAVE_READLINE_HISTORY_H)
94
#include <readline/history.h>
95
#elif defined(HAVE_HISTORY_H)
96
#include <history.h>
97
#else /* !defined(HAVE_HISTORY_H) */
98
extern void add_history ();
99
extern int write_history ();
100
extern int read_history ();
101
#endif /* defined(HAVE_READLINE_HISTORY_H) */
103
#endif /* HAVE_READLINE_HISTORY */
110
Ville Laurikari <vl@iki.fi>
122
<pre class="m4source">
123
AC_DEFUN([AC_LIB_READLINE], [
124
AC_CACHE_CHECK([for a readline compatible library],
125
ac_cv_lib_readline, [
127
for readline_lib in readline edit editline; do
128
for termcap_lib in "" termcap curses ncurses; do
129
if test -z "$termcap_lib"; then
130
TRY_LIB="-l$readline_lib"
132
TRY_LIB="-l$readline_lib -l$termcap_lib"
134
LIBS="$ORIG_LIBS $TRY_LIB"
135
AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
136
if test -n "$ac_cv_lib_readline"; then
140
if test -n "$ac_cv_lib_readline"; then
144
if test -z "$ac_cv_lib_readline"; then
145
ac_cv_lib_readline="no"
150
if test "$ac_cv_lib_readline" != "no"; then
151
AC_DEFINE(HAVE_LIBREADLINE, 1,
152
[Define if you have a readline compatible library])
153
AC_CHECK_HEADERS(readline.h readline/readline.h)
154
AC_CACHE_CHECK([whether readline supports history],
155
ac_cv_lib_readline_history, [
156
ac_cv_lib_readline_history="no"
157
AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
159
if test "$ac_cv_lib_readline_history" = "yes"; then
160
AC_DEFINE(HAVE_READLINE_HISTORY, 1,
161
[Define if your readline library has \`add_history'])
162
AC_CHECK_HEADERS(history.h readline/history.h)
172
<span style="white-space:nowrap;">Copyright © 2008 Ville Laurikari
173
<vl@iki.fi></span>
175
This program is free software: you can redistribute it and/or modify it
176
under the terms of the GNU General Public License as published by the Free
177
Software Foundation, either version 3 of the License, or (at your option)
181
This program is distributed in the hope that it will be useful, but WITHOUT
182
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
183
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
187
You should have received a copy of the GNU General Public License along
188
with this program. If not, see <<a href=
189
"http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.
192
As a special exception, the respective Autoconf Macro's copyright owner
193
gives unlimited permission to copy, distribute and modify the configure
194
scripts that are the output of Autoconf when processing the Macro. You need
195
not follow the terms of the GNU General Public License when using or
196
distributing such scripts, even though portions of the text of the Macro
197
appear in them. The GNU General Public License (GPL) does govern all other
198
use of the material that constitutes the Autoconf Macro.
201
This special exception to the GPL applies to versions of the Autoconf Macro
202
released by the Autoconf Macro Archive. When you make and distribute a
203
modified version of the Autoconf Macro, you may extend this special
204
exception to the GPL to apply to your modified version as well.