summaryrefslogtreecommitdiffstats
path: root/rtems/config/rtems-bsp.cfg
blob: 801cd5cc21fbbf3816289590401651247354c6fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#
# RTEMS BSP Support
#

#
# The RTEMS BSP support requires the host tuple, the RTEMS BSP and the path to
# the tools. The prefix is set to an installed RTEMS. The built package is
# installed into the prefix.
#
# Keeping the package's installed path in the RTEMS install path and separate
# to the tools lets the tools version vary independently.
#
# Provide the path to the RTEMS tools if not in the prefix with the
# --with-tools option. If --with-tools is not provided use the prefix.
#
# Provide the path to the installed RTEMS kernel if not in the prefix with the
# --with-rtems option. If --with-rtems is not provided use the prefix.
#
# Note, only a single path (--with-rtems) for the RTEMS kernel and any other
# add on or 3rd party libraries is supported.
#

#
# If a dry-run and with download ignore errors and correct setting for tools
# and BSPs. Only after the source to download.
#
%if %{_dry_run}
 %log BSP configuration errors ignored
 %define rtems_bsp_error 0
%else
 %define rtems_bsp_error 1
%endif

#
# Set up how we manage pkgconfig. Enable support when crosscompiling,
# and filter specific optimisation and warning from the flags that
# RTEMS exports.
#
%{pkgconfig crosscompile yes}
%{pkgconfig filter-flags yes}

#
# We need a host from the user to specifiy the RTEMS architecture and major
# version. It can be defined in rtems_host.
#
%if %{defined rtems_host}
 %{triplet _host %{rtems_host}}
%endif
%if %{rtems_bsp_error}
 %if %{_host} == %{nil} || %{_host} == %{_build}
  %error No RTEMS host or BSP specified: --host=<arch>-rtems<ver>
 %endif
%endif

#
# We need a BSP from the user.
#
%ifn %{defined with_rtems_bsp}
 %if %{rtems_bsp_error}
  %error No RTEMS BSP specified: --with-rtems-bsp=bsp
 %endif
 %define with_rtems_bsp sparc/erc32
%endif
%define rtems_bsp %{with_rtems_bsp}

#
# If no tools or RTEMS provided use the prefix. If staging use the staging
# root.
#
%ifn %{defined with_tools}
 %if %{install_mode} == staging && \
      %{path check isfile %{stagingroot}/bin/%{_host}-%{_host_cc}}
  %define rtems_tools_staged 1
  %define with_tools %{stagingroot}
  %define rtems_waf_tools --rtems-tools=%{with_tools}
 %else
  %define rtems_tools_staged 1
  %define with_tools %{_prefix}
  %define rtems_waf_tools %{nil}
 %endif
%else
 %define rtems_waf_tools --rtems-tools=%{with_tools}
%endif

%define rtems_host_cc_valid \
         %{path check isfile %{with_tools}/bin/%{_host}-%{_host_cc}}
%if !%{rtems_host_cc_valid} && %{rtems_bsp_error} && !%{_rsb_getting_source}
 %error RTEMS tools not found (%{_host}-%{_host_cc}) found; Please check the --with-tools option or --prefix.
%endif

%ifn %{defined with_rtems}
 %{pkgconfig prefix %{stagingroot}/lib/pkgconfig}
 %if %{install_mode} == staging && %{pkgconfig check %{_host}-%{rtems_bsp}}
  %define rtems_bsp_staged 1
  %define with_rtems %{stagingroot}
  %define rtems_waf_rtems --rtems=%{with_rtems}
 %else
  %define rtems_bsp_staged 0
  %define with_rtems %{_prefix}
  %define rtems_waf_rtems %{nil}
 %endif
%else
 %define rtems_waf_rtems --rtems=%{with_rtems}
%endif

#
# Set the pkgconfig prefix path to the RTEMS prefix.
#
%{pkgconfig prefix %{with_rtems}/lib/pkgconfig}

#
# Check we can find the BSP's pkgconfig file.
#
%if !%{pkgconfig check %{_host}-%{rtems_bsp}} && %{rtems_bsp_error} && !%{_rsb_getting_source}
 %error RTEMS BSP not found (%{_host}-%{rtems_bsp}.pc); Please check the --with-rtems option or --prefix.
%endif

#
# Set the path to the tools.
#
%{path prepend %{with_tools}/bin}

#
# Update the configure paths to be BSP specific.
#
%define rtems_bsp_prefix  %{_prefix}/%{_host}/%{rtems_bsp}
%define _exec_prefix      %{rtems_bsp_prefix}
%define _bindir           %{_exec_prefix}/bin
%define _sbindir          %{_exec_prefix}/sbin
%define _libexecdir       %{_exec_prefix}/libexec
%define _datarootdir      %{_exec_prefix}/share
%define _datadir          %{_datarootdir}
%define _sysconfdir       %{_exec_prefix}/etc
%define _sharedstatedir   %{_exec_prefix}/com
%define _localstatedir    %{_exec_prefix}/var
%define _includedir       %{_libdir}/include
%define _lib              lib
%define _libdir           %{_exec_prefix}/%{_lib}
%define _libexecdir       %{_exec_prefix}/libexec
%define _mandir           %{_datarootdir}/man
%define _infodir          %{_datarootdir}/info
%define _localedir        %{_datarootdir}/locale
%define _localedir        %{_datadir}/locale
%define _localstatedir    %{_exec_prefix}/var

