1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
AC_DEFUN([NTP_LINEEDITLIBS], [
NTP_ORIG_LIBS="$LIBS"
AC_ARG_WITH(
[lineeditlibs],
[AS_HELP_STRING(
[--with-lineeditlibs],
[edit,editline (readline may be specified if desired)]
)],
[use_lineeditlibs="$withval"],
[use_lineeditlibs="edit,editline"]
)
AC_MSG_CHECKING([line editing libraries])
AC_MSG_RESULT([$use_lineeditlibs])
case "$use_lineeditlibs" in
no)
ntp_lib_lineedit=no
;;
*)
for lineedit_lib in `echo $use_lineeditlibs | sed -e 's/,/ /'`; do
for term_lib in "" termcap curses ncurses; do
case "$term_lib" in
'')
TRY_LIB="-l$lineedit_lib"
;;
*)
TRY_LIB="-l$lineedit_lib -l$term_lib"
;;
esac
LIBS="$NTP_ORIG_LIBS $TRY_LIB"
AC_MSG_CHECKING([for readline() with $TRY_LIB])
AC_TRY_LINK_FUNC([readline], [ntp_lib_lineedit="$TRY_LIB"])
case "$ntp_lib_lineedit" in
'')
AC_MSG_RESULT([no])
;;
*)
# Use readline()
AC_MSG_RESULT([yes])
break
esac
case "$term_lib" in
'')
# do not try el_gets without a terminal library
;;
*)
AC_MSG_CHECKING([for el_gets() with $TRY_LIB])
AC_TRY_LINK_FUNC([el_gets], [ntp_lib_lineedit="$TRY_LIB"])
case "$ntp_lib_lineedit" in
'')
AC_MSG_RESULT([no])
;;
*) # Use el_gets()
AC_MSG_RESULT([yes])
break
;;
esac # $ntp_lib_lineedit
esac # $term_lib
done
case "$ntp_lib_lineedit" in
'')
;;
*)
break
;;
esac
done
LIBS="$NTP_ORIG_LIBS"
;;
esac # $use_lineeditlibs
case "$ntp_lib_lineedit" in
'')
ntp_lib_lineedit="no"
;;
no)
;;
*)
EDITLINE_LIBS="$ntp_lib_lineedit"
AC_SUBST([EDITLINE_LIBS])
;;
esac # $ntp_lib_lineedit
case "$ntp_lib_lineedit" in
no)
;;
*)
AC_CHECK_HEADERS([readline.h readline/readline.h histedit.h])
AC_CHECK_HEADERS([history.h readline/history.h])
case "$ac_cv_header_histedit_h" in
yes)
AC_CACHE_CHECK(
[number of arguments to el_init()],
[ntp_cv_el_init_args],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <histedit.h>
]],
[[
el_init("conftest", stdin, stdout, stderr);
]]
)],
[ntp_cv_el_init_args=4],
[ntp_cv_el_init_args=3]
)]
)
AC_DEFINE_UNQUOTED(
[EL_INIT_ARGS],
[$ntp_cv_el_init_args],
[number of args to el_init()]
)
esac
AC_MSG_CHECKING([whether readline supports history])
ntp_lib_lineedit_history="no"
ORIG_LIBS="$LIBS"
LIBS="$ORIG_LIBS $ntp_lib_lineedit"
AC_TRY_LINK_FUNC([add_history], [ntp_lib_lineedit_history="yes"])
LIBS="$ORIG_LIBS"
AC_MSG_RESULT([$ntp_lib_lineedit_history])
case "$ntp_lib_lineedit_history" in
yes)
AC_DEFINE([HAVE_READLINE_HISTORY], [1],
[Define if your readline library has \`add_history'])
esac
esac # $ntp_lib_lineedit
AS_UNSET([NTP_ORIG_LIBS])
AS_UNSET([ORIG_LIBS])
AS_UNSET([TRY_LIB])
AS_UNSET([use_lineeditlibs])
])dnl
|