xref: /PHP-5.3/ext/readline/config.m4 (revision 44116212)
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_WITH(libedit,for libedit readline replacement,
6[  --with-libedit[=DIR]    Include libedit readline replacement (CLI/CGI only)])
7
8if test "$PHP_LIBEDIT" = "no"; then
9  PHP_ARG_WITH(readline,for readline support,
10  [  --with-readline[=DIR]   Include readline support (CLI/CGI only)])
11else
12  dnl "register" the --with-readline option to preven invalid "unknown configure option" warning
13  php_with_readline=no
14fi
15
16if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
17  for i in $PHP_READLINE /usr/local /usr; do
18    test -f $i/include/readline/readline.h && READLINE_DIR=$i && break
19  done
20
21  if test -z "$READLINE_DIR"; then
22    AC_MSG_ERROR(Please reinstall readline - I cannot find readline.h)
23  fi
24
25  PHP_ADD_INCLUDE($READLINE_DIR/include)
26
27  PHP_READLINE_LIBS=""
28  AC_CHECK_LIB(ncurses, tgetent,
29  [
30    PHP_ADD_LIBRARY(ncurses,,READLINE_SHARED_LIBADD)
31    PHP_READLINE_LIBS="$PHP_READLINE_LIBS -lncurses"
32  ],[
33    AC_CHECK_LIB(termcap, tgetent,
34    [
35      PHP_ADD_LIBRARY(termcap,,READLINE_SHARED_LIBADD)
36      PHP_READLINE_LIBS="$PHP_READLINE_LIBS -ltermcap"
37    ])
38  ])
39
40  PHP_CHECK_LIBRARY(readline, readline,
41  [
42    PHP_ADD_LIBRARY_WITH_PATH(readline, $READLINE_DIR/$PHP_LIBDIR, READLINE_SHARED_LIBADD)
43  ], [
44    AC_MSG_ERROR(readline library not found)
45  ], [
46    -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
47  ])
48
49  PHP_CHECK_LIBRARY(readline, rl_pending_input,
50  [], [
51    AC_MSG_ERROR([invalid readline installation detected. Try --with-libedit instead.])
52  ], [
53    -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
54  ])
55
56  PHP_CHECK_LIBRARY(readline, rl_callback_read_char,
57  [
58    AC_DEFINE(HAVE_RL_CALLBACK_READ_CHAR, 1, [ ])
59  ],[],[
60    -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
61  ])
62
63  AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
64
65elif test "$PHP_LIBEDIT" != "no"; then
66
67  for i in $PHP_LIBEDIT /usr/local /usr; do
68    test -f $i/include/editline/readline.h && LIBEDIT_DIR=$i && break
69  done
70
71  if test -z "$LIBEDIT_DIR"; then
72    AC_MSG_ERROR(Please reinstall libedit - I cannot find readline.h)
73  fi
74
75  PHP_ADD_INCLUDE($LIBEDIT_DIR/include)
76
77  AC_CHECK_LIB(ncurses, tgetent,
78  [
79    PHP_ADD_LIBRARY(ncurses,,READLINE_SHARED_LIBADD)
80  ],[
81    AC_CHECK_LIB(termcap, tgetent,
82    [
83      PHP_ADD_LIBRARY(termcap,,READLINE_SHARED_LIBADD)
84    ])
85  ])
86
87  PHP_CHECK_LIBRARY(edit, readline,
88  [
89    PHP_ADD_LIBRARY_WITH_PATH(edit, $LIBEDIT_DIR/$PHP_LIBDIR, READLINE_SHARED_LIBADD)
90  ], [
91    AC_MSG_ERROR(edit library required by readline not found)
92  ], [
93    -L$READLINE_DIR/$PHP_LIBDIR
94  ])
95
96  AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
97fi
98
99if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then
100  AC_CHECK_FUNCS([rl_completion_matches])
101  PHP_NEW_EXTENSION(readline, readline.c, $ext_shared, cli)
102  PHP_SUBST(READLINE_SHARED_LIBADD)
103fi
104