aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Hieber <rohieb@users.noreply.github.com>2021-02-09 02:05:25 +0100
committerGitHub <noreply@github.com>2021-02-08 17:05:25 -0800
commite1f77695132e814728cda982f11342a2e3c7272c (patch)
tree0257b7b939cedffc7dda48ef96b8e7bfdb8dc9fa /configure.ac
parentbpo-40692: Run more test_concurrent_futures tests (GH-20239) (diff)
downloadcpython-e1f77695132e814728cda982f11342a2e3c7272c.tar.gz
cpython-e1f77695132e814728cda982f11342a2e3c7272c.tar.bz2
cpython-e1f77695132e814728cda982f11342a2e3c7272c.zip
bpo-13501: allow choosing between readline and libedit (GH-24189)
In contrast to macOS, libedit is available as its own include file and library on Linux systems to prevent file name clashes. So if both libraries are available on the system, readline is currently chosen by default; and if only libedit is available, it is not found at all. This patch adds a way to link against libedit by adding the following arguments to configure: --with-readline link against libreadline (the default) --with-readline=editline link against libeditline --with-readline=no disable building the readline module --without-readline (same) The runtime detection of libedit vs. readline was already done in commit 7105319ada2e66365902 (2019-12-04, serge-sans-paille: "bpo-38634: Allow non-apple build to cope with libedit (GH-16986)"). Fixes: GH-12076 ("bpo-13501 Build or disable readline with Editline") Fixes: bpo-13501 ("Make libedit support more generic; port readline / libedit to FreeBSD") Co-authored-by: Enji Cooper (ngie-eign) Co-authored-by: Martin Panter (vadmium) Co-authored-by: Robert Marshall (kellinm)
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac186
1 files changed, 109 insertions, 77 deletions
diff --git a/configure.ac b/configure.ac
index 1f5a008388a..60c5d8e0b5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4891,92 +4891,124 @@ then
[Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
fi
+AC_ARG_WITH([readline],
+ [AS_HELP_STRING([--with(out)-readline@<:@=editline@:>@],
+ [use Editline for backend or disable readline module])],
+ [],
+ [with_readline=yes])
+
# check where readline lives
+py_cv_lib_readline=no
# save the value of LIBS so we don't actually link Python with readline
LIBS_no_readline=$LIBS
-# On some systems we need to link readline to a termcap compatible
-# library. NOTE: Keep the precedence of listed libraries synchronised
-# with setup.py.
-py_cv_lib_readline=no
-AC_MSG_CHECKING([how to link readline libs])
-for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
- if test -z "$py_libtermcap"; then
- READLINE_LIBS="-lreadline"
+if test "$with_readline" != no; then
+ case "$with_readline" in
+ editline|edit)
+ LIBREADLINE=edit
+ AC_DEFINE(WITH_EDITLINE, 1,
+ [Define to build the readline module against Editline.])
+ ;;
+ yes|readline)
+ LIBREADLINE=readline
+ ;;
+ *)
+ AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline@:>@])
+ ;;
+ esac
+
+ # On some systems we need to link readline to a termcap compatible
+ # library. NOTE: Keep the precedence of listed libraries synchronised
+ # with setup.py.
+ AC_MSG_CHECKING([how to link readline libs])
+ for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
+ if test -z "$py_libtermcap"; then
+ READLINE_LIBS="-l$LIBREADLINE"
+ else
+ READLINE_LIBS="-l$LIBREADLINE -l$py_libtermcap"
+ fi
+ LIBS="$READLINE_LIBS $LIBS_no_readline"
+ AC_LINK_IFELSE(
+ [AC_LANG_CALL([],[readline])],
+ [py_cv_lib_readline=yes])
+ if test $py_cv_lib_readline = yes; then
+ break
+ fi
+ done
+
+ # Uncomment this line if you want to use READLINE_LIBS in Makefile or scripts
+ #AC_SUBST([READLINE_LIBS])
+ if test $py_cv_lib_readline = no; then
+ AC_MSG_RESULT([none])
else
- READLINE_LIBS="-lreadline -l$py_libtermcap"
+ AC_MSG_RESULT([$READLINE_LIBS])
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define to build the readline module.])
fi
- LIBS="$READLINE_LIBS $LIBS_no_readline"
- AC_LINK_IFELSE(
- [AC_LANG_CALL([],[readline])],
- [py_cv_lib_readline=yes])
- if test $py_cv_lib_readline = yes; then
- break
- fi
-done
-# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
-#AC_SUBST([READLINE_LIBS])
-if test $py_cv_lib_readline = no; then
- AC_MSG_RESULT([none])
-else
- AC_MSG_RESULT([$READLINE_LIBS])
- AC_DEFINE(HAVE_LIBREADLINE, 1,
- [Define if you have the readline library (-lreadline).])
fi
-# check for readline 2.2
-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
- [have_readline=yes],
- [have_readline=no]
-)
-if test $have_readline = yes
-then
- AC_EGREP_HEADER([extern int rl_completion_append_character;],
- [readline/readline.h],
- AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
- [Define if you have readline 2.2]), )
- AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
- [readline/readline.h],
- AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
- [Define if you have rl_completion_suppress_append]), )
-fi
-
-# check for readline 4.0
-AC_CHECK_LIB(readline, rl_pre_input_hook,
- AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
- [Define if you have readline 4.0]), ,$READLINE_LIBS)
-
-# also in 4.0
-AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
- AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
- [Define if you have readline 4.0]), ,$READLINE_LIBS)
-
-# also in 4.0, but not in editline
-AC_CHECK_LIB(readline, rl_resize_terminal,
- AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
- [Define if you have readline 4.0]), ,$READLINE_LIBS)
-
-# check for readline 4.2
-AC_CHECK_LIB(readline, rl_completion_matches,
- AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
- [Define if you have readline 4.2]), ,$READLINE_LIBS)
-
-# also in readline 4.2
-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
- [have_readline=yes],
- [have_readline=no]
-)
-if test $have_readline = yes
-then
- AC_EGREP_HEADER([extern int rl_catch_signals;],
- [readline/readline.h],
- AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
- [Define if you can turn off readline's signal handling.]), )
-fi
+if test "$py_cv_lib_readline" = yes; then
+ # check for readline 2.2
+ AC_CHECK_DECL(rl_completion_append_character,
+ AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
+ [Define if you have readline 2.2]),,
+ [
+#include <stdio.h> /* Must be first for Gnu Readline */
+#ifdef WITH_EDITLINE
+# include <editline/readline.h>
+#else
+# include <readline/readline.h>
+#endif
+ ])
+ AC_CHECK_DECL(rl_completion_suppress_append,
+ AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
+ [Define if you have rl_completion_suppress_append]),,
+ [
+#include <stdio.h> /* Must be first for Gnu Readline */
+#ifdef WITH_EDITLINE
+# include <editline/readline.h>
+#else
+# include <readline/readline.h>
+#endif
+ ])
-AC_CHECK_LIB(readline, append_history,
- AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
- [Define if readline supports append_history]), ,$READLINE_LIBS)
+ # check for readline 4.0
+ AC_CHECK_LIB($LIBREADLINE, rl_pre_input_hook,
+ AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
+ [Define if you have readline 4.0]),,$READLINE_LIBS)
+
+ # also in 4.0
+ AC_CHECK_LIB($LIBREADLINE, rl_completion_display_matches_hook,
+ AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
+ [Define if you have readline 4.0]),,$READLINE_LIBS)
+
+ # also in 4.0, but not in editline
+ AC_CHECK_LIB($LIBREADLINE, rl_resize_terminal,
+ AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
+ [Define if you have readline 4.0]),,$READLINE_LIBS)
+
+ # check for readline 4.2
+ AC_CHECK_LIB($LIBREADLINE, rl_completion_matches,
+ AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
+ [Define if you have readline 4.2]),,$READLINE_LIBS)
+
+ # also in readline 4.2
+ AC_CHECK_DECL(rl_catch_signals,
+ AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
+ [Define if you can turn off readline's signal handling.]),,
+ [
+#include <stdio.h> /* Must be first for Gnu Readline */
+#ifdef WITH_EDITLINE
+# include <editline/readline.h>
+#else
+# include <readline/readline.h>
+#endif
+ ])
+
+ AC_CHECK_LIB($LIBREADLINE, append_history,
+ AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
+ [Define if readline supports append_history]),,$READLINE_LIBS)
+fi
# End of readline checks: restore LIBS
LIBS=$LIBS_no_readline