summaryrefslogtreecommitdiffstats
path: root/rtems/config/rtems-bsp.cfg
blob: bf1f42b6fb57470178c316c2c618b3209cca6c97 (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
#
# 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 is 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 is 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

#
# 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

#
# If no tools or RTEMS provided use the prefix. If staging use the staging
# root.
#
%ifn %{defined with_tools}
 %if %{install_mode} == staging
  %define with_tools %{stagingroot}
  %define rtems_waf_tools --rtems-tools=%{with_tools}
 %else
  %define with_tools %{_prefix}
  %define rtems_waf_tools %{nil}
 %endif
%else
 %define rtems_waf_tools --rtems-tools=%{with_tools}
%endif

%ifn %{defined with_rtems}
 %if %{install_mode} == staging
  %define with_rtems %{stagingroot}
  %define rtems_waf_rtems --rtems=%{with_rtems}
 %else
  %define with_rtems %{_prefix}
  %define rtems_waf_rtems %{nil}
 %endif
%else
 %define rtems_waf_rtems --rtems=%{with_rtems}
%endif

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

#
# Set up how we manage pkgconfig. Set the prefix path to the RTEMS prefix,
# enable support when crosscompiling, and filter specific optimisation and
# warning from the flags that RTEMS exports.
#
%{pkgconfig prefix %{with_rtems}/lib/pkgconfig}
%{pkgconfig crosscompile yes}
%{pkgconfig filter-flags yes}

#
# The RTEMS BSP Flags
#
%define rtems_bsp         %{with_rtems_bsp}
%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}
 %error No RTEMS BSP CFLAGS found; Please check the --with-rtems-bsp option.
%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

#
# 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

#
# Map to names used for cross compiling.
#
%define host_cc       %{rtems_bsp_cc}
%define host_cxx      %{rtems_bsp_cxx}
%define host_includes -I%{_includedir}
%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