#
# The RTEMS BSP Flags
#
%define rtems_bsp_includes -I%{_includedir}
%define rtems_bsp_ccflags  %{pkgconfig ccflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_cflags   %{pkgconfig cflags  %{_host}-%{rtems_bsp}}
%define rtems_bsp_ldflags  %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_libs     %{pkgconfig libs    %{_host}-%{rtems_bsp}}

%if %{rtems_bsp_cflags} == %{nil} && %{rtems_bsp_error} && !%{_rsb_getting_source}
 %error No RTEMS BSP CFLAGS found; Please check the --with-rtems-bsp option.
%endif

#
# C++ flags are the C flags.
#
%if %{rtems_bsp_ccflags} == %{nil}
 %define rtems_bsp_ccflags %{rtems_bsp_cflags}
%endif

#
# If there are no LDFLAGS create a path to RTEMS.
#
%if %{rtems_bsp_ldflags} == %{nil}
 %define rtems_bsp_ldflags -L%{rtems_bsp_prefix}/lib
%endif

#
# Support for RTEMS's Makefile.inc support.
#
%define rtems_bsp_makefile_inc %{rtems_bsp_prefix}
%define rtems_bsp_rtems_root   %{_prefix}

#
# Filter the flags converting any prefix to the staging path if this is a
# staging build of the BSP.
#
%if %{rtems_bsp_staged}
 %define staging_filter sed -e 's|%{_prefix}|%{stagingroot}|g'
 %define rtems_bsp_prefix     $(echo %{rtems_bsp_prefix}   | %{staging_filter})
 %define rtems_bsp_includes   $(echo %{rtems_bsp_includes} | %{staging_filter})
 %define rtems_bsp_ccflags    $(echo %{rtems_bsp_ccflags}  | %{staging_filter})
 %define rtems_bsp_cflags     $(echo %{rtems_bsp_cflags}   | %{staging_filter})
 %define rtems_bsp_ldflags    $(echo %{rtems_bsp_ldflags}  | %{staging_filter})
 %define rtems_bsp_rtems_root %{stagingroot}
%endif

%if %{rtems_bsp_ccflags} == %{nil}
 %define rtems_bsp_ccflags %{rtems_bsp_cflags}
%endif

#
# The RTEMS BSP architecture/bsp.
#
%define rtems_bsp_arch_bsp %{_host_arch}/%{rtems_bsp}

#
# RTEMS BSP paths
#
%define rtems_bsp_cc      %{_host}-gcc
%define rtems_bsp_cxx     %{_host}-g++
%define rtems_bsp_incpath %{with_rtems}/%{_host}/%{rtems_bsp}/include
%define rtems_bsp_libpath %{with_rtems}/%{_host}/%{rtems_bsp}/lib

#
# Check for installed libraries.
#
# - Check is LibBSD is install
# - Add librtemsdefaultconfig so configure scripts work.
#
# Note: default BSP flags include the standard RTEMS libraries.
#
%define rtems-dep-check %(%{_sbdir}/sb/rtems-build-dep -c %{with_tools}/bin/%{rtems_bsp_cc}

%define rtems-libbsd %{rtems-dep-check} -L %{rtems_bsp_libpath} -l libbsd.a)
%if %{rtems-libbsd} == found
 %define rtems_bsp_libs %{rtems_bsp_libs} -lbsd -lm -lz
%endif

%define rtems-defaultconfig %{rtems-dep-check} -L %{rtems_bsp_libpath} -l librtemsdefaultconfig.a)
%if %{rtems-defaultconfig} == found
 %define rtems_bsp_libs %{rtems_bsp_libs} -lrtemsdefaultconfig
%endif

#
# Define any extra flags we may need.
#
%define rtems_bsp_ldflags_extra \
          %{?rtems_bsp_ldflags_extra: %{rtems_bsp_ldflags_extra}} \
          -Wl,--gc-sections

#
# The linker flags need to include the machine options for the BSP.
#
%define mflags_filter  awk '{for (i=1;i<NF;++i) if ($i ~ /\-m/) printf("%s ",$i);}'
%define rtems_bsp_ldflags %{rtems_bsp_ldflags} \
                          $(echo "%{rtems_bsp_cflags}" | %{mflags_filter}) \
			  %{rtems_bsp_ldflags_extra}

#
# Map to names used for cross compiling.
#
%define host_cc       %{rtems_bsp_cc}
%define host_cxx      %{rtems_bsp_cxx}
%define host_includes %{rtems_bsp_includes}
%define host_cflags   %{rtems_bsp_cflags}
%define host_cxxflags %{rtems_bsp_ccflags}
%define host_ldflags  %{rtems_bsp_ldflags}
%define host_libs     %{rtems_bsp_libs}

#
# Handle the Waf install root.
#
%ifos win32 mingw ming32
 %define rtems_waf_build_root_suffix %{waf_build_root_suffix}
%else
 %define rtems_waf_build_root_suffix %{nil}
%endif