source: rtems-source-builder/source-builder/config/gdb-common-1.cfg @ 13f4c37

5
Last change on this file since 13f4c37 was 13f4c37, checked in by Chris Johns <chrisj@…>, on 10/07/18 at 09:59:45

sb: Add support to search for a suitable version of python.

The command python has been removed from upstream python and python2
and python3 is now used. This patch wraps the commands in a shell
script that locates a suitable python to run.

Updates #3537

  • Property mode set to 100644
File size: 6.6 KB
Line 
1#
2# GDB Common Version 1.
3#
4# This configuration file configure's, make's and install's gdb.
5#
6
7#
8# Python
9#
10# GDB uses python internally so we need to link to a suitable python
11# dev kit. The dev kit for python is the header and a library. These
12# files are versioned where the header file is located in a directory
13# based on:
14#
15#  pythonM.m/Python.h
16#
17# where 'M' is the major version number and 'm' is the minor verison
18# number. The library is:
19#
20#  libpythonM.m.a
21#
22# The python command is 'pythonM' which means we need to query it for
23# the minor number.
24#
25# The python running the RSB may not be suitable, for example a MSC,
26# MSYS or Cygwin version on Windows when we want the MinGW python dev
27# file. A specific version cannot be forced because older versions of
28# GDB can only link to 'python2'.
29#
30# Host support can perform a complex query of the system, for example
31# Windows and set '%{gdb_python2}' and '%{gdb_python3}' with the full
32# path to that version's executable.
33#
34# A configuration of GDB can set the version required by setting
35# '%{gdb-python-version}' to the versions command, eg python2.
36#
37# The procedure is:
38#
39# 1. If the macros '%{gdb_python2}' or '%{gdb_python3}' are present
40#    use that path they contain. Assume the path is valid.
41#
42# 2. Does the version of gdb specify a version of python that must be
43#    used. Override with '%define gdb-python-version python2'.
44#
45# 3. Search for 'python2' and if not found search for 'python3'.
46#
47%if %{defined gdb-python2}
48  %define gdb-enable-python %{gdb_python2}
49%else
50  %if %{defined gdb-python3}
51    %define gdb-enable-python %{gdb_python3}
52  %else
53    %if %{defined gdb-python-version}
54      %define gdb-enable-python %(command -v %{gdb-python-version || true})
55    %else
56      %define gdb-enable-python %(command -v python2 || true)
57      %if %{gdb-enable-python} == %{nil}
58        %define gdb-enable-python %(command -v python3 || true)
59      %endif
60      %if %{gdb-enable-python} == %{nil}
61          %define gdb-enable-python %(command -v python || true})
62      %endif
63    %endif
64    %if %{gdb-enable-python} == %{nil}
65      %error "gdb: python: no valid version of python found"
66    %endif
67  %endif
68%endif
69
70#
71# Get the Python's major and minor version from the python
72# command. The headers and libraries are installed under a major/minor
73# (mm) version path and name.
74#
75# The library file name can vary across the hosts so wildcard the search.
76#
77%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
78%define gdb-python-ver-header python%{gdb-python-ver-mm}/Python.h
79%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.*
80%if %{host_includes} == %{nil}
81  %define gdb-host-incs %{nil}
82%else
83  %define gdb-host-incs -I '%{host_includes}'
84%endif
85%define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header})
86%if %{gdb-python-header-check} == not-found
87  %error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
88%endif
89#
90# Too hard to find on MacOS (darwin), the header is good enough.
91#
92%ifnos darwin
93  %if %{host_ldflags} == %{nil}
94    %define gdb-host-libs %{nil}
95  %else
96    %define gdb-host-libs -L '%{host_ldflags}'
97  %endif
98  %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
99  %if %{gdb-python-lib-check} == not-found
100    %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
101  %endif
102%endif
103
104#
105# See if the simulator has been disabled for Windows.
106#
107# Build using the system's readline, it is in better shape
108# than GDB's one with MSYS2.
109#
110%if %{_host_os} == win32
111 %if %{defined win32-gdb-disable-sim}
112  %define gdb-disable-sim 1
113 %endif
114 %define with_system_readline 1
115%endif
116
117#
118# Default to building simulators.
119#
120%ifn %{defined gdb-disable-sim}
121 %define gdb-disable-sim 0
122%else
123 %undefine gdb-sim-options
124%endif
125
126%include %{_configdir}/checks.cfg
127
128#
129# Select Snapshot Macro Maps
130#
131%select gdb-snapshot
132%select expat-snapshot
133
134#
135# The description.
136#
137Name:      %{_target}-gdb-%{gdb_version}-%{_host}-%{release}
138Summary:   GDB v%{gdb_version} for target %{_target} on host %{_host}
139Version:   %{gdb_version}
140Release:   %{release}
141URL:       http://www.gnu.org/software/gdb/
142BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
143
144#
145# GDB has changed it default extension.
146#
147%ifn %{defined gdb_src_ext}
148  %define gdb_src_ext gz
149%endif
150
151#
152# Source
153#
154%source set gdb http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
155
156#
157# Disable Python on Cxc builds for now.
158#
159%if "%{_build}" != "%{_host}"
160  %define without_python
161%endif
162
163#
164# The --with-python option is either the default which is auto or the path to
165# the specific python to be used.
166#
167%if %{defined with_python_path}
168  %define with_python_option --with-python=%{with_python_path}
169%else
170  %if %{defined gdb-enable-python}
171    %define with_python_option --with-python=%{gdb-enable-python}
172  %else
173    %define with_python_option --with-python
174  %endif
175%endif
176
177#
178#
179# Prepare the source code.
180#
181%prep
182  build_top=$(pwd)
183
184  gdb_source=%{?gdb_external:%{gdb_expand_name}}%{!?gdb_external:"gdb-%{gdb_version}"}
185
186  source_dir_gdb=${gdb_source}
187  %source setup gdb -q -n ${gdb_source}
188  %patch setup gdb -p1
189
190  cd ${build_top}
191
192%build
193  build_top=$(pwd)
194
195  %{build_directory}
196
197  mkdir -p ${build_dir}
198  cd ${build_dir}
199
200  %{host_build_flags}
201
202  if test "%{_build}" != "%{_host}" ; then
203    GDB_LIBS_STATIC="-lexpat"
204  else
205    GDB_LIBS_STATIC="-lexpat"
206    GDB_LIBS="%{_forced_static}"
207  fi
208
209  LIBS_STATIC=${GDB_LIBS_STATIC} \
210  LIBS=${GDB_LIBS} \
211  ../${source_dir_gdb}/configure \
212    --build=%{_build} --host=%{_host} \
213    --target=%{_target} \
214    --verbose --disable-nls \
215    --disable-gas --disable-binutils --disable-ld --disable-gold --disable-gprof \
216    %{?with_system_readline:--with-system-readline} \
217    --without-included-gettext \
218    --disable-win32-registry \
219    --disable-werror \
220    %{!?gdb-disable-sim:--enable-sim}%{?gdb-disable-sim:--disable-sim} \
221    %{?gdb-sim-options:%{gdb-sim-options}} \
222    --without-zlib \
223    --with-expat \
224    --with-guile=no \
225    %{!?without_python:%{with_python_option}} \
226    --prefix=%{_prefix} --bindir=%{_bindir} \
227    --exec-prefix=%{_exec_prefix} \
228    --includedir=%{_includedir} --libdir=%{_libdir} \
229    --mandir=%{_mandir} --infodir=%{_infodir}
230
231  %{__make} %{?_smp_mflags} all
232
233  cd ${build_top}
234
235%install
236  build_top=$(pwd)
237
238  %{__rmdir} $SB_BUILD_ROOT
239
240  cd ${build_dir}
241  %{__make} DESTDIR=$SB_BUILD_ROOT install
242
243  # Dropped in FSF-binutils-2.9.5, but Cygwin still ships it.
244  %{__rmdir} $SB_BUILD_ROOT%{_infodir}/configure.info*
245
246  %{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir
247  touch $SB_BUILD_ROOT%{_infodir}/dir
248
249  cd ${build_top}
Note: See TracBrowser for help on using the repository browser.