summaryrefslogtreecommitdiffstats
path: root/source-builder/config/gdb-common-1.cfg
diff options
context:
space:
mode:
Diffstat (limited to 'source-builder/config/gdb-common-1.cfg')
-rw-r--r--source-builder/config/gdb-common-1.cfg86
1 files changed, 60 insertions, 26 deletions
diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
index 397d44d..49bf673 100644
--- a/source-builder/config/gdb-common-1.cfg
+++ b/source-builder/config/gdb-common-1.cfg
@@ -42,8 +42,27 @@
# 2. Does the version of gdb specify a version of python that must be
# used. Override with '%define gdb-python-version python2'.
#
-# 3. Search for 'python2' and if not found search for 'python3'.
+# 3. Search for 'python3' and if not found search for 'python2'.
#
+# User options to help find a suitable python:
+#
+# --with-python2 : name of a python2 command
+#
+# --with-python3 : name of a python2 command
+#
+# --with-python-version : name of a python command with a specific version
+#
+# For example `--with-python-version=python3.6
+#
+%if %{defined with_python2}
+ %define gdb-python2 %{with_python2}
+%endif
+%if %{defined with_python3}
+ %define gdb-python3 %{with_python3}
+%endif
+%if %{defined with_python_version}
+ %define gdb-python-version %{with_python_version}
+%endif
%if %{defined gdb-python2}
%define gdb-enable-python %{gdb_python2}
%else
@@ -53,12 +72,12 @@
%if %{defined gdb-python-version}
%define gdb-enable-python %(command -v %{gdb-python-version} || true)
%else
- %define gdb-enable-python %(command -v python2 || true)
+ %define gdb-enable-python %(command -v python3 || true)
%if %{gdb-enable-python} == %{nil}
- %define gdb-enable-python %(command -v python3 || true)
+ %define gdb-enable-python %(command -v python2 || true)
%endif
%if %{gdb-enable-python} == %{nil}
- %define gdb-enable-python %(command -v python || true})
+ %define gdb-enable-python %(command -v python || true})
%endif
%endif
%if %{gdb-enable-python} == %{nil}
@@ -79,8 +98,13 @@
%endif
%if %{gdb-python-config} == %{nil}
%define gdb-python-config %(command -v %{gdb-enable-python}-config || true)
+ %if %{gdb-python-config} == %{nil}
+ %define gdb-python-config %(command -v %(basename %{gdb-enable-python})-config || true)
+ %endif
%endif
%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
+%define gdb-python-ver-major %(echo "%{gdb-python-ver-mm}" | sed -e 's/\..*//')
+%define gdb-python-ver-minor %(echo "%{gdb-python-ver-mm}" | sed -e 's/.*\.//')
%define gdb-python-header Python.h
%define gdb-python-ver-header python%{gdb-python-ver-mm}/%{gdb-python-header}
%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.*
@@ -98,29 +122,39 @@
%if %{gdb-python-header-check} == not-found && !%{_rsb_getting_source}
%error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
%endif
-#
-# Too hard to find on MacOS (darwin), the header is good enough.
-#
-%ifnos darwin
- %if %{host_ldflags} == %{nil}
- %define gdb-host-libs %{nil}
- %else
- %define gdb-host-libs -L '%{host_ldflags}'
- %endif
- %if %{gdb-python-config} != %{nil}
- %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"*";}'
- %if %{gdb-python-ver-mm} < 3.8
- %define gdb-python-config-lib-check-flags --ldflags
- %else
- %define gdb-python-config-lib-check-flags --ldflags --embed
- %endif
- %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-config-libs})
+%if %{host_ldflags} == %{nil}
+ %define gdb-host-libs %{nil}
+%else
+ %define gdb-host-libs -L '%{host_ldflags}'
+%endif
+%if %{gdb-python-config} != %{nil}
+ %define gdb-python-lib-filter awk '{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"\\*";}'
+ %define gdb-python-libpath-filter awk '{for(i=1;i<NF;++i) if (match($i,"-L.*") == 1) l[substr($i,3)]=1;} END{for(i in l) printf("-L " i " "); printf("\n");}'
+ %if %{gdb-python-ver-major} < 3 || \
+ %{gdb-python-ver-major} == 3 && %{gdb-python-ver-minor} < 8
+ %define gdb-python-config-lib-check-flags --ldflags
%else
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+ %define gdb-python-config-lib-check-flags --ldflags --embed
%endif
- %if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
- %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+ %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
+ %define gdb-python-config-libpath %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-libpath-filter} | uniq)
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} %{gdb-python-config-libpath} -l %{gdb-python-config-libs})
+%else
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+%endif
+%if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
+ %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+%endif
+
+#
+# If in a virtual environment use that as GDB will look 'bin/python' under it
+# Supportted in GDB 13 and later.
+#
+%define gdb_version_major %(echo "%{gdb_version}" | sed -e 's/\..*//')
+%if %{gdb_version_major} >= 13
+ %define python-venv %(echo $VIRTUAL_ENV)
+ %if %{python-venv} != %{nil}
+ %define gdb-enable-python %{python-venv}
%endif
%endif
@@ -173,7 +207,7 @@ URL: http://www.gnu.org/software/gdb/
#
# Source
#
-%source set gdb http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
+%source set gdb https://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
#
# Disable Python on Cxc builds for now.