dbf8be5ed943d088eec73756ce507b50f9ff65be
[debian/amanda] / config / amanda / readline.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_CHECK_READLINE
4 #
5 # OVERVIEW
6 #
7 #   Check for readline support.  Defines HAVE_READLINE if readline
8 #   is available, and also checks for a number of readline headers and
9 #   adds readline libraries to READLINE_LIBS.
10 #
11 #   See common-src/util.{c,h}.
12 #
13 AC_DEFUN([AMANDA_CHECK_READLINE], [
14     AC_ARG_WITH(readline,
15     dnl no initial space here, so the results line up properly
16 AS_HELP_STRING([--with-readline], [require readline support (for amrecover)])
17 AS_HELP_STRING([--without-readline], [don't search for readline]),
18         [ 
19             case "$withval" in
20                 y | ye | yes | n | no) : ;;
21                 *) AC_MSG_ERROR([*** --with-readline does not take a value])
22             esac
23             want_readline="$withval"
24         ], [
25             want_readline="maybe" # meaning "only if we can find it"
26         ])
27
28     # unless the user said "no", look for readline.
29     if test x"$want_readline" != x"no"; then
30         # we need a tgetent() somewhere..
31         proceed="false"
32         AC_CHECK_LIB(termcap, tgetent, [
33             READLINE_LIBS="-ltermcap"
34             proceed="true"
35         ], [
36             AC_CHECK_LIB(curses, tgetent, [
37                 READLINE_LIBS="-lcurses"
38                 proceed="true"
39             ], [
40                 AC_CHECK_LIB(ncurses, tgetent, [
41                     READLINE_LIBS="-lncurses"
42                     proceed="true"
43                 ])
44             ])
45         ])
46
47         if $proceed; then
48             proceed="false"
49             AC_CHECK_HEADERS( history.h readline.h readline/history.h readline/readline.h, [
50                 # found at least one of the headers, so we can proceed.
51                 proceed="true"
52             ])
53         fi
54
55         if $proceed; then
56             proceed="false"
57             AC_CHECK_LIB(readline,readline, [
58                 READLINE_LIBS="-lreadline $READLINE_LIBS"
59                 proceed="true"
60             ],,$READLINE_LIBS)
61         fi
62
63         if $proceed; then
64             # we have readline!
65             AC_DEFINE(HAVE_READLINE, 1, [System has readline support (headers and libraries)])
66         else
67             # no readline.  if the user *really* wanted it, bail out.
68             if test x"$want_readline" = x"yes"; then
69                 AC_MSG_ERROR([*** No readline implementation found.  Try using --with-libraries and --with-includes])
70             fi
71             READLINE_LIBS=""
72         fi
73     fi
74     AC_SUBST(READLINE_LIBS)
75 ])