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