From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id A2A543858C51; Mon, 18 Jul 2022 10:34:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2A543858C51 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/python: look for python, then python 3 at configure time X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 7e864bf71d55626dce94df26ebaf11f65b4d7b65 X-Git-Newrev: 602d2b520dc5917c2353987032c881f79b34d634 Message-Id: <20220718103412.A2A543858C51@sourceware.org> Date: Mon, 18 Jul 2022 10:34:12 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2022 10:34:12 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D602d2b520dc5= 917c2353987032c881f79b34d634 commit 602d2b520dc5917c2353987032c881f79b34d634 Author: Andrew Burgess Date: Mon Jul 4 16:40:05 2022 +0100 gdb/python: look for python, then python 3 at configure time =20 It is possible that a system might have a python3 executable, but no python executable. For example, on my Fedora system the python2 package provides /usr/bin/python2, the python3 package provides /usr/bin/python3, and the python-unversioned-command package provides /usr/bin/python, which picks between python2 and python3. =20 It is quite possible to only have python3 available on a system. =20 Currently, when GDB configures, it looks for a 'python' executable. If non is found then GDB will be built without python support. Or the user needs to configure using --with-python=3D/usr/bin/python3. =20 This commit updates GDB's configure.ac script to first look for 'python', and then 'python3'. Now, on a system that only has a python3 executable, GDB will automatically find, and use that in order to provide python support, no user supplied configure arguments are needed. =20 I've tested this on my local machine by removing the python-unversioned-command package, confirming that there is no longer a 'python' executable in my $PATH, and then rebuilding GDB from scratch. GDB with this patch has python support. Diff: --- gdb/configure | 12 +++++++++--- gdb/configure.ac | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/configure b/gdb/configure index 1b821390801..4b5e031bff9 100755 --- a/gdb/configure +++ b/gdb/configure @@ -11098,8 +11098,11 @@ else case "${with_python}" in yes | auto) if test "${build}" =3D "${host}"; then - # Extract the first word of "python", so it can be a program name = with args. -set dummy python; ac_word=3D$2 + # Look first for 'python', then 'python3'. + for ac_prog in python python3 +do + # Extract the first word of "$ac_prog", so it can be a program name with= args. +set dummy $ac_prog; ac_word=3D$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_python_prog_path+:} false; then : @@ -11125,7 +11128,6 @@ done done IFS=3D$as_save_IFS =20 - test -z "$ac_cv_path_python_prog_path" && ac_cv_path_python_prog_path=3D= "missing" ;; esac fi @@ -11139,6 +11141,10 @@ $as_echo "no" >&6; } fi =20 =20 + test -n "$python_prog_path" && break +done +test -n "$python_prog_path" || python_prog_path=3D"missing" + if test "${python_prog_path}" =3D missing; then python_prog=3Dmissing else diff --git a/gdb/configure.ac b/gdb/configure.ac index bf03b875dfe..b681988d7a4 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -811,7 +811,8 @@ else case "${with_python}" in yes | auto) if test "${build}" =3D "${host}"; then - AC_PATH_PROG(python_prog_path, python, missing) + # Look first for 'python', then 'python3'. + AC_PATH_PROGS(python_prog_path, [python python3], missing) if test "${python_prog_path}" =3D missing; then python_prog=3Dmissing else