[PATCH 2/2] gdb/python: Use python-config for the configuration if found.

chrisj at rtems.org chrisj at rtems.org
Tue Dec 18 04:25:06 UTC 2018


From: Chris Johns <chrisj at rtems.org>

- Do not assume the installed paths for the header and library.
  Ask python-config if found.

Close #3537.
---
 source-builder/config/gdb-common-1.cfg | 25 +++++++++++++++++++++----
 source-builder/sb/rtems-build-dep      |  2 +-
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
index 45df5e9..9018448 100644
--- a/source-builder/config/gdb-common-1.cfg
+++ b/source-builder/config/gdb-common-1.cfg
@@ -51,7 +51,7 @@
     %define gdb-enable-python %{gdb_python3}
   %else
     %if %{defined gdb-python-version}
-      %define gdb-enable-python %(command -v %{gdb-python-version || true})
+      %define gdb-enable-python %(command -v %{gdb-python-version} || true)
     %else
       %define gdb-enable-python %(command -v python2 || true)
       %if %{gdb-enable-python} == %{nil}
@@ -74,15 +74,27 @@
 #
 # The library file name can vary across the hosts so wildcard the search.
 #
+%if %{!defined gdb-python-config}
+  %define gdb-python-config %{nil}
+%endif
+%if %{gdb-python-config} == %{nil}
+ %define gdb-python-config %(command -v %{gdb-enable-python}-config || true)
+%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-header python%{gdb-python-ver-mm}/Python.h
+%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}.*
 %if %{host_includes} == %{nil}
   %define gdb-host-incs %{nil}
 %else
   %define gdb-host-incs -I '%{host_includes}'
 %endif
-%define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header})
+%if %{gdb-python-config} != %{nil}
+  %define gdb-python-config-incs -I '%(%{gdb-python-config} --includes)'
+  %define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} %{gdb-python-config-incs} -H %{gdb-python-header})
+%else
+  %define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header})
+%endif
 %if %{gdb-python-header-check} == not-found
   %error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
 %endif
@@ -95,7 +107,12 @@
   %else
     %define gdb-host-libs -L '%{host_ldflags}'
   %endif
-  %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+  %if %{gdb-python-config} != %{nil}
+    %define gdb-python-config-libs -l '%(%{gdb-python-config} --ldflags)'
+    %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} %{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
     %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
   %endif
diff --git a/source-builder/sb/rtems-build-dep b/source-builder/sb/rtems-build-dep
index 3a82753..7e406c5 100755
--- a/source-builder/sb/rtems-build-dep
+++ b/source-builder/sb/rtems-build-dep
@@ -72,7 +72,7 @@ do
 		echo 'error: no header path (-I) provided'
 		exit 2
 	    fi
-            includes="$2"; shift;
+            includes="${includes} $2"; shift;
             shift;;
 	-l)
 	    if [ $# -eq 1 ]; then
-- 
2.19.1




More information about the devel mailing list