Skip to content

Commit 92daed9

Browse files
committed
Remove Readline integration
The GNU Readline is licensed under the GNU GPL 3 and doesn't allow linking with non-GPL compliant sofware, including PHP. This also simplifies the Readline vs. libedit usage to make the build experience as simple to use as possible.
1 parent 233785a commit 92daed9

File tree

8 files changed

+57
-322
lines changed

8 files changed

+57
-322
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ jobs:
9797
libargon2-dev \
9898
libxslt1-dev \
9999
libcapstone-dev \
100-
libreadline-dev \
101100
libedit-dev \
102101
libsnmp-dev \
103102
snmpd \

cmake/cmake/modules/FindReadline.cmake

Lines changed: 0 additions & 142 deletions
This file was deleted.

cmake/ext/readline/CMakeLists.txt

Lines changed: 43 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
4025
if(NOT EXT_READLINE)
4126
return()
4227
endif()
@@ -64,145 +49,59 @@ if(HAVE_WNO_STRICT_PROTOTYPES_C)
6449
)
6550
endif()
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.

cmake/main/config.w32.cmake.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,6 @@
864864
https://www.sqlite.org/compile.html. */
865865
#cmakedefine PDO_SQLITE_OMIT_LOAD_EXTENSION 1
866866

867-
/* Define to 1 if readline extension uses the 'readline' library. */
868-
#cmakedefine HAVE_LIBREADLINE 1
869-
870867
/* Define to 1 if readline extension uses the 'libedit' library. */
871868
#cmakedefine HAVE_LIBEDIT 1
872869

cmake/main/php_config.cmake.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,6 @@
961961
/* Define to 1 if you have the <LibraryManager.h> header file. */
962962
#cmakedefine HAVE_LIBRARYMANAGER_H 1
963963

964-
/* Define to 1 if readline extension uses the 'readline' library. */
965-
#cmakedefine HAVE_LIBREADLINE 1
966-
967964
/* Define to 1 if the PHP extension 'sodium' is available. */
968965
#cmakedefine HAVE_LIBSODIUMLIB 1
969966

0 commit comments

Comments
 (0)