| 1 |
dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB |
| 2 |
dnl require: |
| 3 |
dnl AC_PROG_CC |
| 4 |
dnl BASH_CHECK_LIB_TERMCAP |
| 5 |
|
| 6 |
AC_DEFUN([RL_LIB_READLINE_VERSION], |
| 7 |
[ |
| 8 |
AC_REQUIRE([BASH_CHECK_LIB_TERMCAP]) |
| 9 |
|
| 10 |
AC_MSG_CHECKING([version of installed readline library]) |
| 11 |
|
| 12 |
# What a pain in the ass this is. |
| 13 |
|
| 14 |
# save cpp and ld options |
| 15 |
_save_CFLAGS="$CFLAGS" |
| 16 |
_save_LDFLAGS="$LDFLAGS" |
| 17 |
_save_LIBS="$LIBS" |
| 18 |
|
| 19 |
# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This |
| 20 |
# allows the caller to do something like $_rl_prefix=$withval if the user |
| 21 |
# specifies --with-installed-readline=PREFIX as an argument to configure |
| 22 |
|
| 23 |
if test -z "$ac_cv_rl_prefix"; then |
| 24 |
test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix} |
| 25 |
fi |
| 26 |
|
| 27 |
eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include |
| 28 |
eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib |
| 29 |
|
| 30 |
LIBS="$LIBS -lreadline ${TERMCAP_LIB}" |
| 31 |
CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}" |
| 32 |
LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" |
| 33 |
|
| 34 |
AC_CACHE_VAL(ac_cv_rl_version, |
| 35 |
[AC_TRY_RUN([ |
| 36 |
#include <stdio.h> |
| 37 |
#include <readline/readline.h> |
| 38 |
#include <stdlib.h> |
| 39 |
|
| 40 |
extern int rl_gnu_readline_p; |
| 41 |
|
| 42 |
main() |
| 43 |
{ |
| 44 |
FILE *fp; |
| 45 |
fp = fopen("conftest.rlv", "w"); |
| 46 |
if (fp == 0) |
| 47 |
exit(1); |
| 48 |
if (rl_gnu_readline_p != 1) |
| 49 |
fprintf(fp, "0.0\n"); |
| 50 |
else |
| 51 |
fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); |
| 52 |
fclose(fp); |
| 53 |
exit(0); |
| 54 |
} |
| 55 |
], |
| 56 |
ac_cv_rl_version=`cat conftest.rlv`, |
| 57 |
ac_cv_rl_version='0.0', |
| 58 |
ac_cv_rl_version='4.2')]) |
| 59 |
|
| 60 |
CFLAGS="$_save_CFLAGS" |
| 61 |
LDFLAGS="$_save_LDFLAGS" |
| 62 |
LIBS="$_save_LIBS" |
| 63 |
|
| 64 |
RL_MAJOR=0 |
| 65 |
RL_MINOR=0 |
| 66 |
|
| 67 |
# ( |
| 68 |
case "$ac_cv_rl_version" in |
| 69 |
2*|3*|4*|5*|6*|7*|8*|9*) |
| 70 |
RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'` |
| 71 |
RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'` |
| 72 |
;; |
| 73 |
esac |
| 74 |
|
| 75 |
# ((( |
| 76 |
case $RL_MAJOR in |
| 77 |
[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;; |
| 78 |
[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;; |
| 79 |
*) _RL_MAJOR=00 ;; |
| 80 |
esac |
| 81 |
|
| 82 |
# ((( |
| 83 |
case $RL_MINOR in |
| 84 |
[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;; |
| 85 |
[[0-9]]) _RL_MINOR=0$RL_MINOR ;; |
| 86 |
*) _RL_MINOR=00 ;; |
| 87 |
esac |
| 88 |
|
| 89 |
RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}" |
| 90 |
|
| 91 |
# Readline versions greater than 4.2 have these defines in readline.h |
| 92 |
|
| 93 |
if test $ac_cv_rl_version = '0.0' ; then |
| 94 |
AC_MSG_WARN([Could not test version of installed readline library.]) |
| 95 |
elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then |
| 96 |
# set these for use by the caller |
| 97 |
RL_PREFIX=$ac_cv_rl_prefix |
| 98 |
RL_LIBDIR=$ac_cv_rl_libdir |
| 99 |
RL_INCLUDEDIR=$ac_cv_rl_includedir |
| 100 |
AC_MSG_RESULT($ac_cv_rl_version) |
| 101 |
else |
| 102 |
|
| 103 |
AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library]) |
| 104 |
AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library]) |
| 105 |
AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library]) |
| 106 |
|
| 107 |
AC_SUBST(RL_VERSION) |
| 108 |
AC_SUBST(RL_MAJOR) |
| 109 |
AC_SUBST(RL_MINOR) |
| 110 |
|
| 111 |
# set these for use by the caller |
| 112 |
RL_PREFIX=$ac_cv_rl_prefix |
| 113 |
RL_LIBDIR=$ac_cv_rl_libdir |
| 114 |
RL_INCLUDEDIR=$ac_cv_rl_includedir |
| 115 |
|
| 116 |
AC_MSG_RESULT($ac_cv_rl_version) |
| 117 |
|
| 118 |
fi |
| 119 |
]) |