source: rtems-source-builder/source-builder/config/gdb-common-1.cfg @ 599c4d7

5
Last change on this file since 599c4d7 was 599c4d7, checked in by Chris Johns <chrisj@…>, on 01/21/20 at 03:46:16

freebsd: Fix GDB building on some 12 and higher versions

  • Property mode set to 100644
File size: 7.7 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# Fix the mess iconv is on FreeBSD 10.0 and higher.
196#
197%if %{defined iconv_prefix}
198 %define iconv_opts --with-libiconv-prefix=%{iconv_prefix}
199%else
200 %define iconv_opts %{nil}
201%endif
202
203#
204#
205# Prepare the source code.
206#
207%prep
208  build_top=$(pwd)
209
210  gdb_source=%{?gdb_external:%{gdb_expand_name}}%{!?gdb_external:"gdb-%{gdb_version}"}
211
212  source_dir_gdb=${gdb_source}
213  %source setup gdb -q -n ${gdb_source}
214  %patch setup gdb -p1
215
216  cd ${build_top}
217
218%build
219  build_top=$(pwd)
220
221  %{build_directory}
222
223  mkdir -p ${build_dir}
224  cd ${build_dir}
225
226  %{host_build_flags}
227
228  if test "%{_build}" != "%{_host}" ; then
229    GDB_LIBS_STATIC="-lexpat"
230  else
231    GDB_LIBS_STATIC="-lexpat"
232    GDB_LIBS="%{_forced_static}"
233  fi
234
235  LIBS_STATIC=${GDB_LIBS_STATIC} \
236  LIBS=${GDB_LIBS} \
237  ../${source_dir_gdb}/configure \
238    --build=%{_build} --host=%{_host} \
239    --target=%{_target} \
240    --verbose --disable-nls \
241    --disable-gas --disable-binutils --disable-ld --disable-gold --disable-gprof \
242    %{?with_system_readline:--with-system-readline} \
243    --without-included-gettext \
244    --disable-win32-registry \
245    --disable-werror \
246    %{!?gdb-disable-sim:--enable-sim}%{?gdb-disable-sim:--disable-sim} \
247    %{?gdb-sim-options:%{gdb-sim-options}} \
248    --without-zlib \
249    --with-expat \
250    --with-guile=no \
251    %{iconv_opts} \
252    %{!?without_python:%{with_python_option}} \
253    --prefix=%{_prefix} --bindir=%{_bindir} \
254    --exec-prefix=%{_exec_prefix} \
255    --includedir=%{_includedir} --libdir=%{_libdir} \
256    --mandir=%{_mandir} --infodir=%{_infodir}
257
258  %{__make} %{?_smp_mflags} all
259
260  cd ${build_top}
261
262%install
263  build_top=$(pwd)
264
265  %{__rmdir} $SB_BUILD_ROOT
266
267  cd ${build_dir}
268  %{__make} DESTDIR=$SB_BUILD_ROOT install
269
270  # Dropped in FSF-binutils-2.9.5, but Cygwin still ships it.
271  %{__rmdir} $SB_BUILD_ROOT%{_infodir}/configure.info*
272
273  %{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir
274  touch $SB_BUILD_ROOT%{_infodir}/dir
275
276  cd ${build_top}
Note: See TracBrowser for help on using the repository browser.