source: rtems-source-builder/rtems/config/rtems-bsp.cfg

Last change on this file was e1f87e5, checked in by Chris Johns <chrisj@…>, on 09/07/22 at 08:21:50

rtems/rtems-bsp: Support a kernel configuration file

  • Support a single BSP defined in a kernel config file
  • Property mode set to 100644
File size: 8.3 KB
Line 
1#
2# RTEMS BSP Support
3#
4
5#
6# The RTEMS BSP support requires the host tuple, the RTEMS BSP and the path to
7# the tools. The prefix is set to an installed RTEMS. The built package is
8# installed into the prefix.
9#
10# Keeping the package's installed path in the RTEMS install path and separate
11# to the tools lets the tools version vary independently.
12#
13# Provide the path to the RTEMS tools if not in the prefix with the
14# --with-tools option. If --with-tools is not provided use the prefix.
15#
16# Provide the path to the installed RTEMS kernel if not in the prefix with the
17# --with-rtems option. If --with-rtems is not provided use the prefix.
18#
19# Note, only a single path (--with-rtems) for the RTEMS kernel and any other
20# add on or 3rd party libraries is supported.
21#
22
23#
24# If a dry-run and with download ignore errors and correct setting for tools
25# and BSPs. Only after the source to download.
26#
27%if %{_dry_run}
28 %log BSP configuration errors ignored
29 %define rtems_bsp_error 0
30%else
31 %define rtems_bsp_error 1
32%endif
33
34#
35# Set up how we manage pkgconfig. Enable support when crosscompiling,
36# and filter specific optimisation and warning from the flags that
37# RTEMS exports.
38#
39%{pkgconfig crosscompile yes}
40%{pkgconfig filter-flags yes}
41
42#
43# We need a BSP from the user.
44#
45%if %{defined with_rtems_bsp_config}
46 %define rtems_bsp %(%{_sbdir}/sb/rtems-kernel-config-check \
47                        -c %{with_rtems_bsp_config})
48%else
49 %ifn %{defined with_rtems_bsp}
50  %if %{rtems_bsp_error}
51   %error No RTEMS BSP specified: --with-rtems-bsp=bsp
52  %endif
53  %define with_rtems_bsp sparc/erc32
54 %endif
55 %define rtems_bsp %{with_rtems_bsp}
56%endif
57
58#
59# Count the BSPs. Currently only one is supported
60#
61%define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
62
63%if %{rtems_bsp_count} > 1
64 %error RTEMS packages do not support multiple BSP builds
65%endif
66
67#
68# Separate out the arch and bsp
69#
70%define rtems_arch %(echo %{rtems_bsp} | sed -e 's^\/.*^^g')
71%define rtems_bsp  %(echo %{rtems_bsp} | sed -e 's^.*\/^^g')
72
73#
74# We need a host from the user to specifiy the RTEMS architecture and major
75# version. It can be defined in rtems_host.
76#
77%if !%{defined rtems_host}
78 %define rtems_host %{rtems_arch}-rtems%{rtems_version}
79%endif
80%{triplet _host %{rtems_host}}
81
82#
83# If no tools or RTEMS provided use the prefix. If staging use the staging
84# root.
85#
86%ifn %{defined with_tools}
87 %if %{install_mode} == staging && \
88      %{path check isfile %{stagingroot}/bin/%{_host}-%{_host_cc}}
89  %define rtems_tools_staged 1
90  %define with_tools %{stagingroot}
91  %define rtems_waf_tools --rtems-tools=%{with_tools}
92 %else
93  %define rtems_tools_staged 1
94  %define with_tools %{_prefix}
95  %define rtems_waf_tools %{nil}
96 %endif
97%else
98 %define rtems_waf_tools --rtems-tools=%{with_tools}
99%endif
100
101%define rtems_host_cc_valid \
102         %{path check isfile %{with_tools}/bin/%{_host}-%{_host_cc}}
103%if !%{rtems_host_cc_valid} && %{rtems_bsp_error} && !%{_rsb_getting_source}
104 %error RTEMS tools not found (%{_host}-%{_host_cc}) found; Please check the --with-tools option or --prefix.
105%endif
106
107%ifn %{defined with_rtems}
108 %{pkgconfig prefix %{stagingroot}/lib/pkgconfig}
109 %if %{install_mode} == staging && %{pkgconfig check %{_host}-%{rtems_bsp}}
110  %define rtems_bsp_staged 1
111  %define with_rtems %{stagingroot}
112  %define rtems_waf_rtems --rtems=%{with_rtems}
113 %else
114  %define rtems_bsp_staged 0
115  %define with_rtems %{_prefix}
116  %define rtems_waf_rtems %{nil}
117 %endif
118%else
119 %define rtems_waf_rtems --rtems=%{with_rtems}
120%endif
121
122#
123# Set the pkgconfig prefix path to the RTEMS prefix.
124#
125%{pkgconfig prefix %{with_rtems}/lib/pkgconfig}
126
127#
128# Check we can find the BSP's pkgconfig file.
129#
130%if !%{pkgconfig check %{_host}-%{rtems_bsp}} && %{rtems_bsp_error} && !%{_rsb_getting_source}
131 %error RTEMS BSP not found (%{_host}-%{rtems_bsp}.pc); Please check the --with-rtems option or --prefix.
132%endif
133
134#
135# Set the path to the tools.
136#
137%{path prepend %{with_tools}/bin}
138
139#
140# Update the configure paths to be BSP specific.
141#
142%define rtems_bsp_prefix  %{_prefix}/%{_host}/%{rtems_bsp}
143%define _exec_prefix      %{rtems_bsp_prefix}
144%define _bindir           %{_exec_prefix}/bin
145%define _sbindir          %{_exec_prefix}/sbin
146%define _libexecdir       %{_exec_prefix}/libexec
147%define _datarootdir      %{_exec_prefix}/share
148%define _datadir          %{_datarootdir}
149%define _sysconfdir       %{_exec_prefix}/etc
150%define _sharedstatedir   %{_exec_prefix}/com
151%define _localstatedir    %{_exec_prefix}/var
152%define _includedir       %{_libdir}/include
153%define _lib              lib
154%define _libdir           %{_exec_prefix}/%{_lib}
155%define _libexecdir       %{_exec_prefix}/libexec
156%define _mandir           %{_datarootdir}/man
157%define _infodir          %{_datarootdir}/info
158%define _localedir        %{_datarootdir}/locale
159%define _localedir        %{_datadir}/locale
160%define _localstatedir    %{_exec_prefix}/var
161
162#
163# The RTEMS BSP Flags
164#
165%define rtems_bsp_includes -I%{_includedir}
166%define rtems_bsp_ccflags  %{pkgconfig ccflags %{_host}-%{rtems_bsp}}
167%define rtems_bsp_cflags   %{pkgconfig cflags  %{_host}-%{rtems_bsp}}
168%define rtems_bsp_ldflags  %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
169%define rtems_bsp_libs     %{pkgconfig libs    %{_host}-%{rtems_bsp}}
170
171%if %{rtems_bsp_cflags} == %{nil} && %{rtems_bsp_error} && !%{_rsb_getting_source}
172 %error No RTEMS BSP CFLAGS found; Please check the --with-rtems-bsp option.
173%endif
174
175#
176# C++ flags are the C flags.
177#
178%if %{rtems_bsp_ccflags} == %{nil}
179 %define rtems_bsp_ccflags %{rtems_bsp_cflags}
180%endif
181
182#
183# If there are no LDFLAGS create a path to RTEMS.
184#
185%if %{rtems_bsp_ldflags} == %{nil}
186 %define rtems_bsp_ldflags -L%{rtems_bsp_prefix}/lib
187%endif
188
189#
190# Support for RTEMS's Makefile.inc support.
191#
192%define rtems_bsp_makefile_inc %{rtems_bsp_prefix}
193%define rtems_bsp_rtems_root   %{_prefix}
194
195#
196# Filter the flags converting any prefix to the staging path if this is a
197# staging build of the BSP.
198#
199%if %{rtems_bsp_staged}
200 %define staging_filter sed -e 's|%{_prefix}|%{stagingroot}|g'
201 %define rtems_bsp_prefix     $(echo %{rtems_bsp_prefix}   | %{staging_filter})
202 %define rtems_bsp_includes   $(echo %{rtems_bsp_includes} | %{staging_filter})
203 %define rtems_bsp_ccflags    $(echo %{rtems_bsp_ccflags}  | %{staging_filter})
204 %define rtems_bsp_cflags     $(echo %{rtems_bsp_cflags}   | %{staging_filter})
205 %define rtems_bsp_ldflags    $(echo %{rtems_bsp_ldflags}  | %{staging_filter})
206 %define rtems_bsp_rtems_root %{stagingroot}
207%endif
208
209%if %{rtems_bsp_ccflags} == %{nil}
210 %define rtems_bsp_ccflags %{rtems_bsp_cflags}
211%endif
212
213#
214# The RTEMS BSP architecture/bsp.
215#
216%define rtems_bsp_arch_bsp %{_host_arch}/%{rtems_bsp}
217
218#
219# RTEMS BSP paths
220#
221%define rtems_bsp_cc      %{_host}-gcc
222%define rtems_bsp_cxx     %{_host}-g++
223%define rtems_bsp_incpath %{with_rtems}/%{_host}/%{rtems_bsp}/include
224%define rtems_bsp_libpath %{with_rtems}/%{_host}/%{rtems_bsp}/lib
225
226#
227# Check for installed libraries.
228#
229# - Check is LibBSD is install
230# - Add librtemsdefaultconfig so configure scripts work.
231#
232# Note: default BSP flags include the standard RTEMS libraries.
233#
234%define rtems-dep-check %(%{_sbdir}/sb/rtems-build-dep -c %{with_tools}/bin/%{rtems_bsp_cc}
235
236%define rtems-libbsd %{rtems-dep-check} -L %{rtems_bsp_libpath} -l libbsd.a)
237%if %{rtems-libbsd} == found
238 %define rtems_bsp_libs %{rtems_bsp_libs} -lbsd -lm -lz
239%endif
240
241%define rtems-defaultconfig %{rtems-dep-check} -L %{rtems_bsp_libpath} -l librtemsdefaultconfig.a)
242%if %{rtems-defaultconfig} == found
243 %define rtems_bsp_libs %{rtems_bsp_libs} -lrtemsdefaultconfig
244%endif
245
246#
247# Define any extra flags we may need.
248#
249%define rtems_bsp_ldflags_extra \
250          %{?rtems_bsp_ldflags_extra: %{rtems_bsp_ldflags_extra}} \
251          -Wl,--gc-sections
252
253#
254# The linker flags need to include the machine options for the BSP.
255#
256%define mflags_filter  awk '{for (i=1;i<NF;++i) if ($i ~ /\-m/) printf("%s ",$i);}'
257%define rtems_bsp_ldflags %{rtems_bsp_ldflags} \
258                          $(echo "%{rtems_bsp_cflags}" | %{mflags_filter}) \
259                          %{rtems_bsp_ldflags_extra}
260
261#
262# Map to names used for cross compiling.
263#
264%define host_cc       %{rtems_bsp_cc}
265%define host_cxx      %{rtems_bsp_cxx}
266%define host_includes %{rtems_bsp_includes}
267%define host_cflags   %{rtems_bsp_cflags}
268%define host_cxxflags %{rtems_bsp_ccflags}
269%define host_ldflags  %{rtems_bsp_ldflags}
270%define host_libs     %{rtems_bsp_libs}
271
272#
273# Handle the Waf install root.
274#
275%ifos win32 mingw ming32
276 %define rtems_waf_build_root_suffix %{waf_build_root_suffix}
277%else
278 %define rtems_waf_build_root_suffix %{nil}
279%endif
Note: See TracBrowser for help on using the repository browser.