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