source: rtems-source-builder/source-builder/config/gdb-common-1.cfg @ 8de6b67

5
Last change on this file since 8de6b67 was 8de6b67, checked in by Chris Johns <chrisj@…>, on Oct 26, 2019 at 11:35:30 PM

sb/gdb: Add further getting source checks.

  • Property mode set to 100644
File size: 7.5 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%if %{!defined gdb-python-config}
78  %define gdb-python-config %{nil}
79%endif
80%if %{gdb-python-config} == %{nil}
81 %define gdb-python-config %(command -v %{gdb-enable-python}-config || true)
82%endif
83%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
84%define gdb-python-header Python.h
85%define gdb-python-ver-header python%{gdb-python-ver-mm}/%{gdb-python-header}
86%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.*
87%if %{host_includes} == %{nil}
88  %define gdb-host-incs %{nil}
89%else
90  %define gdb-host-incs -I '%{host_includes}'
91%endif
92%if %{gdb-python-config} != %{nil}
93  %define gdb-python-config-incs -I '%(%{gdb-python-config} --includes)'
94  %define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} %{gdb-python-config-incs} -H %{gdb-python-header})
95%else
96  %define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header})
97%endif
98%if %{gdb-python-header-check} == not-found && !%{_rsb_getting_source}
99  %error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
100%endif
101#
102# Too hard to find on MacOS (darwin), the header is good enough.
103#
104%ifnos darwin
105  %if %{host_ldflags} == %{nil}
106    %define gdb-host-libs %{nil}
107  %else
108    %define gdb-host-libs -L '%{host_ldflags}'
109  %endif
110  %if %{gdb-python-config} != %{nil}
111    %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"*";}'
112    %define gdb-python-config-libs %(%{gdb-python-config} --ldflags | %{gdb-python-lib-filter})
113    %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-config-libs})
114  %else
115    %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
116  %endif
117  %if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
118    %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
119  %endif
120%endif
121
122#
123# See if the simulator has been disabled for Windows.
124#
125# Build using the system's readline, it is in better shape
126# than GDB's one with MSYS2.
127#
128%if %{_host_os} == win32
129 %if %{defined win32-gdb-disable-sim}
130  %define gdb-disable-sim 1
131 %endif
132 %define with_system_readline 1
133%endif
134
135#
136# Default to building simulators.
137#
138%ifn %{defined gdb-disable-sim}
139 %define gdb-disable-sim 0
140%else
141 %undefine gdb-sim-options
142%endif
143
144%include %{_configdir}/checks.cfg
145
146#
147# Select Snapshot Macro Maps
148#
149%select gdb-snapshot
150%select expat-snapshot
151
152#
153# The description.
154#
155Name:      %{_target}-gdb-%{gdb_version}-%{_host}-%{release}
156Summary:   GDB v%{gdb_version} for target %{_target} on host %{_host}
157Version:   %{gdb_version}
158Release:   %{release}
159URL:       http://www.gnu.org/software/gdb/
160
161#
162# GDB has changed it default extension.
163#
164%ifn %{defined gdb_src_ext}
165  %define gdb_src_ext gz
166%endif
167
168#
169# Source
170#
171%source set gdb http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
172
173#
174# Disable Python on Cxc builds for now.
175#
176%if "%{_build}" != "%{_host}"
177  %define without_python
178%endif
179
180#
181# The --with-python option is either the default which is auto or the path to
182# the specific python to be used.
183#
184%if %{defined with_python_path}
185  %define with_python_option --with-python=%{with_python_path}
186%else
187  %if %{defined gdb-enable-python}
188    %define with_python_option --with-python=%{gdb-enable-python}
189  %else
190    %define with_python_option --with-python
191  %endif
192%endif
193
194#
195#
196# Prepare the source code.
197#
198%prep
199  build_top=$(pwd)
200
201  gdb_source=%{?gdb_external:%{gdb_expand_name}}%{!?gdb_external:"gdb-%{gdb_version}"}
202
203  source_dir_gdb=${gdb_source}
204  %source setup gdb -q -n ${gdb_source}
205  %patch setup gdb -p1
206
207  cd ${build_top}
208
209%build
210  build_top=$(pwd)
211
212  %{build_directory}
213
214  mkdir -p ${build_dir}
215  cd ${build_dir}
216
217  %{host_build_flags}
218
219  if test "%{_build}" != "%{_host}" ; then
220    GDB_LIBS_STATIC="-lexpat"
221  else
222    GDB_LIBS_STATIC="-lexpat"
223    GDB_LIBS="%{_forced_static}"
224  fi
225
226  LIBS_STATIC=${GDB_LIBS_STATIC} \
227  LIBS=${GDB_LIBS} \
228  ../${source_dir_gdb}/configure \
229    --build=%{_build} --host=%{_host} \
230    --target=%{_target} \
231    --verbose --disable-nls \
232    --disable-gas --disable-binutils --disable-ld --disable-gold --disable-gprof \
233    %{?with_system_readline:--with-system-readline} \
234    --without-included-gettext \
235    --disable-win32-registry \
236    --disable-werror \
237    %{!?gdb-disable-sim:--enable-sim}%{?gdb-disable-sim:--disable-sim} \
238    %{?gdb-sim-options:%{gdb-sim-options}} \
239    --without-zlib \
240    --with-expat \
241    --with-guile=no \
242    %{!?without_python:%{with_python_option}} \
243    --prefix=%{_prefix} --bindir=%{_bindir} \
244    --exec-prefix=%{_exec_prefix} \
245    --includedir=%{_includedir} --libdir=%{_libdir} \
246    --mandir=%{_mandir} --infodir=%{_infodir}
247
248  %{__make} %{?_smp_mflags} all
249
250  cd ${build_top}
251
252%install
253  build_top=$(pwd)
254
255  %{__rmdir} $SB_BUILD_ROOT
256
257  cd ${build_dir}
258  %{__make} DESTDIR=$SB_BUILD_ROOT install
259
260  # Dropped in FSF-binutils-2.9.5, but Cygwin still ships it.
261  %{__rmdir} $SB_BUILD_ROOT%{_infodir}/configure.info*
262
263  %{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir
264  touch $SB_BUILD_ROOT%{_infodir}/dir
265
266  cd ${build_top}
Note: See TracBrowser for help on using the repository browser.