gdb/python: Use python-config for the configuration if found.

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

Close #3537.
This commit is contained in:
Chris Johns
2018-12-18 15:09:37 +11:00
parent c2d2338759
commit 257c9267cf
2 changed files with 22 additions and 5 deletions

View File

@@ -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

View File

@@ -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