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