1dnl stolen from libgadu 2dnl Rewritten from scratch. --wojtekka 3dnl 4 5AC_DEFUN([AC_CHECK_READLINE],[ 6 AC_SUBST(READLINE_LIBS) 7 AC_SUBST(READLINE_INCLUDES) 8 9 AC_ARG_WITH(readline, 10 [[ --with-readline[=dir] Compile with readline/locate base dir]], 11 if test "x$withval" = "xno" ; then 12 without_readline=yes 13 elif test "x$withval" != "xyes" ; then 14 with_arg="$withval/include:-L$withval/lib $withval/include/readline:-L$withval/lib" 15 fi) 16 17 if test "x$without_readline" != "xyes"; then 18 AC_MSG_CHECKING(for readline.h) 19 for i in $with_arg \ 20 /usr/include: \ 21 /usr/local/include:-L/usr/local/lib \ 22 /usr/freeware/include:-L/usr/freeware/lib32 \ 23 /usr/pkg/include:-L/usr/pkg/lib \ 24 /sw/include:-L/sw/lib \ 25 /cw/include:-L/cw/lib \ 26 /net/caladium/usr/people/piotr.nba/temp/pkg/include:-L/net/caladium/usr/people/piotr.nba/temp/pkg/lib \ 27 /boot/home/config/include:-L/boot/home/config/lib; do 28 29 incl=`echo "$i" | sed 's/:.*//'` 30 lib=`echo "$i" | sed 's/.*://'` 31 32 have_readline=no 33 34 if test -f $incl/readline/readline.h ; then 35 AC_MSG_RESULT($incl/readline/readline.h) 36 READLINE_LIBS="$lib -lreadline" 37 if test "$incl" != "/usr/include"; then 38 READLINE_INCLUDES="-I$incl/readline -I$incl" 39 else 40 READLINE_INCLUDES="-I$incl/readline" 41 fi 42 have_readline=yes 43 break 44 elif test -f $incl/readline.h -a "x$incl" != "x/usr/include"; then 45 AC_MSG_RESULT($incl/readline.h) 46 READLINE_LIBS="$lib -lreadline" 47 READLINE_INCLUDES="-I$incl" 48 have_readline=yes 49 break 50 fi 51 52 done 53 54 if test "$have_readline" = yes; then 55 dnl Check to see if ncurses is needed. 56 dnl Debian's libreadline is linked against ncurses, 57 dnl but others' may not be. 58 READLINE_LIBS_TEMP="$LIBS" 59 READLINE_LDFLAGS_TEMP="$LDFLAGS" 60 LIBS='' 61 AC_MSG_NOTICE([checking whether libreadline is linked against libncurses]) 62 AC_CHECK_LIB([readline], [cbreak]) 63 if test "$LIBS" = ''; then 64 LIBS='' 65 LDFLAGS="$READLINE_LDFLAGS_TEMP" 66 AC_CHECK_LIB([ncurses], [cbreak]) 67 if test "$LIBS" = ''; then 68 AC_MSG_NOTICE([libreadline is not linked against libncurses, and I can't find it - disabling]) 69 have_readline=no 70 else 71 READLINE_LIBS="$READLINE_LIBS $LIBS" 72 AC_MSG_NOTICE([libreadline is not linked against libncurses; adding $LIBS]) 73 fi 74 else 75 AC_MSG_NOTICE([libreadline is linked against libncurses]) 76 fi 77 LIBS="$READLINE_LIBS_TEMP" 78 LDFLAGS="$READLINE_LDFLAGS_TEMP" 79 else 80 AC_MSG_RESULT(not found) 81 fi 82 83 if test "$have_readline" = yes; then 84 AC_DEFINE(HAVE_READLINE, 1, [define if You want readline]) 85 fi 86 87 fi 88 89]) 90 91