client: Unbreak standalone build
[empserver] / m4 / my_lib_readline.m4
1 AC_DEFUN([MY_LIB_READLINE], [
2     AC_CACHE_CHECK([for a readline compatible library],
3                    my_cv_lib_readline, [
4         my_lib_readline_save_LIBS="$LIBS"
5         for readline_lib in readline edit editline; do
6             for termcap_lib in "" termlib termcap curses ncurses; do
7                 if test -z "$termcap_lib"; then
8                     my_cv_lib_readline="-l$readline_lib"
9                 else
10                     my_cv_lib_readline="-l$readline_lib -l$termcap_lib"
11                 fi
12                 LIBS="$my_cv_lib_readline $my_lib_readline_save_LIBS"
13                 AC_LINK_IFELSE([AC_LANG_CALL([], [add_history])],
14                                [break 2], [my_cv_lib_readline=no])
15             done
16         done
17     ])
18
19     if test "$my_cv_lib_readline" != no; then
20         AC_CHECK_HEADER([readline/readline.h], [], [my_cv_lib_readline=no],
21                         [AC_INCLUDES_DEFAULT])
22     fi
23     if test "$my_cv_lib_readline" != no; then
24         AC_CHECK_HEADER([readline/history.h], [], [my_cv_lib_readline=no],
25                         [AC_INCLUDES_DEFAULT])
26     fi
27
28     if test "$my_cv_lib_readline" = no; then
29         LIBS="$my_lib_readline_save_LIBS"
30     else
31         AC_DEFINE([HAVE_LIBREADLINE], [1],
32                   [Define if you have libreadline])
33     fi
34 ])
35
36 AC_DEFUN([MY_WITH_READLINE], [
37     AC_ARG_WITH([readline],
38         [AS_HELP_STRING([--with-readline],
39           [support fancy command line editing @<:@default=check@:>@])],
40         [],
41         [with_readline=check])
42     if test "x$with_readline" != xno; then
43         MY_LIB_READLINE
44         if test "x$my_cv_lib_readline$with_readline" = xnoyes; then
45             AC_MSG_FAILURE([--with-readline was given, but test for readline failed])
46         fi
47         if test "$my_cv_lib_readline" = no; then
48             with_readline=no
49         else
50             with_readline=yes
51         fi
52     fi])