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
7105319ada (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)
This commit is contained in:
Roland Hieber 2021-02-09 02:05:25 +01:00 committed by GitHub
parent bf2e7e55d7
commit e1f7769513
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 275 additions and 207 deletions

View file

@ -0,0 +1,2 @@
The configure script can now use *libedit* instead of *readline* with the
command line option ``--with-readline=editline``.

View file

@ -26,10 +26,14 @@
# define RESTORE_LOCALE(sl) # define RESTORE_LOCALE(sl)
#endif #endif
#ifdef WITH_EDITLINE
# include <editline/readline.h>
#else
/* GNU readline definitions */ /* GNU readline definitions */
# undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */ # undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
# include <readline/readline.h> # include <readline/readline.h>
# include <readline/history.h> # include <readline/history.h>
#endif
#ifdef HAVE_RL_COMPLETION_MATCHES #ifdef HAVE_RL_COMPLETION_MATCHES
#define completion_matches(x, y) \ #define completion_matches(x, y) \

214
configure vendored
View file

@ -849,6 +849,7 @@ with_libc
enable_big_digits enable_big_digits
with_platlibdir with_platlibdir
with_wheel_pkg_dir with_wheel_pkg_dir
with_readline
with_computed_gotos with_computed_gotos
with_ensurepip with_ensurepip
with_openssl with_openssl
@ -1581,6 +1582,8 @@ Optional Packages:
--with-wheel-pkg-dir=PATH --with-wheel-pkg-dir=PATH
Directory of wheel packages used by ensurepip Directory of wheel packages used by ensurepip
(default: none) (default: none)
--with(out)-readline[=editline]
use Editline for backend or disable readline module
--with-computed-gotos enable computed gotos in evaluation loop (enabled by --with-computed-gotos enable computed gotos in evaluation loop (enabled by
default on supported compilers) default on supported compilers)
--with-ensurepip[=install|upgrade|no] --with-ensurepip[=install|upgrade|no]
@ -15602,21 +15605,46 @@ $as_echo "#define HAVE_GETC_UNLOCKED 1" >>confdefs.h
fi fi
# Check whether --with-readline was given.
if test "${with_readline+set}" = set; then :
withval=$with_readline;
else
with_readline=yes
fi
# check where readline lives # check where readline lives
py_cv_lib_readline=no
# save the value of LIBS so we don't actually link Python with readline # save the value of LIBS so we don't actually link Python with readline
LIBS_no_readline=$LIBS LIBS_no_readline=$LIBS
if test "$with_readline" != no; then
case "$with_readline" in
editline|edit)
LIBREADLINE=edit
$as_echo "#define WITH_EDITLINE 1" >>confdefs.h
;;
yes|readline)
LIBREADLINE=readline
;;
*)
as_fn_error $? "proper usage is --with(out)-readline[=editline]" "$LINENO" 5
;;
esac
# On some systems we need to link readline to a termcap compatible # On some systems we need to link readline to a termcap compatible
# library. NOTE: Keep the precedence of listed libraries synchronised # library. NOTE: Keep the precedence of listed libraries synchronised
# with setup.py. # with setup.py.
py_cv_lib_readline=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link readline libs" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link readline libs" >&5
$as_echo_n "checking how to link readline libs... " >&6; } $as_echo_n "checking how to link readline libs... " >&6; }
for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
if test -z "$py_libtermcap"; then if test -z "$py_libtermcap"; then
READLINE_LIBS="-lreadline" READLINE_LIBS="-l$LIBREADLINE"
else else
READLINE_LIBS="-lreadline -l$py_libtermcap" READLINE_LIBS="-l$LIBREADLINE -l$py_libtermcap"
fi fi
LIBS="$READLINE_LIBS $LIBS_no_readline" LIBS="$READLINE_LIBS $LIBS_no_readline"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@ -15646,7 +15674,8 @@ rm -f core conftest.err conftest.$ac_objext \
break break
fi fi
done done
# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
# Uncomment this line if you want to use READLINE_LIBS in Makefile or scripts
#AC_SUBST([READLINE_LIBS]) #AC_SUBST([READLINE_LIBS])
if test $py_cv_lib_readline = no; then if test $py_cv_lib_readline = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
@ -15658,57 +15687,50 @@ $as_echo "$READLINE_LIBS" >&6; }
$as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
fi fi
# check for readline 2.2
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <readline/readline.h>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
have_readline=yes
else
have_readline=no
fi fi
rm -f conftest.err conftest.i conftest.$ac_ext
if test $have_readline = yes
then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <readline/readline.h>
_ACEOF if test "$py_cv_lib_readline" = yes; then
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | # check for readline 2.2
$EGREP "extern int rl_completion_append_character;" >/dev/null 2>&1; then : ac_fn_c_check_decl "$LINENO" "rl_completion_append_character" "ac_cv_have_decl_rl_completion_append_character" "
#include <stdio.h> /* Must be first for Gnu Readline */
#ifdef WITH_EDITLINE
# include <editline/readline.h>
#else
# include <readline/readline.h>
#endif
"
if test "x$ac_cv_have_decl_rl_completion_append_character" = xyes; then :
$as_echo "#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1" >>confdefs.h $as_echo "#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1" >>confdefs.h
fi fi
rm -f conftest*
cat confdefs.h - <<_ACEOF >conftest.$ac_ext ac_fn_c_check_decl "$LINENO" "rl_completion_suppress_append" "ac_cv_have_decl_rl_completion_suppress_append" "
/* end confdefs.h. */ #include <stdio.h> /* Must be first for Gnu Readline */
#ifdef WITH_EDITLINE
# include <editline/readline.h>
#else
# include <readline/readline.h> # include <readline/readline.h>
#endif
_ACEOF "
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | if test "x$ac_cv_have_decl_rl_completion_suppress_append" = xyes; then :
$EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then :
$as_echo "#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1" >>confdefs.h $as_echo "#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1" >>confdefs.h
fi fi
rm -f conftest*
fi
# check for readline 4.0 # check for readline 4.0
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5 as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_pre_input_hook" | $as_tr_sh`
$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -l$LIBREADLINE" >&5
if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then : $as_echo_n "checking for rl_pre_input_hook in -l$LIBREADLINE... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS" LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -15728,17 +15750,18 @@ return rl_pre_input_hook ();
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_rl_pre_input_hook=yes eval "$as_ac_Lib=yes"
else else
ac_cv_lib_readline_rl_pre_input_hook=no eval "$as_ac_Lib=no"
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_pre_input_hook" >&5 eval ac_res=\$$as_ac_Lib
$as_echo "$ac_cv_lib_readline_rl_pre_input_hook" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
if test "x$ac_cv_lib_readline_rl_pre_input_hook" = xyes; then : $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
$as_echo "#define HAVE_RL_PRE_INPUT_HOOK 1" >>confdefs.h $as_echo "#define HAVE_RL_PRE_INPUT_HOOK 1" >>confdefs.h
@ -15746,13 +15769,14 @@ fi
# also in 4.0 # also in 4.0
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5 as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_completion_display_matches_hook" | $as_tr_sh`
$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -l$LIBREADLINE" >&5
if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then : $as_echo_n "checking for rl_completion_display_matches_hook in -l$LIBREADLINE... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS" LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -15772,17 +15796,18 @@ return rl_completion_display_matches_hook ();
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_rl_completion_display_matches_hook=yes eval "$as_ac_Lib=yes"
else else
ac_cv_lib_readline_rl_completion_display_matches_hook=no eval "$as_ac_Lib=no"
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_display_matches_hook" >&5 eval ac_res=\$$as_ac_Lib
$as_echo "$ac_cv_lib_readline_rl_completion_display_matches_hook" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
if test "x$ac_cv_lib_readline_rl_completion_display_matches_hook" = xyes; then : $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
$as_echo "#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1" >>confdefs.h $as_echo "#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1" >>confdefs.h
@ -15790,13 +15815,14 @@ fi
# also in 4.0, but not in editline # also in 4.0, but not in editline
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_resize_terminal in -lreadline" >&5 as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_resize_terminal" | $as_tr_sh`
$as_echo_n "checking for rl_resize_terminal in -lreadline... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_resize_terminal in -l$LIBREADLINE" >&5
if ${ac_cv_lib_readline_rl_resize_terminal+:} false; then : $as_echo_n "checking for rl_resize_terminal in -l$LIBREADLINE... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS" LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -15816,17 +15842,18 @@ return rl_resize_terminal ();
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_rl_resize_terminal=yes eval "$as_ac_Lib=yes"
else else
ac_cv_lib_readline_rl_resize_terminal=no eval "$as_ac_Lib=no"
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_resize_terminal" >&5 eval ac_res=\$$as_ac_Lib
$as_echo "$ac_cv_lib_readline_rl_resize_terminal" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
if test "x$ac_cv_lib_readline_rl_resize_terminal" = xyes; then : $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
$as_echo "#define HAVE_RL_RESIZE_TERMINAL 1" >>confdefs.h $as_echo "#define HAVE_RL_RESIZE_TERMINAL 1" >>confdefs.h
@ -15834,13 +15861,14 @@ fi
# check for readline 4.2 # check for readline 4.2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5 as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_completion_matches" | $as_tr_sh`
$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -l$LIBREADLINE" >&5
if ${ac_cv_lib_readline_rl_completion_matches+:} false; then : $as_echo_n "checking for rl_completion_matches in -l$LIBREADLINE... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS" LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -15860,17 +15888,18 @@ return rl_completion_matches ();
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_rl_completion_matches=yes eval "$as_ac_Lib=yes"
else else
ac_cv_lib_readline_rl_completion_matches=no eval "$as_ac_Lib=no"
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_matches" >&5 eval ac_res=\$$as_ac_Lib
$as_echo "$ac_cv_lib_readline_rl_completion_matches" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
if test "x$ac_cv_lib_readline_rl_completion_matches" = xyes; then : $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
$as_echo "#define HAVE_RL_COMPLETION_MATCHES 1" >>confdefs.h $as_echo "#define HAVE_RL_COMPLETION_MATCHES 1" >>confdefs.h
@ -15878,41 +15907,30 @@ fi
# also in readline 4.2 # also in readline 4.2
cat confdefs.h - <<_ACEOF >conftest.$ac_ext ac_fn_c_check_decl "$LINENO" "rl_catch_signals" "ac_cv_have_decl_rl_catch_signals" "
/* end confdefs.h. */ #include <stdio.h> /* Must be first for Gnu Readline */
#ifdef WITH_EDITLINE
# include <editline/readline.h>
#else
# include <readline/readline.h> # include <readline/readline.h>
_ACEOF #endif
if ac_fn_c_try_cpp "$LINENO"; then :
have_readline=yes
else
have_readline=no
fi "
rm -f conftest.err conftest.i conftest.$ac_ext if test "x$ac_cv_have_decl_rl_catch_signals" = xyes; then :
if test $have_readline = yes
then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <readline/readline.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "extern int rl_catch_signals;" >/dev/null 2>&1; then :
$as_echo "#define HAVE_RL_CATCH_SIGNAL 1" >>confdefs.h $as_echo "#define HAVE_RL_CATCH_SIGNAL 1" >>confdefs.h
fi fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for append_history in -lreadline" >&5 as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_append_history" | $as_tr_sh`
$as_echo_n "checking for append_history in -lreadline... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for append_history in -l$LIBREADLINE" >&5
if ${ac_cv_lib_readline_append_history+:} false; then : $as_echo_n "checking for append_history in -l$LIBREADLINE... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $READLINE_LIBS $LIBS" LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -15932,22 +15950,24 @@ return append_history ();
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_append_history=yes eval "$as_ac_Lib=yes"
else else
ac_cv_lib_readline_append_history=no eval "$as_ac_Lib=no"
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_append_history" >&5 eval ac_res=\$$as_ac_Lib
$as_echo "$ac_cv_lib_readline_append_history" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
if test "x$ac_cv_lib_readline_append_history" = xyes; then : $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
$as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h $as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h
fi fi
fi
# End of readline checks: restore LIBS # End of readline checks: restore LIBS
LIBS=$LIBS_no_readline LIBS=$LIBS_no_readline

View file

@ -4891,20 +4891,41 @@ then
[Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
fi 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 # check where readline lives
py_cv_lib_readline=no
# save the value of LIBS so we don't actually link Python with readline # save the value of LIBS so we don't actually link Python with readline
LIBS_no_readline=$LIBS LIBS_no_readline=$LIBS
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 # On some systems we need to link readline to a termcap compatible
# library. NOTE: Keep the precedence of listed libraries synchronised # library. NOTE: Keep the precedence of listed libraries synchronised
# with setup.py. # with setup.py.
py_cv_lib_readline=no
AC_MSG_CHECKING([how to link readline libs]) AC_MSG_CHECKING([how to link readline libs])
for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
if test -z "$py_libtermcap"; then if test -z "$py_libtermcap"; then
READLINE_LIBS="-lreadline" READLINE_LIBS="-l$LIBREADLINE"
else else
READLINE_LIBS="-lreadline -l$py_libtermcap" READLINE_LIBS="-l$LIBREADLINE -l$py_libtermcap"
fi fi
LIBS="$READLINE_LIBS $LIBS_no_readline" LIBS="$READLINE_LIBS $LIBS_no_readline"
AC_LINK_IFELSE( AC_LINK_IFELSE(
@ -4914,69 +4935,80 @@ for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
break break
fi fi
done done
# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
# Uncomment this line if you want to use READLINE_LIBS in Makefile or scripts
#AC_SUBST([READLINE_LIBS]) #AC_SUBST([READLINE_LIBS])
if test $py_cv_lib_readline = no; then if test $py_cv_lib_readline = no; then
AC_MSG_RESULT([none]) AC_MSG_RESULT([none])
else else
AC_MSG_RESULT([$READLINE_LIBS]) AC_MSG_RESULT([$READLINE_LIBS])
AC_DEFINE(HAVE_LIBREADLINE, 1, AC_DEFINE(HAVE_LIBREADLINE, 1,
[Define if you have the readline library (-lreadline).]) [Define to build the readline module.])
fi
fi fi
if test "$py_cv_lib_readline" = yes; then
# check for readline 2.2 # check for readline 2.2
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], AC_CHECK_DECL(rl_completion_append_character,
[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, AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
[Define if you have readline 2.2]), ) [Define if you have readline 2.2]),,
AC_EGREP_HEADER([extern int rl_completion_suppress_append;], [
[readline/readline.h], #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, AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
[Define if you have rl_completion_suppress_append]), ) [Define if you have rl_completion_suppress_append]),,
fi [
#include <stdio.h> /* Must be first for Gnu Readline */
#ifdef WITH_EDITLINE
# include <editline/readline.h>
#else
# include <readline/readline.h>
#endif
])
# check for readline 4.0 # check for readline 4.0
AC_CHECK_LIB(readline, rl_pre_input_hook, AC_CHECK_LIB($LIBREADLINE, rl_pre_input_hook,
AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
[Define if you have readline 4.0]),,$READLINE_LIBS) [Define if you have readline 4.0]),,$READLINE_LIBS)
# also in 4.0 # also in 4.0
AC_CHECK_LIB(readline, rl_completion_display_matches_hook, AC_CHECK_LIB($LIBREADLINE, rl_completion_display_matches_hook,
AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
[Define if you have readline 4.0]),,$READLINE_LIBS) [Define if you have readline 4.0]),,$READLINE_LIBS)
# also in 4.0, but not in editline # also in 4.0, but not in editline
AC_CHECK_LIB(readline, rl_resize_terminal, AC_CHECK_LIB($LIBREADLINE, rl_resize_terminal,
AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1, AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
[Define if you have readline 4.0]),,$READLINE_LIBS) [Define if you have readline 4.0]),,$READLINE_LIBS)
# check for readline 4.2 # check for readline 4.2
AC_CHECK_LIB(readline, rl_completion_matches, AC_CHECK_LIB($LIBREADLINE, rl_completion_matches,
AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
[Define if you have readline 4.2]),,$READLINE_LIBS) [Define if you have readline 4.2]),,$READLINE_LIBS)
# also in readline 4.2 # also in readline 4.2
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], AC_CHECK_DECL(rl_catch_signals,
[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, AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
[Define if you can turn off readline's signal handling.]), ) [Define if you can turn off readline's signal handling.]),,
fi [
#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_CHECK_LIB($LIBREADLINE, append_history,
AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1, AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
[Define if readline supports append_history]),,$READLINE_LIBS) [Define if readline supports append_history]),,$READLINE_LIBS)
fi
# End of readline checks: restore LIBS # End of readline checks: restore LIBS
LIBS=$LIBS_no_readline LIBS=$LIBS_no_readline

View file

@ -610,7 +610,7 @@
/* Define to 1 if you have the <libintl.h> header file. */ /* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H #undef HAVE_LIBINTL_H
/* Define if you have the readline library (-lreadline). */ /* Define to build the readline module. */
#undef HAVE_LIBREADLINE #undef HAVE_LIBREADLINE
/* Define to 1 if you have the `resolv' library (-lresolv). */ /* Define to 1 if you have the `resolv' library (-lresolv). */
@ -1554,6 +1554,9 @@
Dyld is necessary to support frameworks. */ Dyld is necessary to support frameworks. */
#undef WITH_DYLD #undef WITH_DYLD
/* Define to build the readline module against Editline. */
#undef WITH_EDITLINE
/* Define to 1 if libintl is needed for locale functions. */ /* Define to 1 if libintl is needed for locale functions. */
#undef WITH_LIBINTL #undef WITH_LIBINTL

