Annotation of embedaddon/readline/examples/autoconf/wi_LIB_READLINE, revision 1.1.1.1

1.1       misho       1: dnl Borut Razem
                      2: dnl
                      3: dnl This macro checks for the presence of the readline library.
                      4: dnl It works also in cross-compilation environment.
                      5: dnl
                      6: dnl To get it into the aclocal.m4 dnl file, do this:
                      7: dnl   aclocal -I . --verbose
                      8: dnl
                      9: dnl The --verbose will show all of the files that are searched
                     10: dnl for .m4 macros.
                     11: 
                     12: AC_DEFUN([wi_LIB_READLINE], [
                     13:   dnl check for the readline.h header file
                     14: 
                     15:   AC_CHECK_HEADER(readline/readline.h)
                     16: 
                     17:   if test "$ac_cv_header_readline_readline_h" = yes; then
                     18:     dnl check the readline version
                     19: 
                     20:     cat > conftest.$ac_ext <<EOF
                     21: #include <stdio.h>
                     22: #include <readline/readline.h>
                     23: wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR
                     24: EOF
                     25: 
                     26:     wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION  *\([[0-9\]][[0-9\]]*\)  *\([[0-9\]][[0-9\]]*\)$/\1.\2/p")
                     27:     rm -rf conftest*
                     28: 
                     29:     if test -n "$wi_READLINE_VERSION"; then
                     30:       wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.')
                     31:       wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*$\)')
                     32:       if test $wi_MINOR -lt 10; then
                     33:         wi_MINOR=$(expr $wi_MINOR \* 10)
                     34:       fi
                     35:       wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR)
                     36:     else
                     37:       wi_READLINE_VERSION=-1
                     38:     fi
                     39: 
                     40:     dnl check for the readline library
                     41: 
                     42:     ac_save_LIBS="$LIBS"
                     43:     # Note: $LIBCURSES is permitted to be empty.
                     44: 
                     45:     for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
                     46:     do
                     47:       AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE])
                     48: 
                     49:       LIBS="$ac_save_LIBS $LIBREADLINE"
                     50: 
                     51:       AC_TRY_LINK([
                     52:         /* includes */
                     53:         #include <stdio.h>
                     54:         #include <readline/readline.h>
                     55:       ],[
                     56:         /* function-body */
                     57:         int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */
                     58:         readline(NULL);
                     59:       ],[
                     60:         wi_cv_lib_readline=yes
                     61:         AC_MSG_RESULT(yes)
                     62:       ],[
                     63:         wi_cv_lib_readline=no
                     64:         AC_MSG_RESULT(no)
                     65:       ])
                     66: 
                     67:       if test "$wi_cv_lib_readline" = yes; then
                     68:         AC_SUBST(LIBREADLINE)
                     69:         AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline])
                     70:         break
                     71:       fi
                     72:     done
                     73: 
                     74:     LIBS="$ac_save_LIBS"
                     75:   fi
                     76: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>