summaryrefslogtreecommitdiffstats
path: root/rtems/config/tools/rtems-kernel-common.cfg
blob: aa424d2c4fb7323458faaccb3fc2e426bb0ca5a5 (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
#
# RTEMS Kernel.
#
# This configuration file configure's, make's and install's RTEMS.
#

#
# 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} && %{defined with_download}
 %log Kernel configuration errors ignored
 %define rtems_kernel_error 0
%else
 %define rtems_kernel_error 1
%endif

%if %{rsb_released}
 %define rtems_kernel_version %{rsb_version}
%endif

%if %{defined with_rtems_bsp_config}
 #
 # A config file can build any BSP from any architecture. No options are
 # accepted.
 #
 %if %{defined with_rtems_target} || %{defined with_rtems_bsp} || \
     %{defined with_rtems_bspopts} || %{defined enable_cxx} || \
     %{defined with_rtems_tests} || %{defined with_rtems_smp}
  %error Options --with-rtems-* are not valid with --with-rtems-bsp-config
 %endif
 %if %{defined rtems_posix} || %{defined rtems_tests} || %{defined rtems_bspopts}
  %error Options rtems_* macros are not valid with --with-rtems-bsp-config
 %endif
 %define config_file %(realpath %{with_rtems_bsp_config})
 %if %(test -f %{config_file}; echo $?) == 1
  %error Configuration INI file not found: %{config_file}
 %endif
 %define rtems_bsp %(%{_sbdir}/sb/rtems-kernel-config-check -c %{with_rtems_bsp_config})
 %define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
 %define rtems_tests %(%{_sbdir}/sb/rtems-kernel-config-check -t %{with_rtems_bsp_config})
 # If a list the path gets too long
 %define rtems_bsp_pkgname %(basename %{with_rtems_bsp_config} | sed -e 's/\..*//g')
%else
 #
 # Backwards compatible command line or deployed build set
 # options.
 #
 %define config_file config.ini
 %if !%{defined with_rtems_bsp} && %{rtems_kernel_error}
  %error No RTEMS BSP specified: --with-rtems-bsp=bsp
 %endif
 %if %{defined with_rtems_bspopts}
  %define bspopts %{with_rtems_bspopts}
 %endif
 %define rtems_bsp_pkgname bsps
 #
 # Check the various --with/--without options we support. These are
 # turned into the internal settings.
 #
 # --with-rtems-bsp               : The BSP or list of BSPs
 # --without-rtems-bsp            : Not supported
 # --with-rtems-tests             : Supported, samples/yes/no
 # --without-rtems-tests          : Supported, forced to no
 # --with-rtems-smp               : Supported
 # --without-rtems-smp            : Don't care
 # --with-rtems-legacy-network    : Unsupported
 # --without-rtems-legacy-network : Don't care
 %if !%{defined with_rtems_bsp}
  %error Option --without-rtems-bsp is not found.
 %endif
 %if %{defined without_rtems_bsp}
  %error Option --without-rtems-bsp is not supported.
 %endif
 %define rtems_bsp %{with_rtems_bsp}
 %define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
 %if %{defined with_rtems_legacy_network}
  echo "RTEMS legacy network has been removed."
  echo "Please review and update your configuration."
  exit 1
 %endif
 %if %{defined enable_cxx}
  echo "CXX has been removed."
  echo "Please review and update your configuration."
  exit 1
 %endif
 %if %{defined without_rtems_tests}
  %define rtems_tests False
  %define rtems_sample_tests False
 %endif
 %if %{defined with_rtems_tests}
  %if %{with_rtems_tests} == 1
    %define rtems_tests True
    %define rtems_sample_tests True
  %endif
   %if %{with_rtems_tests} == samples
       %define rtems_tests False
       %define rtems_sample_tests True
  %endif
 %endif
 %if %{defined with_rtems_smp}
  %define rtems_smp 1
 %endif
 %if %{defined with_rtems_bspopts}
  %if %{rtems_bsp_count} > 1
   %error BSP options not supported with more than one BSP builds
  %endif
  %define rtems_bspopts %{with_rtems_bspopts}
 %endif
 #
 # Default set up. Override these in a BSP if you want a
 # specific setup.
 #
 %ifn %{defined rtems_posix}
  %define rtems_posix 1
 %endif
 %ifn %{defined rtems_tests}
  %define rtems_tests False
  %define rtems_sample_tests True
 %endif
 %ifn %{defined rtems_bspopts}
  %define rtems_bspopts %{nil}
 %endif
%endif

%define _target not-used

#
# If no tools are provided use the prefix.
#
%ifn %{defined with_tools}
 %define with_tools %{_prefix}
%endif

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

#
# Define the package.
#
package: rtems-%{rtems_version}-%{rtems_bsp_pkgname}-%{_host}-%{release}

#
# Package details.
#
Name:    rtems-kernel-%{rtems_bsp_pkgname}-%{release}
Summary: RTEMS v%{rtems_kernel_version} for BSP(s) %{rtems_bsp}
Version: %{rtems_kernel_version}
Release: %{release}
URL: 	 https://www.rtems.org/

%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%include %{_configdir}/versions.cfg

#
# If no tools provided use the prefix.
#
%ifn %{defined with_tools}
 %define with_tools %{_prefix}
%endif

#
# Check options.
#
%if %{defined without_rtems_posix}
 %define rtems_posix 0
%endif

#
# Source
#
%if %{rsb_released}
 %define rtems_kernel_file rtems-%{rtems_kernel_version}.tar.xz
%else
 %define rtems_kernel_file rtems-kernel-%{rtems_kernel_version}.tar.bz2
%endif

%if ! %{defined rtems_kernel_version}
 %error No RTEMS kernel version defined
%endif

%source set rtems_kernel --rsb-file=%{rtems_kernel_file} \
              https://git.rtems.org/rtems/snapshot/rtems-%{rtems_kernel_version}.tar.bz2

#
# Prepare the source code.
#
%prep
  source_dir_rtems="rtems-%{rtems_kernel_version}"
  %source setup rtems_kernel -q -c -n %{name}-%{version}
  cd ${source_dir_rtems}
  %patch setup rtems_kernel -p1
  cd ..

%build
  # Build directory support.
  if test "%{_build}" != "%{_host}" ; then
    build_dir="build-cxc"
  else
    build_dir="build"
  fi

  cd ${source_dir_rtems}

  #
  # If no user supplied configuration file create one
  #
  %if !%{defined with_rtems_bsp_config}
    echo "[DEFAULT]" > %{config_file}
    echo "RTEMS_POSIX_API = %{?rtems_posix:True}%{!?rtems_posix:False}" >> %{config_file}
    echo "RTEMS_SMP = %{?rtems_smp:True}%{!?rtems_smp:False}" >> %{config_file}
    echo "BUILD_TESTS = %{rtems_tests}" >> %{config_file}
    echo "BUILD_SAMPLES = %{rtems_sample_tests}" >> %{config_file}
    echo "" >> %{config_file}
    for bsp in %{rtems_bsp}
    do
     echo "[$bsp]" >> %{config_file}
     %if %{rtems_bsp_count} == 1 && %{defined rtems_bspopts}
       for opt in $(echo %{rtems_bspopts} | tr ' ' '\n')
       do
        echo "$opt" >> %{config_file}
       done
     %endif
     echo "" >> %{config_file}
    done
  %endif

  mkdir -p ${build_dir}

  ./waf configure \
    --prefix=%{_prefix} \
    --rtems-config=%{config_file}

  ./waf %{?_smp_mflags}

  cd ..

%install
  %{__rmdir} $SB_BUILD_ROOT

  cd ${source_dir_rtems}
  ./waf --destdir=$SB_BUILD_ROOT install

  echo "rtems_tests: %{rtems_tests}"

  %if %{rtems_tests} != False
   for bsp in %{rtems_bsp}
   do
    export bsp
    mkdir -p $SB_BUILD_ROOT/%{_prefix}/${bsp}-rtems%{rtems_kernel_version}/tests
    find build/$bsp -name \*.exe -and -not -name \*.norun.exe \
      -exec sh -c 'cp -v {} $SB_BUILD_ROOT/%{_prefix}/${bsp}-rtems%{rtems_kernel_version}/tests/$(basename {})' \;
   done
  %endif

  cd -