infcall: refactor 'call_function_by_hand_dummy'
[deliverable/binutils-gdb.git] / readline / examples / autoconf / RL_LIB_READLINE_VERSION
CommitLineData
cc88a640
JK
1dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
2dnl require:
3dnl AC_PROG_CC
4dnl BASH_CHECK_LIB_TERMCAP
5
6AC_DEFUN([RL_LIB_READLINE_VERSION],
7[
8AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
9
10AC_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
23if test -z "$ac_cv_rl_prefix"; then
24test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
25fi
26
27eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
28eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
29
30LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
31CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
32LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
33
34AC_CACHE_VAL(ac_cv_rl_version,
35[AC_TRY_RUN([
36#include <stdio.h>
37#include <readline/readline.h>
38
39extern int rl_gnu_readline_p;
40
41main()
42{
43 FILE *fp;
44 fp = fopen("conftest.rlv", "w");
45 if (fp == 0)
46 exit(1);
47 if (rl_gnu_readline_p != 1)
48 fprintf(fp, "0.0\n");
49 else
50 fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
51 fclose(fp);
52 exit(0);
53}
54],
55ac_cv_rl_version=`cat conftest.rlv`,
56ac_cv_rl_version='0.0',
57ac_cv_rl_version='4.2')])
58
59CFLAGS="$_save_CFLAGS"
60LDFLAGS="$_save_LDFLAGS"
61LIBS="$_save_LIBS"
62
63RL_MAJOR=0
64RL_MINOR=0
65
66# (
67case "$ac_cv_rl_version" in
682*|3*|4*|5*|6*|7*|8*|9*)
69 RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
70 RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
71 ;;
72esac
73
74# (((
75case $RL_MAJOR in
76[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
77[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
78*) _RL_MAJOR=00 ;;
79esac
80
81# (((
82case $RL_MINOR in
83[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
84[[0-9]]) _RL_MINOR=0$RL_MINOR ;;
85*) _RL_MINOR=00 ;;
86esac
87
88RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
89
90# Readline versions greater than 4.2 have these defines in readline.h
91
92if test $ac_cv_rl_version = '0.0' ; then
93 AC_MSG_WARN([Could not test version of installed readline library.])
94elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
95 # set these for use by the caller
96 RL_PREFIX=$ac_cv_rl_prefix
97 RL_LIBDIR=$ac_cv_rl_libdir
98 RL_INCLUDEDIR=$ac_cv_rl_includedir
99 AC_MSG_RESULT($ac_cv_rl_version)
100else
101
102AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
103AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
104AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
105
106AC_SUBST(RL_VERSION)
107AC_SUBST(RL_MAJOR)
108AC_SUBST(RL_MINOR)
109
110# set these for use by the caller
111RL_PREFIX=$ac_cv_rl_prefix
112RL_LIBDIR=$ac_cv_rl_libdir
113RL_INCLUDEDIR=$ac_cv_rl_includedir
114
115AC_MSG_RESULT($ac_cv_rl_version)
116
117fi
118])
This page took 0.467973 seconds and 4 git commands to generate.