View file

@ -1022,7 +1022,6 @@ class PyBuildExt(build_ext):
def detect_readline_curses(self): def detect_readline_curses(self):
# readline # readline
do_readline = self.compiler.find_library_file(self.lib_dirs, 'readline')
readline_termcap_library = "" readline_termcap_library = ""
curses_library = "" curses_library = ""
# Cannot use os.popen here in py3k. # Cannot use os.popen here in py3k.
@ -1030,7 +1029,13 @@ class PyBuildExt(build_ext):
if not os.path.exists(self.build_temp): if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp) os.makedirs(self.build_temp)
# Determine if readline is already linked against curses or tinfo. # Determine if readline is already linked against curses or tinfo.
if do_readline: if sysconfig.get_config_var('HAVE_LIBREADLINE'):
if sysconfig.get_config_var('WITH_EDITLINE'):
readline_lib = 'edit'
else:
readline_lib = 'readline'
do_readline = self.compiler.find_library_file(self.lib_dirs,
readline_lib)
if CROSS_COMPILING: if CROSS_COMPILING:
ret = run_command("%s -d %s | grep '(NEEDED)' > %s" ret = run_command("%s -d %s | grep '(NEEDED)' > %s"
% (sysconfig.get_config_var('READELF'), % (sysconfig.get_config_var('READELF'),
@ -1053,6 +1058,8 @@ class PyBuildExt(build_ext):
break break
if os.path.exists(tmpfile): if os.path.exists(tmpfile):
os.unlink(tmpfile) os.unlink(tmpfile)
else:
do_readline = False
# Issue 7384: If readline is already linked against curses, # Issue 7384: If readline is already linked against curses,
# use the same library for the readline and curses modules. # use the same library for the readline and curses modules.
if 'curses' in readline_termcap_library: if 'curses' in readline_termcap_library:
@ -1092,7 +1099,7 @@ class PyBuildExt(build_ext):
else: else:
readline_extra_link_args = () readline_extra_link_args = ()
readline_libs = ['readline'] readline_libs = [readline_lib]
if readline_termcap_library: if readline_termcap_library:
pass # Issue 7384: Already linked against curses or tinfo. pass # Issue 7384: Already linked against curses or tinfo.
elif curses_library: elif curses_library: