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
|
dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
dnl require:
dnl AC_PROG_CC
dnl BASH_CHECK_LIB_TERMCAP
AC_DEFUN([RL_LIB_READLINE_VERSION],
[
AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
AC_MSG_CHECKING([version of installed readline library])
# What a pain in the ass this is.
# save cpp and ld options
_save_CFLAGS="$CFLAGS"
_save_LDFLAGS="$LDFLAGS"
_save_LIBS="$LIBS"
# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This
# allows the caller to do something like $_rl_prefix=$withval if the user
# specifies --with-installed-readline=PREFIX as an argument to configure
if test -z "$ac_cv_rl_prefix"; then
test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
fi
eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
AC_CACHE_VAL(ac_cv_rl_version,
[AC_TRY_RUN([
#include <stdio.h>
#include <readline/readline.h>
#include <stdlib.h>
extern int rl_gnu_readline_p;
main()
{
FILE *fp;
fp = fopen("conftest.rlv", "w");
if (fp == 0)
exit(1);
if (rl_gnu_readline_p != 1)
fprintf(fp, "0.0\n");
else
fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
fclose(fp);
exit(0);
}
],
ac_cv_rl_version=`cat conftest.rlv`,
ac_cv_rl_version='0.0',
ac_cv_rl_version='4.2')])
CFLAGS="$_save_CFLAGS"
LDFLAGS="$_save_LDFLAGS"
LIBS="$_save_LIBS"
RL_MAJOR=0
RL_MINOR=0
# (
case "$ac_cv_rl_version" in
2*|3*|4*|5*|6*|7*|8*|9*)
RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
;;
esac
# (((
case $RL_MAJOR in
[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
*) _RL_MAJOR=00 ;;
esac
# (((
case $RL_MINOR in
[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
[[0-9]]) _RL_MINOR=0$RL_MINOR ;;
*) _RL_MINOR=00 ;;
esac
RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
# Readline versions greater than 4.2 have these defines in readline.h
if test $ac_cv_rl_version = '0.0' ; then
AC_MSG_WARN([Could not test version of installed readline library.])
elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
# set these for use by the caller
RL_PREFIX=$ac_cv_rl_prefix
RL_LIBDIR=$ac_cv_rl_libdir
RL_INCLUDEDIR=$ac_cv_rl_includedir
AC_MSG_RESULT($ac_cv_rl_version)
else
AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
AC_SUBST(RL_VERSION)
AC_SUBST(RL_MAJOR)
AC_SUBST(RL_MINOR)
# set these for use by the caller
RL_PREFIX=$ac_cv_rl_prefix
RL_LIBDIR=$ac_cv_rl_libdir
RL_INCLUDEDIR=$ac_cv_rl_includedir
AC_MSG_RESULT($ac_cv_rl_version)
fi
])
|