Fix compilation with wxWidgets 2.8.12
[amule.git] / m4 / readline.m4
blobeb9957baa42b6f02b038e416bcf400a149257eb0
1 dnl
2 dnl Copyright (c) 2003-2011 aMule Team (http://www.amule.org)
3 dnl Copyright (c) 1995-2008 Free Software Foundation, Inc.
4 dnl
5 dnl This file is free software, distributed under the terms of the GNU
6 dnl General Public License.  As a special exception to the GNU General
7 dnl Public License, this file may be distributed as part of a program
8 dnl that contains a configuration script generated by Autoconf, under
9 dnl the same distribution terms as the rest of that program.
10 dnl
11 dnl Original file available from the GNU Autoconf Macro Archive at:
12 dnl http://www.gnu.org/software/ac-archive/htmldoc/vl_lib_readline.html
13 dnl
15 AC_DEFUN([VL_LIB_READLINE], [
16   AC_CACHE_CHECK([for a readline compatible library],
17                  vl_cv_lib_readline, [
18     ORIG_LIBS="$LIBS"
19     for readline_lib in readline edit editline; do
20       for termcap_lib in "" termcap curses ncurses; do
21         if test -z "$termcap_lib"; then
22           TRY_LIB="-l$readline_lib"
23         else
24           TRY_LIB="-l$readline_lib -l$termcap_lib"
25         fi
26         LIBS="$ORIG_LIBS $TRY_LIB"
27         AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
28         if test -n "$vl_cv_lib_readline"; then
29           break
30         fi
31       done
32       if test -n "$vl_cv_lib_readline"; then
33         break
34       fi
35     done
36     if test -z "$vl_cv_lib_readline"; then
37       vl_cv_lib_readline="no"
38       LIBS="$ORIG_LIBS"
39       READLINE_LIBS=""
40     else
41       READLINE_LIBS="$vl_cv_lib_readline"
42     fi
43   ])
45   if test "$vl_cv_lib_readline" != "no"; then
46     AC_DEFINE(HAVE_LIBREADLINE, 1,
47               [Define if you have a readline compatible library])
48     AC_CHECK_HEADERS(readline.h readline/readline.h)
49     AC_CACHE_CHECK([whether readline supports history],
50                    vl_cv_lib_readline_history, [
51       vl_cv_lib_readline_history="no"
52       AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes")
53     ])
54     if test "$vl_cv_lib_readline_history" = "yes"; then
55       AC_DEFINE(HAVE_READLINE_HISTORY, 1,
56                 [Define if your readline library has \`add_history'])
57       AC_CHECK_HEADERS(history.h readline/history.h)
58     fi
59   fi
60   AC_SUBST(READLINE_LIBS)
61   LIBS="$ORIG_LIBS"
62 ])dnl