# # GDB Common Version 1. # # This configuration file configure's, make's and install's gdb. # # # Python # # GDB uses python internally so we need to link to a suitable python # dev kit. The dev kit for python is the header and a library. These # files are versioned where the header file is located in a directory # based on: # # pythonM.m/Python.h # # where 'M' is the major version number and 'm' is the minor verison # number. The library is: # # libpythonM.m.a # # The python command is 'pythonM' which means we need to query it for # the minor number. # # The python running the RSB may not be suitable, for example a MSC, # MSYS or Cygwin version on Windows when we want the MinGW python dev # file. A specific version cannot be forced because older versions of # GDB can only link to 'python2'. # # Host support can perform a complex query of the system, for example # Windows and set '%{gdb_python2}' and '%{gdb_python3}' with the full # path to that version's executable. # # A configuration of GDB can set the version required by setting # '%{gdb-python-version}' to the versions command, eg python2. # # The procedure is: # # 1. If the macros '%{gdb_python2}' or '%{gdb_python3}' are present # use that path they contain. Assume the path is valid. # # 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'. # %if !%{defined without_python} %if %{defined gdb-python2} %define gdb-enable-python %{gdb_python2} %else %if %{defined gdb-python3} %define gdb-enable-python %{gdb_python3} %else %if %{defined gdb-python-version} %define gdb-enable-python %(command -v %{gdb-python-version} || true) %else %define gdb-enable-python %(command -v python2 || true) %if %{gdb-enable-python} == %{nil} %define gdb-enable-python %(command -v python3 || true) %endif %if %{gdb-enable-python} == %{nil} %define gdb-enable-python %(command -v python || true}) %endif %endif %if %{gdb-enable-python} == %{nil} %error "gdb: python: no valid version of python found" %endif %endif %endif # # Get the Python's major and minor version from the python # command. The headers and libraries are installed under a major/minor # (mm) version path and name. # # 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-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 %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 && !%{_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