@@ -22,21 +22,6 @@ cmake_dependent_option(
2222 OFF
2323)
2424
25- cmake_dependent_option(
26- EXT_READLINE_LIBREADLINE
27- "Use the GNU Readline library instead of Editline"
28- OFF
29- "EXT_READLINE"
30- OFF
31- )
32- mark_as_advanced (EXT_READLINE_LIBREADLINE)
33-
34- add_feature_info(
35- "ext/readline with GNU Readline"
36- EXT_READLINE_LIBREADLINE
37- "GNU Readline library support instead of Editline"
38- )
39-
4025if (NOT EXT_READLINE)
4126 return ()
4227endif ()
@@ -64,145 +49,59 @@ if(HAVE_WNO_STRICT_PROTOTYPES_C)
6449 )
6550endif ()
6651
67- if (NOT EXT_READLINE_LIBREADLINE)
68- find_package (Editline)
69- set_package_properties(
70- Editline
71- PROPERTIES
72- TYPE REQUIRED
73- PURPOSE "Necessary to enable the readline extension."
74- )
52+ find_package (Editline)
53+ set_package_properties(
54+ Editline
55+ PROPERTIES
56+ TYPE REQUIRED
57+ PURPOSE "Necessary to enable the readline extension."
58+ )
7559
76- target_link_libraries (php_readline PUBLIC Editline::Editline)
77-
78- if (TARGET Editline::Editline)
79- check_library_exists(
80- Editline::Editline
81- rl_callback_read_char
82- ""
83- HAVE_RL_CALLBACK_READ_CHAR
84- )
85- check_library_exists(
86- Editline::Editline
87- rl_on_new_line
88- ""
89- HAVE_RL_ON_NEW_LINE
90- )
91- check_library_exists(
92- Editline::Editline
93- rl_completion_matches
94- ""
95- HAVE_RL_COMPLETION_MATCHES
96- )
97- check_library_exists(
98- Editline::Editline
99- history_list
100- ""
101- HAVE_HISTORY_LIST
102- )
103- endif ()
60+ target_link_libraries (php_readline PUBLIC Editline::Editline)
10461
105- set (
106- HAVE_LIBEDIT 1
107- CACHE INTERNAL "Whether Editline is used for readline extension"
62+ if (TARGET Editline::Editline)
63+ check_library_exists(
64+ Editline::Editline
65+ rl_callback_read_char
66+ ""
67+ HAVE_RL_CALLBACK_READ_CHAR
10868 )
109-
110- cmake_push_check_state(RESET)
111- set (CMAKE_REQUIRED_LIBRARIES Editline::Editline)
112- check_symbol_exists(
113- rl_erase_empty_line
114- editline/readline.h
115- HAVE_ERASE_EMPTY_LINE
116- )
117- cmake_pop_check_state()
118- else ()
119- message (
120- WARNING
121- "The GNU Readline library is licensed under the GNU GPL 3, which is not "
122- "compatible with the PHP license. The recommended library for using and "
123- "distributing the PHP 'readline' extension without limitations is libedit. "
124- "To build with libedit, remove the 'EXT_READLINE_LIBREADLINE', or set it "
125- "to 'OFF'."
69+ check_library_exists(
70+ Editline::Editline
71+ rl_on_new_line
72+ ""
73+ HAVE_RL_ON_NEW_LINE
12674 )
127- find_package (Readline)
128- set_package_properties(
129- Readline
130- PROPERTIES
131- TYPE REQUIRED
132- PURPOSE "Necessary to enable the readline extension."
75+ check_library_exists(
76+ Editline::Editline
77+ rl_completion_matches
78+ ""
79+ HAVE_RL_COMPLETION_MATCHES
13380 )
81+ check_library_exists(
82+ Editline::Editline
83+ history_list
84+ ""
85+ HAVE_HISTORY_LIST
86+ )
87+ endif ()
13488
135- target_link_libraries (php_readline PUBLIC Readline::Readline)
136-
137- if (TARGET Readline::Readline)
138- # Sanity minimum version check if Readline library has the
139- # 'rl_pending_input' variable. The macOS systems might have an outdated
140- # forked Readline library installed on the system by default, which doesn't
141- # have this variable.
142- # See https://bugs.php.net/48608.
143- cmake_push_check_state(RESET)
144- set (CMAKE_REQUIRED_LIBRARIES Readline::Readline)
145-
146- check_symbol_exists(
147- rl_pending_input
148- # The <readline/readline.h> is not self-contained header and some
149- # systems, like macOS, need <stdio.h> to have FILE type available.
150- "stdio.h;readline/readline.h"
151- _readline_have_rl_pending_input
152- )
153- cmake_pop_check_state()
154-
155- if (NOT _readline_have_rl_pending_input)
156- message (
157- FATAL_ERROR
158- "Readline library check failed. Variable rl_pending_input missing. "
159- "This version of Readline installation is not supported. Try using "
160- "libedit instead (set EXT_READLINE_LIBREADLINE to 'OFF')."
161- )
162- endif ()
163-
164- check_library_exists(
165- Readline::Readline
166- rl_callback_read_char
167- ""
168- HAVE_RL_CALLBACK_READ_CHAR
169- )
170- check_library_exists(
171- Readline::Readline
172- rl_on_new_line
173- ""
174- HAVE_RL_ON_NEW_LINE
175- )
176- check_library_exists(
177- Readline::Readline
178- rl_completion_matches
179- ""
180- HAVE_RL_COMPLETION_MATCHES
181- )
182- endif ()
89+ set (
90+ HAVE_LIBEDIT 1
91+ CACHE INTERNAL "Whether Editline is used for readline extension"
92+ )
18393
184- set (
185- HAVE_HISTORY_LIST 1
186- CACHE INTERNAL "Whether Readline library has history_list"
187- )
188- set (
189- HAVE_LIBREADLINE 1
190- CACHE INTERNAL "Whether Readline is used for readline extension"
94+ cmake_push_check_state(RESET)
95+ set (CMAKE_REQUIRED_LIBRARIES Editline::Editline)
96+ check_symbol_exists(
97+ rl_erase_empty_line
98+ editline/readline.h
99+ HAVE_ERASE_EMPTY_LINE
191100 )
101+ cmake_pop_check_state()
192102
193- cmake_push_check_state(RESET)
194- set (CMAKE_REQUIRED_LIBRARIES Readline::Readline)
195- check_symbol_exists(
196- rl_erase_empty_line
197- # The <readline/readline.h> is not self-contained header and some systems,
198- # like macOS, need <stdio.h> to have FILE type available.
199- "stdio.h;readline/readline.h"
200- HAVE_ERASE_EMPTY_LINE
201- )
202- cmake_pop_check_state()
203- endif ()
204103
205- # TODO: Editline/Readline dependent libraries shouldn't be linked on this level.
104+ # TODO: Editline dependent libraries shouldn't be linked on this level.
206105# Recheck if this is really needed. Either move to find modules or remove it.
207106# Also, for example, Editline with Autoconf integration has even more thorough
208107# dependencies checked in current version.
0 commit comments