779.2.4
by Monty Taylor
Updated some more build stuff. |
1 |
##### http://autoconf-archive.cryp.to/vl_lib_readline.html
|
2 |
#
|
|
3 |
# SYNOPSIS
|
|
4 |
#
|
|
5 |
# VL_LIB_READLINE
|
|
6 |
#
|
|
7 |
# DESCRIPTION
|
|
8 |
#
|
|
9 |
# Searches for a readline compatible library. If found, defines
|
|
10 |
# `HAVE_LIBREADLINE'. If the found library has the `add_history'
|
|
11 |
# function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
|
|
12 |
# locations of the necessary include files and sets `HAVE_READLINE_H'
|
|
13 |
# or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
|
|
14 |
# 'HAVE_HISTORY_H' if the corresponding include files exists.
|
|
15 |
#
|
|
16 |
# The libraries that may be readline compatible are `libedit',
|
|
17 |
# `libeditline' and `libreadline'. Sometimes we need to link a
|
|
18 |
# termcap library for readline to work, this macro tests these cases
|
|
19 |
# too by trying to link with `libtermcap', `libcurses' or
|
|
20 |
# `libncurses' before giving up.
|
|
21 |
#
|
|
22 |
# Here is an example of how to use the information provided by this
|
|
23 |
# macro to perform the necessary includes or declarations in a C
|
|
24 |
# file:
|
|
25 |
#
|
|
26 |
# #ifdef HAVE_LIBREADLINE
|
|
27 |
# # if defined(HAVE_READLINE_READLINE_H)
|
|
28 |
# # include <readline/readline.h>
|
|
29 |
# # elif defined(HAVE_READLINE_H)
|
|
30 |
# # include <readline.h>
|
|
31 |
# # else /* !defined(HAVE_READLINE_H) */
|
|
32 |
# extern char *readline ();
|
|
33 |
# # endif /* !defined(HAVE_READLINE_H) */
|
|
34 |
# char *cmdline = NULL;
|
|
35 |
# #else /* !defined(HAVE_READLINE_READLINE_H) */
|
|
36 |
# /* no readline */
|
|
37 |
# #endif /* HAVE_LIBREADLINE */
|
|
38 |
#
|
|
39 |
# #ifdef HAVE_READLINE_HISTORY
|
|
40 |
# # if defined(HAVE_READLINE_HISTORY_H)
|
|
41 |
# # include <readline/history.h>
|
|
42 |
# # elif defined(HAVE_HISTORY_H)
|
|
43 |
# # include <history.h>
|
|
44 |
# # else /* !defined(HAVE_HISTORY_H) */
|
|
45 |
# extern void add_history ();
|
|
46 |
# extern int write_history ();
|
|
47 |
# extern int read_history ();
|
|
48 |
# # endif /* defined(HAVE_READLINE_HISTORY_H) */
|
|
49 |
# /* no history */
|
|
50 |
# #endif /* HAVE_READLINE_HISTORY */
|
|
51 |
#
|
|
52 |
# LAST MODIFICATION
|
|
53 |
#
|
|
54 |
# 2002-04-04
|
|
55 |
#
|
|
56 |
# COPYLEFT
|
|
57 |
#
|
|
58 |
# Copyright (c) 2002 Ville Laurikari <vl@iki.fi>
|
|
59 |
#
|
|
60 |
# Copying and distribution of this file, with or without
|
|
61 |
# modification, are permitted in any medium without royalty provided
|
|
62 |
# the copyright notice and this notice are preserved.
|
|
63 |
||
64 |
AC_DEFUN([VL_LIB_READLINE], [ |
|
65 |
AC_CACHE_CHECK([for a readline compatible library], |
|
66 |
vl_cv_lib_readline, [ |
|
67 |
ORIG_LIBS="$LIBS" |
|
68 |
for readline_lib in readline edit editline; do |
|
69 |
for termcap_lib in "" termcap curses ncurses; do |
|
70 |
if test -z "$termcap_lib"; then |
|
71 |
TRY_LIB="-l$readline_lib" |
|
72 |
else |
|
73 |
TRY_LIB="-l$readline_lib -l$termcap_lib" |
|
74 |
fi |
|
75 |
LIBS="$ORIG_LIBS $TRY_LIB" |
|
76 |
AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB") |
|
77 |
if test -n "$vl_cv_lib_readline"; then |
|
78 |
break |
|
79 |
fi |
|
80 |
done |
|
81 |
if test -n "$vl_cv_lib_readline"; then |
|
82 |
break |
|
83 |
fi |
|
84 |
done |
|
85 |
if test -z "$vl_cv_lib_readline"; then |
|
86 |
vl_cv_lib_readline="no" |
|
87 |
LIBS="$ORIG_LIBS" |
|
88 |
fi |
|
89 |
]) |
|
90 |
||
91 |
if test "$vl_cv_lib_readline" != "no"; then |
|
92 |
AC_DEFINE(HAVE_LIBREADLINE, 1, |
|
93 |
[Define if you have a readline compatible library]) |
|
94 |
AC_CHECK_HEADERS(readline.h readline/readline.h) |
|
95 |
AC_CACHE_CHECK([whether readline supports history], |
|
96 |
vl_cv_lib_readline_history, [ |
|
97 |
vl_cv_lib_readline_history="no" |
|
98 |
AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes") |
|
99 |
]) |
|
100 |
if test "$vl_cv_lib_readline_history" = "yes"; then |
|
101 |
AC_DEFINE(HAVE_READLINE_HISTORY, 1, |
|
102 |
[Define if your readline library has \`add_history']) |
|
103 |
AC_CHECK_HEADERS(history.h readline/history.h) |
|
104 |
fi |
|
105 |
fi |
|
106 |
])dnl |