-
Notifications
You must be signed in to change notification settings - Fork 0
/
readline.m4
116 lines (98 loc) · 3.94 KB
/
readline.m4
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
#
# Configure paths and flags for the GNU Readline library.
# Denis Arnaud <denis_arnaud at users dot sourceforge dot net>, April 2011
# Based on http://code.google.com/p/libnfc/source/browse/trunk/m4/readline.m4
# itself based on Wojtekka's m4 from
# http://wloc.wsinf.edu.pl/~kklos/ekg-20080219/m4/readline.m4
#
# Note: the GNU Readline library has a GPL license. Any program using
# it must therefore be GPL.
#
# Variables set by this macro:
# * AM_PATH_READLINE
# * READLINE_VERSION
# * READLINE_CFLAGS
# * READLINE_LIBS
#
AC_DEFUN([AM_PATH_READLINE],
[
AC_LANG_SAVE
AC_LANG([C])
##
AC_ARG_WITH(readline,
[[ --with-readline[=PFX] Prefix where Readline is installed (optional) ]],
readline_dir="$withval",
readline_dir="")
ac_readline_path=""
if test "x${readline_dir}" = "xno"
then
without_readline=yes
elif test "x${readline_dir}" != "xyes"
then
with_arg="${readline_dir}/include:-L${readline_dir}/lib ${readline_dir}/include/readline:-L${readline_dir}/lib"
fi
##
AC_MSG_CHECKING(for readline.h)
if test "x$without_readline" != "xyes"; then
for i in $with_arg \
/usr/include: /usr/local/include:-L/usr/local/lib \
/usr/pkg/include:-L/usr/pkg/lib
do
ac_readline_path=`echo "$i" | sed 's/:.*//'`
lib=`echo "$i" | sed 's/.*://'`
if test -f ${ac_readline_path}/readline/readline.h
then
AC_MSG_RESULT(${ac_readline_path}/readline/readline.h)
READLINE_LIBS="$lib -lreadline"
if test "${ac_readline_path}" != "/usr/include"; then
READLINE_CFLAGS="-I${ac_readline_path}/readline -I${ac_readline_path}"
else
READLINE_CFLAGS="-I${ac_readline_path}/readline"
fi
AC_DEFINE(HAVE_READLINE, 1, [define if you have readline])
ac_readline_path="${ac_readline_path}/readline"
have_readline=yes
break
elif test -f ${ac_readline_path}/readline.h -a "x${ac_readline_path}" != "x/usr/include"
then
AC_MSG_RESULT(${ac_readline_path}/readline.h)
READLINE_CFLAGS="-I${ac_readline_path}"
READLINE_LIBS="$lib -lreadline"
AC_DEFINE(HAVE_READLINE, 1, [define if you have readline])
have_readline=yes
break
fi
done
fi
if test "x$have_readline" != "xyes"; then
AC_MSG_ERROR([The GNU Readline library cannot be found. You may want to install readline-devel (RPM-based)/readline-dev (Debian-based) package.])
fi
## Readline version
readline_lib_version_req=ifelse([$1], ,6.0,$1)
AC_MSG_CHECKING(for readline lib version >= $readline_lib_version_req)
succeeded=no
readline_lib_version_req_shorten=`expr $readline_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
readline_lib_version_req_major=`expr $readline_lib_version_req : '\([[0-9]]*\)'`
readline_lib_version_req_minor=`expr $readline_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
WANT_READLINE_VERSION=`expr $readline_lib_version_req_major \* 100 \+ $readline_lib_version_req_minor`
# The lines specifying the Readline version are like the following:
#define RL_READLINE_VERSION [TAB] 0x0601 /* Readline 6.0 */
#define RL_VERSION_MAJOR [TAB] 6
#define RL_VERSION_MINOR [TAB] 1
readline_version_coded=`grep "define RL_READLINE_VERSION" ${ac_readline_path}/readline.h | cut -f2 | cut -dx -f2`
readline_version_major=`grep "define RL_VERSION_MAJOR" ${ac_readline_path}/readline.h | cut -f2`
readline_version_minor=`grep "define RL_VERSION_MINOR" ${ac_readline_path}/readline.h | cut -f2`
readline_version_computed=`expr $readline_version_major \* 100 \+ $readline_version_minor`
READLINE_VERSION="${readline_version_major}.${readline_version_minor}"
if test ${readline_version_computed} -ge ${WANT_READLINE_VERSION}
then
AC_MSG_RESULT([yes (${READLINE_VERSION}.)])
else
AC_MSG_ERROR([The version (${READLINE_VERSION}) of the GNU Readline library is too old. You may want to upgrade your readline package.])
fi
##
AC_SUBST([READLINE_VERSION])
AC_SUBST([READLINE_CFLAGS])
AC_SUBST([READLINE_LIBS])
AC_LANG_RESTORE
])