xref: /PHP-5.5/ext/readline/config.m4 (revision c6d977dd)
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  PHP_CHECK_LIBRARY(edit, rl_on_new_line,
64  [
65    AC_DEFINE(HAVE_RL_ON_NEW_LINE, 1, [ ])
66  ],[],[
67    -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
68  ])
69
70  AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
71
72elif test "$PHP_LIBEDIT" != "no"; then
73
74  for i in $PHP_LIBEDIT /usr/local /usr; do
75    test -f $i/include/editline/readline.h && LIBEDIT_DIR=$i && break
76  done
77
78  if test -z "$LIBEDIT_DIR"; then
79    AC_MSG_ERROR(Please reinstall libedit - I cannot find readline.h)
80  fi
81
82  PHP_ADD_INCLUDE($LIBEDIT_DIR/include)
83
84  AC_CHECK_LIB(ncurses, tgetent,
85  [
86    PHP_ADD_LIBRARY(ncurses,,READLINE_SHARED_LIBADD)
87  ],[
88    AC_CHECK_LIB(termcap, tgetent,
89    [
90      PHP_ADD_LIBRARY(termcap,,READLINE_SHARED_LIBADD)
91    ])
92  ])
93
94  PHP_CHECK_LIBRARY(edit, readline,
95  [
96    PHP_ADD_LIBRARY_WITH_PATH(edit, $LIBEDIT_DIR/$PHP_LIBDIR, READLINE_SHARED_LIBADD)
97  ], [
98    AC_MSG_ERROR(edit library required by readline not found)
99  ], [
100    -L$READLINE_DIR/$PHP_LIBDIR
101  ])
102
103  PHP_CHECK_LIBRARY(edit, rl_callback_read_char,
104  [
105    AC_DEFINE(HAVE_RL_CALLBACK_READ_CHAR, 1, [ ])
106  ],[],[
107    -L$READLINE_DIR/$PHP_LIBDIR
108  ])
109
110  PHP_CHECK_LIBRARY(edit, rl_on_new_line,
111  [
112    AC_DEFINE(HAVE_RL_ON_NEW_LINE, 1, [ ])
113  ],[],[
114    -L$READLINE_DIR/$PHP_LIBDIR
115  ])
116
117  AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
118fi
119
120if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then
121  AC_CHECK_FUNCS([rl_completion_matches])
122  PHP_NEW_EXTENSION(readline, readline.c readline_cli.c, $ext_shared, cli)
123  PHP_SUBST(READLINE_SHARED_LIBADD)
124fi
125