source: rtems-source-builder/doc/source-builder.txt @ 851c734

5
Last change on this file since 851c734 was 851c734, checked in by Gedare Bloom <gedare@…>, on 08/26/16 at 15:20:48

doc: update with version information

  • Property mode set to 100644
File size: 145.0 KB
Line 
1RTEMS Source Builder
2====================
3:doctype: book
4:toc2:
5:toclevels: 5
6:icons:
7:numbered:
8
9image:images/rtemswhitebg.jpg["RTEMS",width="30%"]
10
11Chris Johns <chrisj@rtems.org>
121.9, July 2014
13
14RTEMS Tools From Source
15-----------------------
16
17The RTEMS Source Builder is a tool to aid building packages from source used by
18the RTEMS project. It helps consolidate the details you need to build a package
19from source in a controlled and verifiable way. The tool is aimed at developers
20of software who use tool sets for embedded type development and is not limited
21to building just for RTEMS. Embedded development typically uses cross-compiling
22tool chains, debuggers, and debugging aids. Together we call these a 'tool
23set'. The RTEMS Source Builder is not limited to this role but designed to fit
24with-in this specific niche. It can be used outside of the RTEMS project and we
25welcome this happening in other open source or commercial projects.
26
27The RTEMS Source Builder is typically used to build a set of tools or a 'build
28set'. A 'build set' is a collection of packages and a package is a specific
29tool, for example gcc or gdb. The RTEMS Source Builder attempts to support any
30host environment that runs Python and you can build the package on. It is not
31some sort of magic that can take any piece of source code and make it
32build. Someone at some point in time has figured out how to build that package
33from source and taught this tool. The RTEMS Source Builder has been tested on:
34
35[[platform_links]]
36* <<_archlinux,Archlinux>>
37* <<_centos,Centos>>
38* <<_fedora,Fedora>>
39* <<_freebsd,FreeBSD>>
40* <<_netbsd,NetBSD>>
41* <<_macos,MacOS>>
42* <<_mint,Linux Mint>>
43* <<_opensuse,openSUSE>>
44* <<_raspbian,Raspbian>>
45* <<_ubuntu,Ubuntu>>
46* <<_windows,Windows>>
47* <<_ubuntu,Xubuntu>>
48
49The RTEMS Source Builder has two types of configuration data. The first is the
50'build set'. A _build set_ describes a collection of packages that define a set
51of tools you would use when developing software for RTEMS. For example the
52basic GNU tool set is binutils, gcc, and gdb and is the typical base suite of
53tools you need for an embedded cross-development type project. The second type
54of configuration data is the configuration files and they define how a package
55is built. Configuration files are scripts loosely based on the RPM spec file
56format and they detail the steps needed to build a package. The steps are
57'preparation', 'building', and 'installing'. Scripts support macros, shell
58expansion, logic, includes plus many more features useful when build packages.
59
60The RTEMS Source Builder does not interact with any host package management
61systems. There is no automatic dependence checking between various packages you
62build or packages and software your host system you may have installed. We
63assume the build sets and configuration files you are using have been created
64by developers who do. Support is provided for package config or pkgconfg type
65files so you can check and use standard libraries if present. If you have a
66problem please ask on the RTEMS Users mailing list.
67
68This documentation caters for a range of users from new to experienced RTEMS
69developers. New users can follow the Quick Start section up to the "Installing
70and Tar Files" to get a working tools and RTEMS. Users building a binary tool
71set for release can read the "Installing and Tar Files". Users wanting to run
72and test bleeding edge tools or packages, or wanting update or extend the RSB's
73configuration can read the remaining sections.
74
75*************************************************************
76IMPORTANT: If you have a problem please see <<_bugs,the reporting bugs>>
77           section.
78*************************************************************
79
80Quick Start
81-----------
82
83The quick start will show you how to build a set of RTEMS tools for a supported
84architecture. The tools are installed into a build _prefix_. The _prefix_ is the
85top of a group of directories containing all the files needed to develop RTEMS
86applications. Building an RTEMS build set will build all that you need. This
87includes autoconf, automake, assemblers, linkers, compilers, debuggers,
88standard libraries and RTEMS itself.
89
90There is no need to become root or the administrator and we recommend you avoid
91doing this. You can build and install the tools anywhere on the host's file
92system you, as a standard user, have read and write access too. I recommend you
93use your home directory and work under the directory `~/development/rtems`. The
94examples shown here will do this.
95
96You can use the build _prefix_ to install and maintain different versions of
97the tools. Doing this lets you try a new set of tools while not touching your
98proven working production set of tools. Once you have proven the new tools are
99working rebuild with the 'production' prefix switching your development to them.
100
101I also suggest you keep your environment to the bare minimum, particularly the
102path variable. Using environment variables has been proven over the years to be
103difficult to manage in production systems.
104
105.Host Setup
106*************************************************************
107IMPORTANT: Before proceeding to the next section please refer to the
108<<_host_setups,host specific setup>> for your host and install any extra
109packages. The RSB assumes the needed packages are installed and work.
110*************************************************************
111
112.Path to use when building applications
113*************************************************************
114TIP: Do not forget to do this before you use the tools such as build RTEMS.
115
116The RSB by default will install (copy) the executables under the prefix you
117supply. To use the tools once finished just set your path to the 'bin'
118directory under the _prefix_ you use. In the examples that follow the _prefix_
119is `$HOME/development/rtems/4.11` and is set using the `--prefix` option so the
120path you need to configure to build applications can be set with the following
121in a BASH shell:
122
123-------------------------------------------------------------
124$ export PATH=$HOME/development/rtems/4.11/bin:$PATH
125-------------------------------------------------------------
126Make sure you place the RTEMS tool path at the front of your path so they are
127searched first. RTEMS can provide newer versions of some tools your operating
128system provides and placing the RTEMS tools path at the front means it is
129searched first and the RTEMS needed versions of the tools are used.
130*************************************************************
131
132.RTEMS Version
133*************************************************************
134RSB and RTEMS have matching `git branch` for each version of RTEMS.
135For example, if you want to build a toolchain for 4.11, then you
136should checkout the 4.11 branch of the RSB:
137-------------------------------------------------------------
138$ git checkout -t origin/4.11
139-------------------------------------------------------------
140Branches are available for the 4.9, 4.10, and 4.11 versions of RTEMS.
141*************************************************************
142
143Setup
144~~~~~
145
146Setup a development work space:
147
148-------------------------------------------------------------
149$ cd
150$ mkdir -p development/rtems/src
151$ cd development/rtems/src
152-------------------------------------------------------------
153
154The RTEMS Source Builder is distributed as source. It is Python code so all you
155need to do is head over to the RTEMS GIT repository and clone the code directly
156from git:
157
158-------------------------------------------------------------
159$ git clone git://git.rtems.org/rtems-source-builder.git
160$ cd rtems-source-builder
161-------------------------------------------------------------
162
163Checking
164~~~~~~~~
165
166The next step is to check if your host is set up correctly. The RTEMS Source
167Builder provides a tool to help:
168
169-------------------------------------------------------------
170$ source-builder/sb-check
171warning: exe: absolute exe found in path: (__objcopy) /usr/local/bin/objcopy <1>
172warning: exe: absolute exe found in path: (__objdump) /usr/local/bin/objdump
173error: exe: not found: (_xz) /usr/local/bin/xz <2>
174RTEMS Source Builder environment is not correctly set up
175$ source-builder/sb-check
176RTEMS Source Builder environment is ok <3>
177-------------------------------------------------------------
178
179<1> A tool is in the environment path but does not match the expected path.
180<2> The executable 'xz' is not found.
181<3> The host's environment is set up correct.
182
183The checking tool will output a list of executable files not found if problems
184are detected. Locate those executable files and install them. You may also be
185given a list of warnings about executable files not in the expected location
186however the executable was located somewhere in your environment's path. You
187will need to check each tool to determine if this is an issue. An executable
188not in the standard location may indicate it is not the host operating system's
189standard tool. It maybe ok or it could be buggy, only you can determine this.
190
191The <<_host_setups,Host Setups>> section lists packages you should install for
192common host operating systems. It maybe worth checking if you have those
193installed.
194
195Build Sets
196~~~~~~~~~~
197
198The RTEMS tools can be built within the RTEMS Source Builder's source tree. We
199recommend you do this so lets change into the RTEMS directory in the RTEMS
200Source Builder package:
201
202-------------------------------------------------------------
203$ cd rtems
204-------------------------------------------------------------
205
206If you are unsure how to specify the build set for the architecture you wish to
207build ask the tool:
208
209-------------------------------------------------------------
210$ ../source-builder/sb-set-builder --list-bsets <1>
211RTEMS Source Builder - Set Builder, v0.2.0
212Examining: config <2>
213Examining: ../source-builder/config <2>
214    4.10/rtems-all.bset <3>
215    4.10/rtems-arm.bset <4>
216    4.10/rtems-autotools.bset
217    4.10/rtems-avr.bset
218    4.10/rtems-bfin.bset
219    4.10/rtems-h8300.bset
220    4.10/rtems-i386.bset
221    4.10/rtems-lm32.bset
222    4.10/rtems-m32c.bset
223    4.10/rtems-m32r.bset
224    4.10/rtems-m68k.bset
225    4.10/rtems-mips.bset
226    4.10/rtems-nios2.bset
227    4.10/rtems-powerpc.bset
228    4.10/rtems-sh.bset
229    4.10/rtems-sparc.bset
230    4.11/rtems-all.bset
231    4.11/rtems-arm.bset
232    4.11/rtems-autotools.bset
233    4.11/rtems-avr.bset
234    4.11/rtems-bfin.bset
235    4.11/rtems-h8300.bset
236    4.11/rtems-i386.bset
237    4.11/rtems-lm32.bset
238    4.11/rtems-m32c.bset
239    4.11/rtems-m32r.bset
240    4.11/rtems-m68k.bset
241    4.11/rtems-microblaze.bset
242    4.11/rtems-mips.bset
243    4.11/rtems-moxie.bset
244    4.11/rtems-nios2.bset
245    4.11/rtems-powerpc.bset
246    4.11/rtems-sh.bset
247    4.11/rtems-sparc.bset
248    4.11/rtems-sparc64.bset
249    4.11/rtems-v850.bset
250    4.9/rtems-all.bset
251    4.9/rtems-arm.bset
252    4.9/rtems-autotools.bset
253    4.9/rtems-i386.bset
254    4.9/rtems-m68k.bset
255    4.9/rtems-mips.bset
256    4.9/rtems-powerpc.bset
257    4.9/rtems-sparc.bset
258    gnu-tools-4.6.bset
259    rtems-4.10-base.bset <5>
260    rtems-4.11-base.bset
261    rtems-4.9-base.bset
262    rtems-base.bset <5>
263    unstable/4.11/rtems-all.bset <6>
264    unstable/4.11/rtems-arm.bset
265    unstable/4.11/rtems-avr.bset
266    unstable/4.11/rtems-bfin.bset
267    unstable/4.11/rtems-h8300.bset
268    unstable/4.11/rtems-i386.bset
269    unstable/4.11/rtems-lm32.bset
270    unstable/4.11/rtems-m32c.bset
271    unstable/4.11/rtems-m32r.bset
272    unstable/4.11/rtems-m68k.bset
273    unstable/4.11/rtems-microblaze.bset
274    unstable/4.11/rtems-mips.bset
275    unstable/4.11/rtems-moxie.bset
276    unstable/4.11/rtems-powerpc.bset
277    unstable/4.11/rtems-sh.bset
278    unstable/4.11/rtems-sparc.bset
279    unstable/4.11/rtems-sparc64.bset
280    unstable/4.11/rtems-v850.bset
281-------------------------------------------------------------
282<1> Only option needed is +--list-bsets+
283<2> The paths inspected. See <<X1,+_configdir+>> variable.
284<3> Build all RTEMS 4.10 supported architectures.
285<4> The build set for the ARM architecture on RTEMS 4.10.
286<5> Support build set file with common functionality included by other build
287    set files.
288<6> Unstable tool sets are used by RTEMS developers to test new tool sets. You
289    are welcome to try them but you must remember they are unstable, can change
290    at any point in time and your application may not work. If you have an
291    issue with a production tool it may pay to try the unstable tool to see if
292    it has been resolved.
293
294Building
295~~~~~~~~
296
297In this quick start I will build a SPARC tool set.
298
299-------------------------------------------------------------
300$ ../source-builder/sb-set-builder --log=l-sparc.txt <1> \
301                --prefix=$HOME/development/rtems/4.11 <2> 4.11/rtems-sparc <3>
302Source Builder - Set Builder, v0.2.0
303Build Set: 4.11/rtems-sparc
304config: expat-2.1.0-1.cfg <4>
305package: expat-2.1.0-x86_64-freebsd9.1-1
306building: expat-2.1.0-x86_64-freebsd9.1-1
307config: tools/rtems-binutils-2.22-1.cfg <5>
308package: sparc-rtems4.11-binutils-2.22-1
309building: sparc-rtems4.11-binutils-2.22-1
310config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg <6>
311package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
312building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
313config: tools/rtems-gdb-7.5.1-1.cfg <7>
314package: sparc-rtems4.11-gdb-7.5.1-1
315building: sparc-rtems4.11-gdb-7.5.1-1
316installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <8>
317installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
318installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
319installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
320cleaning: expat-2.1.0-x86_64-freebsd9.1-1 <9>
321cleaning: sparc-rtems4.11-binutils-2.22-1
322cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
323cleaning: sparc-rtems4.11-gdb-7.5.1-1
324Build Set: Time 0:13:43.616383 <10>
325-------------------------------------------------------------
326
327<1> Providing a log file redirects the build output into a file. Logging the
328    build output provides a simple way to report problems.
329<2> The prefix is the location on your file system the tools are installed
330    into. Provide a prefix to a location you have read and write access. You
331    can use the prefix to install different versions or builds of tools. Just
332    use the path to the tools you want to use when building RTEMS.
333<3> The build set. This is the SPARC build set. First a specifically referenced
334    file is checked for and if not found the '%{_configdir} path is
335    searched. The set builder will first look for files with a +.bset+
336    extension and then for a configuration file with a +.cfg+ extension.
337<4> The SPARC build set first builds the expat library as it is used in GDB.
338    This is the expat configuration used.
339<5> The binutils build configuration.
340<6> The GCC and Newlib build configuration.
341<7> The GDB build configuration.
342<8> Installing the built packages to the install prefix.
343<9> All the packages built are cleaned at the end. If the build fails all the
344    needed files are present. You may have to clean up by deleting the build
345    directory if the build fails.
346<10> The time to build the package. This lets you see how different host
347     hardware or configurations perform.
348
349Your SPARC RTEMS 4.11 tool set will be installed and ready to build RTEMS and
350RTEMS applications. When the build runs you will notice the tool fetch the
351source code from the internet. These files are cached in a directory called
352+source+. If you run the build again the cached files are used. This is what
353happened in the shown example before.
354
355TIP: The RSB for releases will automatically build and install RTEMS. The
356development version require adding +--with-rtems+. Use this for a single
357command to get the tools and RTEMS with one command.
358
359The installed tools:
360
361-------------------------------------------------------------
362$ ls $HOME/development/rtems/4.11
363bin         include     lib         libexec     share       sparc-rtems4.11
364$ ls $HOME/development/rtems/4.11/bin
365sparc-rtems4.11-addr2line       sparc-rtems4.11-cpp
366sparc-rtems4.11-gcc-ar          sparc-rtems4.11-gprof
367sparc-rtems4.11-objdump         sparc-rtems4.11-size
368sparc-rtems4.11-ar              sparc-rtems4.11-elfedit
369sparc-rtems4.11-gcc-nm          sparc-rtems4.11-ld
370sparc-rtems4.11-ranlib          sparc-rtems4.11-strings
371sparc-rtems4.11-as              sparc-rtems4.11-g++
372sparc-rtems4.11-gcc-ranlib      sparc-rtems4.11-ld.bfd
373sparc-rtems4.11-readelf         sparc-rtems4.11-strip
374sparc-rtems4.11-c++             sparc-rtems4.11-gcc
375sparc-rtems4.11-gcov            sparc-rtems4.11-nm
376sparc-rtems4.11-run             xmlwf
377sparc-rtems4.11-c++filt         sparc-rtems4.11-gcc-4.7.2
378sparc-rtems4.11-gdb             sparc-rtems4.11-objcopy
379sparc-rtems4.11-sis
380$ $HOME/development/rtems/4.11/bin/sparc-rtems4.11-gcc -v
381Using built-in specs.
382COLLECT_GCC=/home/chris/development/rtems/4.11/bin/sparc-rtems4.11-gcc
383COLLECT_LTO_WRAPPER=/usr/home/chris/development/rtems/4.11/bin/../ \
384libexec/gcc/sparc-rtems4.11/4.7.2/lto-wrapper
385Target: sparc-rtems4.11 <1>
386Configured with: ../gcc-4.7.2/configure <2>
387--prefix=/home/chris/development/rtems/4.11
388--bindir=/home/chris/development/rtems/4.11/bin
389--exec_prefix=/home/chris/development/rtems/4.11
390--includedir=/home/chris/development/rtems/4.11/include
391--libdir=/home/chris/development/rtems/4.11/lib
392--libexecdir=/home/chris/development/rtems/4.11/libexec
393--mandir=/home/chris/development/rtems/4.11/share/man
394--infodir=/home/chris/development/rtems/4.11/share/info
395--datadir=/home/chris/development/rtems/4.11/share
396--build=x86_64-freebsd9.1 --host=x86_64-freebsd9.1 --target=sparc-rtems4.11
397--disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib
398--with-system-zlib --disable-nls --without-included-gettext
399--disable-win32-registry --enable-version-specific-runtime-libs --disable-lto
400--enable-threads --enable-plugin --enable-newlib-io-c99-formats
401--enable-newlib-iconv --enable-languages=c,c++
402Thread model: rtems <3>
403gcc version 4.7.2 20120920 <4>
404 (RTEMS4.11-RSB(cb12e4875c203f794a5cd4b3de36101ff9a88403)-1,gcc-4.7.2/newlib-2.0.0) (GCC)
405-------------------------------------------------------------
406
407<1> The target the compiler is built for.
408<2> The configure options used to build GCC.
409<3> The threading model is always RTEMS. This makes the RTEMS tools difficult
410    for bare metal development more difficult.
411<4> The version string. It contains the Git hash of the RTEMS Source Builder
412    you are using. If your local clone has been modifed that state is also
413    recorded in the version string. The hash allows you to track from a GCC
414    executable back to the original source used to build it.
415
416NOTE: The RTEMS thread model enables specific hooks in GCC so applications
417built with RTEMS tools need the RTEMS runtime to operate correctly. You can use
418RTEMS tools to build bare metal component but it is more difficult than with a
419bare metal tool chain and you need to know what you are doing at a low
420level. The RTEMS Source Builder can build bare metal tool chains as well. Look
421in the top level +bare+ directory.
422
423Distributing and Archiving A Build
424~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425
426If you wish to create and distribute your build or you want to archive a build
427you can create a tar file. This is a more advanced method for binary packaging
428and installing of tools.
429
430By default the RTEMS Source Builder installs the built packages directly and
431optionally it can also create a _build set tar file_ or a _package tar file_
432per package built. The normal and default behaviour is to let the RTEMS Source
433Builder install the tools. The source will be downloaded, built, installed and
434cleaned up.
435
436The tar files are created with the full build prefix present and if you follow
437the examples given in this documentation the path is absolute. This can cause
438problems if you are installing on a host you do not have super user or
439administrator rights on because the prefix path may references part you do not
440have write access too and tar will not extract the files. You can use the
441+--strip-components+ option in tar if your host tar application supports it to
442remove the parts you do not have write access too or you may need to unpack the
443tar file somewhere and copy the file tree from the level you have write access
444from. Embedding the full prefix path in the tar files lets you know what the
445prefix is and is recommended. For example if
446`/home/chris/development/rtems/4.11` is the prefix used you cannot change
447directory to the root (`/`) and install because the `/home` is root access
448only. To install you would:
449
450-------------------------------------------------------------
451$ cd
452$ tar --strip-components=3 -xjf rtems-4.11-sparc-rtems4.11-1.tar.bz2
453-------------------------------------------------------------
454
455A build set tar file is created by adding `--bset-tar-file` option to the
456`sb-set-builder` command.
457
458-------------------------------------------------------------
459$ ../source-builder/sb-set-builder --log=l-sparc.txt \
460         --prefix=$HOME/development/rtems/4.11 \
461         --bset-tar-file <1> 4.11/rtems-sparc
462Source Builder - Set Builder, v0.2.0
463Build Set: 4.11/rtems-sparc
464config: expat-2.1.0-1.cfg
465package: expat-2.1.0-x86_64-freebsd9.1-1
466building: expat-2.1.0-x86_64-freebsd9.1-1
467config: tools/rtems-binutils-2.22-1.cfg
468package: sparc-rtems4.11-binutils-2.22-1
469building: sparc-rtems4.11-binutils-2.22-1
470config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
471package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
472building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
473config: tools/rtems-gdb-7.5.1-1.cfg
474package: sparc-rtems4.11-gdb-7.5.1-1
475building: sparc-rtems4.11-gdb-7.5.1-1
476installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <2>
477installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
478installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
479installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
480tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
481cleaning: expat-2.1.0-x86_64-freebsd9.1-1
482cleaning: sparc-rtems4.11-binutils-2.22-1
483cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
484cleaning: sparc-rtems4.11-gdb-7.5.1-1
485Build Set: Time 0:15:25.92873
486-------------------------------------------------------------
487
488<1> The option to create a build set tar file.
489<2> The installation still happens unless you specify `--no-install`.
490<3> Creating the build set tar file.
491
492You can also suppress installing the files using the `--no-install` option to
493the `sb-set-builder` command. This is usefu if your prefix is not accessiable
494when building Canadian cross compiled tool sets.
495
496-------------------------------------------------------------
497$ ../source-builder/sb-set-builder --log=l-sparc.txt \
498            --prefix=$HOME/development/rtems/4.11 \
499            --bset-tar-file --no-install <1> 4.11/rtems-sparc
500Source Builder - Set Builder, v0.2.0
501Build Set: 4.11/rtems-sparc
502config: expat-2.1.0-1.cfg
503package: expat-2.1.0-x86_64-freebsd9.1-1
504building: expat-2.1.0-x86_64-freebsd9.1-1
505config: tools/rtems-binutils-2.22-1.cfg
506package: sparc-rtems4.11-binutils-2.22-1
507building: sparc-rtems4.11-binutils-2.22-1
508config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
509package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
510building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
511config: tools/rtems-gdb-7.5.1-1.cfg
512package: sparc-rtems4.11-gdb-7.5.1-1
513building: sparc-rtems4.11-gdb-7.5.1-1
514tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <2>
515cleaning: expat-2.1.0-x86_64-freebsd9.1-1
516cleaning: sparc-rtems4.11-binutils-2.22-1
517cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
518cleaning: sparc-rtems4.11-gdb-7.5.1-1
519Build Set: Time 0:14:11.721274
520$ ls tar
521rtems-4.11-sparc-rtems4.11-1.tar.bz2
522-------------------------------------------------------------
523
524<1> The option to supressing installing the packages.
525<2> Create the build set tar.
526
527A package tar file can be created by adding the +--pkg-tar-files+ to the
528+sb-set-builder+ command. This creates a tar file per package built in the
529build set.
530
531-------------------------------------------------------------
532$ ../source-builder/sb-set-builder --log=l-sparc.txt \
533            --prefix=$HOME/development/rtems/4.11 \
534            --bset-tar-file --pkg-tar-files <1> --no-install 4.11/rtems-sparc
535Source Builder - Set Builder, v0.2.0
536Build Set: 4.11/rtems-sparc
537config: expat-2.1.0-1.cfg
538package: expat-2.1.0-x86_64-freebsd9.1-1
539building: expat-2.1.0-x86_64-freebsd9.1-1
540config: tools/rtems-binutils-2.22-1.cfg
541package: sparc-rtems4.11-binutils-2.22-1
542building: sparc-rtems4.11-binutils-2.22-1
543config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
544package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
545building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
546config: tools/rtems-gdb-7.5.1-1.cfg
547package: sparc-rtems4.11-gdb-7.5.1-1
548building: sparc-rtems4.11-gdb-7.5.1-1
549tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2
550cleaning: expat-2.1.0-x86_64-freebsd9.1-1
551cleaning: sparc-rtems4.11-binutils-2.22-1
552cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
553cleaning: sparc-rtems4.11-gdb-7.5.1-1
554Build Set: Time 0:14:37.658460
555$ ls tar
556expat-2.1.0-x86_64-freebsd9.1-1.tar.bz2           sparc-rtems4.11-binutils-2.22-1.tar.bz2
557sparc-rtems4.11-gdb-7.5.1-1.tar.bz2 <2>           rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
558sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1.tar.bz2
559-------------------------------------------------------------
560
561<1> The option to create packages tar files.
562<2> The GDB package tar file.
563<3> The build set tar file. All the others in a single tar file.
564
565Controlling the Build
566~~~~~~~~~~~~~~~~~~~~~
567
568Build sets can be controlled via the command line to enable and disable various
569features. There is no definitive list of build options that can be listed
570because they are implemented with the configuration scripts. The best way to
571find what is available is to grep the configuration files. for +with+ and
572+without+.
573
574Following are currentlt available:
575
576'--without-rtems':: Do not build RTEMS when building an RTEMS build set.
577'--without-cxx':: Do not build a C++ compiler.
578'--with-objc':: Attempt to build a C++ compiler.
579'--with-fortran':: Attempt to build a Fortran compiler.
580
581Why Build from Source ?
582-----------------------
583
584The RTEMS Source Builder is not a replacement for the binary install systems
585you have with commercial operating systems or open source operating system
586distributions. Those products and distributions are critically important and
587are the base that allows the Source Builder to work. The RTEMS Source Builder
588sits somewhere between you manually entering the commands to build a tool set
589and a tool such as +yum+ or +apt-get+ to install binary packages made
590specifically for your host operating system. Building manually or installing a
591binary package from a remote repository are valid and real alternatives while
592the Source Builder is attempting to provide a specific service of repeatably
593being able to build tool sets from source code.
594
595If you are developing a system or product that has a long shelf life or is used
596in a critical piece of infrastructure that has a long life cycle being able to
597build from source is important. It insulates the project from the fast ever
598changing world of the host development machines. If your tool set is binary and
599you have lost the ability to build it you have lost a degree of control and
600flexibility open source gives you. Fast moving host environments are
601fantastic. We have powerful multi-core computers with huge amounts of memory
602and state of the art operating systems to run on them however the product or
603project you are part of may need to be maintained well past the life time of
604these host. Being able to build from source an important and critical part of
605this process because you can move to a newer host and create an equivalent tool
606set.
607
608Building from source provides you with control over the configuration of the
609package you are building. If all or the most important dependent parts are
610built from source you limit the exposure to host variations. For example the
611GNU C compiler (gcc) currently uses a number of 3rd party libraries internally
612(gmp, mpfr, etc). If your validated compiler generating code for your target
613processor is dynamically linked against the host's version of these libraries
614any change in the host's configuration may effect you. The changes the host's
615package management system makes may be perfectly reasonable in relation to the
616distribution being managed however this may not extend to you and your
617tools. Building your tools from source and controlling the specific version of
618these dependent parts means you are not exposing yourself to unexpected and
619often difficult to resolve problems. On the other side you need to make sure
620your tools build and work with newer versions of the host operating
621system. Given the stability of standards based libraries like 'libc' and ever
622improving support for standard header file locations this task is becoming
623easier.
624
625The RTEMS Source Builder is designed to be audited and incorporated into a
626project's verification and validation process. If your project is developing
627critical applications that needs to be traced from source to executable code in
628the target, you need to also consider the tools and how to track them.
629
630If your IT department maintains all your computers and you do not have suitable
631rights to install binary packages, building from source lets you create your
632own tool set that you install under your home directory. Avoiding installing
633any extra packages as a super user is always helpful in maintaining a secure
634computing environment.
635
636[[_bugs]]
637Bugs, Crashes, and Build Failures
638---------------------------------
639
640The RTEMS Source Builder is a Python program and every care is taken to test
641the code however bugs, crashes, and build failures can and do happen. If you
642find a bug please report it via the RTEMS Bug tracker tool Bugzilla or via
643email on the RTEMS Users list. RTEMS's bugzilla is found at
644https://www.rtems.org/bugzilla/.
645
646Please include the generated RSB report. If you see the following a report has
647been generated:
648
649-------------------------------------------------------------
650 ...
651 ...
652Build FAILED <1>
653  See error report: rsb-report-4.11-rtems-lm32.txt <2>
654-------------------------------------------------------------
655<1> The build has failed.
656<2> The report's file name.
657
658The generated report contains the command line, version of the RSB, your host's
659+uname+ details, the version of Python and the last 200 lines of the log.
660
661If for some reason there is no report please send please report the following:
662
663. Command line,
664. The git hash,
665. Host details with the output of the +uname -a+ command,
666. If you have made any modifications.
667
668If there is a Python crash please cut and paste the Python backtrace into the
669bug report. If the tools fail to build please locate the first error in the log
670file. This can be difficult to find on hosts with many cores so it sometimes
671pays to re-run the command with the +--jobs=none+ option to get a log that is
672correctly sequenced. If searching the log file seach for +error:+ and the error
673should be just above it.
674
675[[_contributing]]
676Contributing
677------------
678
679We welcome all users adding, fixing, updating and upgrading packages and their
680configurations. The RSB is open source and open to contributions. These can be
681bug fixes, new features or new configurations. Please break patches down into
682changes to the core Python code, configuration changes or new configurations.
683
684Please email me patches via git so I can maintain your commit messages so you
685are acknowledged as the contributor.
686
687Most of what follows is related to the development of RSB and it's
688configurations.
689
690Project Sets
691------------
692
693The RTEMS Source Builder supports project configurations. Project
694configurations can be public or private and can be contained in the RTEMS
695Source Builder project if suitable, other projects they use the RTEMS Source
696Builder or privately on your local file system.
697
698The configuration file loader searches the macro +_configdir+ and by default
699this is set to +%{\_topdir}/config:%{\_sbdir}/config+ where +_topdir+ is the
700your current working direct, in other words the directory you invoke the RTEMS
701Source Builder command in, and +_sbdir+ is the directory where the RTEMS Source
702Builder command resides. Therefore the +config+ directory under each of these
703is searched so all you need to do is create a +config+ in your project and add
704your configuration files. They do not need to be under the RTEMS Source Builder
705source tree. Public projects are included in the main RTEMS Source Builder such
706as RTEMS.
707
708You can also add your own +patches+ directory next to your +config+ directory
709as the +%patch+ command searches the +_patchdir+ macro variable and it is
710by default set to +%{\_topdir}/patches:%{\_sbdir}/patches+.
711
712The +source-builder/config+ directory provides generic scripts for building
713various tools. You can specialise these in your private configurations to make
714use of them. If you add new generic configurations please contribute them back
715to the project
716
717Bare Metal
718~~~~~~~~~~
719
720The RSB contains a 'bare' configuration tree and you can use this to add
721packages you use on the hosts. For example 'qemu' is supported on a range of
722hosts. RTEMS tools live in the +rtems/config+ directory tree. RTEMS packages
723include tools for use on your host computer as well as packages you can build
724and run on RTEMS.
725
726The 'bare metal' support for GNU Tool chains. An example is the 'lang/gcc491'
727build set. You need to provide a target via the command line '--target'
728option and this is in the standard 2 or 3 tuple form. For example for an ARM
729compiler you would use 'arm-eabi' or 'arm-eabihf', and for SPARC you would
730use 'sparc-elf'.
731
732-------------------------------------------------------------
733$ cd rtems-source-builder/bare
734$../source-builder/sb-set-builder --log=log_arm_eabihf \
735    --prefix=$HOME/development/bare --target=arm-eabihf lang/gcc491
736RTEMS Source Builder - Set Builder, v0.3.0
737Build Set: lang/gcc491
738config: devel/expat-2.1.0-1.cfg
739package: expat-2.1.0-x86_64-apple-darwin13.2.0-1
740building: expat-2.1.0-x86_64-apple-darwin13.2.0-1
741config: devel/binutils-2.24-1.cfg
742package: arm-eabihf-binutils-2.24-1
743building: arm-eabihf-binutils-2.24-1
744config: devel/gcc-4.9.1-newlib-2.1.0-1.cfg
745package: arm-eabihf-gcc-4.9.1-newlib-2.1.0-1
746building: arm-eabihf-gcc-4.9.1-newlib-2.1.0-1
747config: devel/gdb-7.7-1.cfg
748package: arm-eabihf-gdb-7.7-1
749building: arm-eabihf-gdb-7.7-1
750installing: expat-2.1.0-x86_64-apple-darwin13.2.0-1 -> /Users/chris/development/bare
751installing: arm-eabihf-binutils-2.24-1 -> /Users/chris/development/bare
752installing: arm-eabihf-gcc-4.9.1-newlib-2.1.0-1 -> /Users/chris/development/bare
753installing: arm-eabihf-gdb-7.7-1 -> /Users/chris/development/bare
754cleaning: expat-2.1.0-x86_64-apple-darwin13.2.0-1
755cleaning: arm-eabihf-binutils-2.24-1
756cleaning: arm-eabihf-gcc-4.9.1-newlib-2.1.0-1
757cleaning: arm-eabihf-gdb-7.7-1
758-------------------------------------------------------------
759
760RTEMS
761~~~~~
762
763The RTEMS Configurations found in the 'rtems' directory. The configurations are
764grouped by RTEMS version. In RTEMS the tools are specific to a specific version
765because of variations between Newlib and RTEMS. Restructuring in RTEMS and
766Newlib sometimes moves _libc_ functionality between these two parts and this
767makes existing tools incompatible with RTEMS.
768
769RTEMS allows architectures to have different tool versions and patches. The
770large number of architectures RTEMS supports can make it difficult to get a
771common stable version of all the packages. An architecture may require a recent
772GCC because an existing bug has been fixed, however the more recent version may
773have a bug in other architecture. Architecture specific patches should be
774limited to the architecture it relates to. The patch may fix a problem on the
775effect architecture however it could introduce a problem in another
776architecture. Limit exposure limits any possible crosstalk between
777architectures.
778
779RTEMS supports _stable_ and _unstable_. Stable configurations are fixed while
780unstable configurations are supporting using snapshots of user macros and
781reference release candidates or source extracted directly from version
782control. The stable build sets are referenced as +<version>/rtems-<arch>+ and
783include `autoconf` and `automake`.
784
785If you are building a released version of RTEMS the release RTEMS tar file will
786be downloaded and built as part of the build process. If you are building a
787tool set for use with the development branch of RTEMS, the development branch
788will be cloned directly from the RTEMS GIT repository and built.
789
790When building RTEMS within the RTEMS Source Builder it needs a suitable working
791`autoconf` and `automake`. These packages need to built and installed in their
792prefix in order for them to work. The RTEMS Source Builder installs all
793packages only after they have been built so if you host does not have a
794recent enough version of `autoconf` and `automake` you first need to build them
795and install them then build your tool set. The commands are:
796
797-------------------------------------------------------------
798$ ../source-builder/sb-set-builder --log=l-4.11-at.txt \
799   --prefix=$HOME/development/rtems/4.11 4.11/rtems-autotools
800$ export PATH=~/development/rtems/4.11/bin:$PATH <1>
801$ ../source-builder/sb-set-builder --log=l-4.11-sparc.txt \
802   --prefix=$HOME/development/rtems/4.11 4.11/rtems-sparc
803-------------------------------------------------------------
804<1> Setting the path.
805
806TIP: If this is your first time building the tools and RTEMS it pays to add the
807`--dry-run` option. This will run through all the configuration files and if
808any checks fail you will see this quickly rather than waiting for until the
809build fails a check.
810
811To build snapshots for testing purposes you use the available macro maps
812passing them on the command line using the `--macros` option. For RTEMS these
813are held in `config/snapshots` directory. The following builds _newlib_ from
814CVS:
815
816-------------------------------------------------------------
817$ ../source-builder/sb-set-builder --log=l-4.11-sparc.txt \
818   --prefix=$HOME/development/rtems/4.11 \
819   --macros=snapshots/newlib-head.mc \
820   4.11/rtems-sparc
821-------------------------------------------------------------
822
823and the following uses the version control heads for _binutils_, _gcc_,
824_newlib_, _gdb_ and _RTEMS_:
825
826-------------------------------------------------------------
827$ ../source-builder/sb-set-builder --log=l-heads-sparc.txt \
828   --prefix=$HOME/development/rtems/4.11-head \
829   --macros=snapshots/binutils-gcc-newlib-gdb-head.mc \
830   4.11/rtems-sparc
831-------------------------------------------------------------
832
833Patches
834~~~~~~~
835
836Packages being built by the RSB need patches from time to time and the RSB
837supports patching upstream packages. The patches are held in a seperate
838directory called +patches+ relative to the configuration directory you are
839building. For example +%{\_topdir}/patches:%{\_sbdir}/patches+. Patches are
840declared in the configuration files in a similar manner to the package's source
841so please refer to the +%source+ documentation. Patches, like the source, are
842to be made publically available for configurations that live in the RSB package
843and are downloaded on demand.
844
845If a package has a patch management tool it is recommended you reference the
846package's patch management tools directly. If the RSB does not support the
847specific patch manage tool please contact the mailing list to see if support
848can be added.
849
850Patches for packages developed by the RTEMS project can be placed in the RTEMS
851Tools Git repository. The +tools+ directory in the repository has various
852places a patch can live. The tree is broken down in RTEMS releases and then
853tools within that release. If the package is not specific to any release the
854patch can be added closer to the top under the package's name. Patches to fix
855specific tool related issues for a specific architecture should be grouped
856under the specific architecture and only applied when building that
857architecture avoiding a patch breaking an uneffected architecture.
858
859Patches in the RTEMS Tools repository need to be submitted to the upstream
860project. It should not be a clearing house for patches that will not be
861accepted upstream.
862
863Patches are added to a component's name and in the +%prep:+ section the patches
864can be set up, meaning they are applied to source. The patches are applied in
865the order they are added. If there is a dependency make sure you order the
866patches correctly when you add them. You can add any number of patches and the
867RSB will handle them efficently.
868
869Patches can have options. These are added before the patch URL. If no options
870are provided the patch's setup default options are used.
871
872Patches can be declared in build set up files.
873
874This examples shows how to declare a patch for gdb in the +lm32+ architecture:
875
876-------------------------------------------------------------
877%patch add <1> gdb <2> %{rtems_gdb_patches}/lm32/gdb-sim-lm32uart.diff <3>
878-------------------------------------------------------------
879<1> The patch's +add+ command.
880<2> The group of patches this patch belongs too.
881<3> The patch's URL. It is downloaded from here.
882
883Patches require a checksum to avoid a warning. The +%hash+ directive can be
884used to add a checksum for a patch that is used to verify the patch:
885
886-------------------------------------------------------------
887%hash md5 <1> gdb-sim-lm32uart.diff <2> 77d070878112783292461bd6e7db17fb <3>
888-------------------------------------------------------------
889<1> The type of checksum, in the case an MD5 hash.
890<2> The patch file the checksum is for.
891<3> The MD5 hash.
892
893The patches are applied when a patch +setup+ command is issued in the +%prep:+
894section. All patches in the group are applied. To apply the GDB patch above
895use:
896
897-------------------------------------------------------------
898%patch setup <1> gdb <2> -p1 <3>
899-------------------------------------------------------------
900<1> The patch's +setup+ command.
901<2> The group of patches to apply.
902<3> The patch group's default options. If no option is given with the patch
903these options are used.
904
905Architecture specific patches live in the architecture build set file isolating
906the patch to that specific architecture. If a patch is common to a tool it
907resides in the RTEMS tools configuration file. Do not place patches for tools
908in the +source-builder/config+ template configuration files.
909
910To test a patch simply copy it to your local +patches+ directory. The RSB will
911see the patch is present and will not attempt to download it. Once you are
912happy with the patch submit it to the project and a core developer will review
913it and add it to the RTEMS Tools git repository.
914For example, to test a local patch for newlib, add the following two lines to
915the .cfg file in +rtems/config/tools/+ that is included by the bset you use:
916-------------------------------------------------------------
917%patch add newlib file://0001-this-is-a-newlib-patch.patch <1>
918%hash md5 0001-this-is-a-newlib-patch.diff 77d070878112783292461bd6e7db17fb <2>
919-------------------------------------------------------------
920<1> The diff file prepended with +file://+ to tell RSB this is a local file.
921<2> The output from md5sum on the diff file.
922
923Cross and Canadian Cross Building
924---------------------------------
925
926Cross building and Canadian Cross building is the process of building on one
927machine an executable that runs on another machine. An example is building a
928set of RTEMS tools on Linux to run on Windows. The RSB supports cross building
929and Canadian cross building.
930
931This sections details how to the RSB to cross and Canadian cross build.
932
933Cross Building
934~~~~~~~~~~~~~~
935
936Cross building is where the _build_ machine and _host_ are different. The
937_build_ machine runs the RSB and the _host_ machine is where the output from
938the build runs. An example is building a package such as NTP for RTEMS on your
939development machine.
940
941To build the NTP package for RTEMS you enter the RSB command:
942
943-------------------------------------------------------------
944$ ../source-builder/sb-set-builder \
945   --log=log_ntp_arm.txt \
946   --prefix=$HOME/development/rtems/4.11 <1> \
947   --host=arm-rtems4.11 <2> \
948   --with-rtems-bsp=xilinx_zynq_zc706 <3> \
949   4.11/net/ntp
950-------------------------------------------------------------
951<1> The tools and the RTEMS BSP are installed under the same prefix.
952<2> The +--host+ command is the RTEMS architecture and version.
953<3> The BSP is built and installed in the prefix. The arhcitecture must
954    match the +--host+ architecture.
955
956TIP: If you install BSPs into a different path to the prefix use the
957+--with-tools+ option to specify the path to the tools. Do not add the 'bin'
958directory at the end of the path.
959
960Canadian Cross Building
961~~~~~~~~~~~~~~~~~~~~~~~
962
963A Canadian cross builds are where the _build_, _host_ and _target_ machines all
964differ. For example building an RTEMS compiler for an ARM processor that runs
965on Windows is built using a Linux machine. The process is controlled by setting
966the build triplet to the host you are building, the host triplet to the host
967the tools will run on and the target to the RTEMS architecture you require. The
968tools needed by the RSB are:
969
970. Build host C and C++ compiler
971. Host C and C++ cross compiler
972
973The RTEMS Source Builder requires you provide the build host C and C\++
974compiler and the final host C and C\++ cross-compiler. The RSB will build the
975build host RTEMS compiler and the final host RTEMS C and C++ compiler, the
976output of this process.
977
978The Host C and C++ compiler is a cross-compiler that builds executables for
979the host you want the tools for. You need to provide these tools. For Windows a
980number of Unix operating systems provide MinGW tool sets as packages.
981
982The RSB will build an RTEMS tool set for the build host. This is needed when
983building the final host's RTEMS compiler as it needs to build RTEMS runtime
984code such as _libc_ on the build host.
985
986TIP: Make sure the host's cross-compiler tools are in your path before run the
987RSB build command.
988
989TIP: Canadian Cross built tools will not run on the machine being used to build
990them so you should provide the +--bset-tar-files+ and +--no-install+
991options. The option to not install the files lets you provide a prefix that
992does not exist or you cannot access.
993
994To perform a cross build add +--host=+ to the command line. For example to
995build a MinGW tool set on FreeBSD for Windows add +--host=mingw32+ if the cross
996compiler is +mingw32-gcc+:
997
998-------------------------------------------------------------
999$ ../source-builder/sb-set-builder --host=mingw32 \
1000   --log=l-mingw32-4.11-sparc.txt \
1001   --prefix=$HOME/development/rtems/4.11 \
1002   4.11/rtems-sparc
1003-------------------------------------------------------------
1004
1005If you are on a Linux Fedora build host with the MinGW packages installed the
1006command line is:
1007
1008-------------------------------------------------------------
1009$ ../source-builder/sb-set-builder --host=i686-w64-mingw32 \
1010   --log=l-mingw32-4.11-sparc.txt \
1011   --prefix=$HOME/development/rtems/4.11 \
1012   4.11/rtems-sparc
1013-------------------------------------------------------------
1014
1015RTEMS 3rd Party Packages
1016------------------------
1017
1018This section describes how to build and add an RTEMS 3rd party package to the
1019RSB.
1020
1021A 3rd party package is a library or software package built to run on RTEMS,
1022examples are NTP, Net-Snmp, libjpeg or Python. These pieces of software can be
1023used to help build RTEMS applications. The package is built for a specific
1024BSP and so requires a working RTEMS tool chain and an installed RTEMS Board
1025Support Package (BSP).
1026
1027The RSB support for building 3rd part packages is based around the pkconfig
1028files (PC) installed with the BSP. The pkgconfig support in RTEMS is considered
1029experimental and can have some issues for some BSPs. This issue is rooted deep
1030in the RTEMS build system. If you have any issues with this support please ask
1031on the RTEMS developers mailing list.
1032
1033Building
1034~~~~~~~~
1035
1036To build a package you need to have a suitable RTEMS tool chain and RTEMS BSP
1037installed. The set builder command line requires you provide the tools path,
1038the RTEMS host, and the prefix path to the installed RTEMS BSP. The prefix
1039needs to be the same as the prefix used to build RTEMS.
1040
1041To build Net-SNMP the command is:
1042
1043-------------------------------------------------------------
1044cd rtems-source-builder/rtems
1045$ ../source-builder/sb-set-builder --log=log_sis_net_snmp \
1046    --prefix=$HOME/development/rtems/bsps/4.11 \
1047    --with-tools=$HOME/development/rtems/4.11 \
1048    --host=sparc-rtems4.11 --with-rtems-bsp=sis 4.11/net-mgmt/net-snmp
1049RTEMS Source Builder - Set Builder, v0.3.0
1050Build Set: 4.11/net-mgmt/net-snmp
1051config: net-mgmt/net-snmp-5.7.2.1-1.cfg
1052package: net-snmp-5.7.2.1-sparc-rtems4.11-1
1053building: net-snmp-5.7.2.1-sparc-rtems4.11-1
1054installing: net-snmp-5.7.2.1-sparc-rtems4.11-1 -> /Users/chris/development/rtems/bsps/4.11
1055cleaning: net-snmp-5.7.2.1-sparc-rtems4.11-1
1056Build Set: Time 0:01:10.651926
1057-------------------------------------------------------------
1058
1059Adding
1060~~~~~~
1061
1062Adding a package requires you first build it manually by downloading the source
1063for the package and building it for RTEMS using the command line of a standard
1064shell. If the package has not been ported to RTEMS you will need to port it and
1065this may require you asking questions on the package's user or development
1066support lists as well as RTEMS's developers list. Your porting effort may end
1067up with a patch. RTEMS requires a patch be submitted upstream to the project's
1068community as well as RTEMS so it can be added to the RTEMS Tools git
1069repository. A patch in the RTEMS Tools git reposiitory can then be referenced
1070by an RSB configuration file.
1071
1072A package may create executables, for example NTP normally creates executables
1073such as +ntdp+, +ntpupdate+, or +ntpdc+. These executables can be useful when
1074testing the package however they are of limited use by RTEMS users because they
1075cannot be directly linked into a user application. Users need to link to the
1076functions in these executables or even the executable as a function placed in
1077libraries. If the package does not export the code in a suitable manner please
1078contact the project's commuinity and see if you can work them to provide a way
1079for the code to be exported. This may be difficult because exporting internal
1080headers and functions opens the project up to API compatibility issues they did
1081not have before. In the simplest case attempting to get the code into a static
1082library with a single call entry point exported in a header would give RTEMS
1083user's access to the package's main functionality.
1084
1085A package requires 3 files to be created:
1086
1087. The first file is the RTEMS build set file and it resides in the
1088  +$$rtems/config/%{rtems_version}$$+ path in a directory tree based on the
1089  FreeBSD ports collection. For the NTP package and RTEMS 4.11 this is
1090  +rtems/config/4.11/net/ntp.bset+. If you do not know the FreeBSD port path
1091  for the package you are adding please ask. The build set file references a
1092  specific configuration file therefore linking the RTEMS version to a specific
1093  version of the package you are adding. Updating the package to a new version
1094  requires changing the build set to the new configuration file.
1095
1096. The second file is an RTEMS version specific configuration file and it
1097  includes the RSB RTEMS BSP support. These configuration files reside in the
1098  +rtems/config+ tree again under the FreeBSD port's path name. For example the
1099  NTP package is found in the +net+ directory of the FreeBSD ports tree so the
1100  NTP configuration path is +$$rtems/config/net/ntp-4.2.6p5-1.cfg$$+ for that
1101  specific version. The configuration file name typically provides version
1102  specific references and the RTEMS build set file references a specific
1103  version. This configuration file references the build configuration file held
1104  in the common configuration file tree.
1105
1106. The build configuration. This is a common script that builds the package. It
1107  resides in the +source-builder/config+ directory and typically has the
1108  packages's name with the major version number. If the build script does not
1109  change for each major version number a _common_ base script can be created
1110  and included by each major version configuration script. The _gcc_ compiler
1111  configuration is an example. This approach lets you branch a version if
1112  something changes that is not backwards compatible. It is important to keep
1113  existing versions building. The build configuration should be able to build a
1114  package for the build host as well as RTEMS as the RSB abstracts the RTEMS
1115  specific parts. See <<H1,+_Configuration_+>> for more details.
1116
1117BSP Support
1118~~~~~~~~~~~
1119
1120The RSB provides support to help build packages for RTEMS. RTEMS applications
1121can be viewed as statically linked executables operating in a single address
1122space. As a result only the static libraries a package builds are required and
1123these libraries need to be ABI compatible with the RTEMS kernel and application
1124code meaning compiler ABI flags cannot be mixed when building code. The 3rd
1125party package need to use the same compiler flags as the BSP used to build
1126RTEMS.
1127
1128[TIP]
1129=============================================================
1130
1131RTEMS's dynamic loading support does not use the standard shared library
1132support found in Unix and the ELF standard. RTEMS's loader uses static
1133libraries and the runtime link editor performs a similar function to a host
1134based static linker. RTEMS will only reference static libraries even if dynamic
1135libraries are created and installed.
1136
1137=============================================================
1138
1139The RSB provides the configuration file +rtems/config/rtems-bsp.cfg+ to support
1140building 3rd party packages and you need to include this file in your RTEMS
1141version specific configuration file. For example the Net-SNMP configuration
1142file:
1143
1144.rtems/config/net-mgmt/net-snmp-5.7.2.1-1.cfg
1145-------------------------------------------------------------
1146#
1147# NetSNMP 5.7.2.1
1148#
1149
1150%if %{release} == %{nil}
1151 %define release 1 <1>
1152%endif
1153
1154%include %{_configdir}/rtems-bsp.cfg <2>
1155
1156#
1157# NetSNMP Version
1158#
1159%define net_snmp_version 5.7.2.1 <3>
1160
1161#
1162# We need some special flags to build this version.
1163#
1164%define net_snmp_cflags <4> -DNETSNMP_CAN_USE_SYSCTL=1 -DARP_SCAN_FOUR_ARGUMENTS=1 -DINP_IPV6=0
1165
1166#
1167# Patch for RTEMS support.
1168#
1169%patch add net-snmp %{rtems_git_tools}/net-snmp/rtems-net-snmp-5.7.2.1-20140623.patch <5>
1170
1171#
1172# NetSNMP Build configuration
1173#
1174%include %{_configdir}/net-snmp-5-1.cfg <6>
1175-------------------------------------------------------------
1176<1> The release number.
1177<2> Include the RSB RTEMS BSP support.
1178<3> The Net-SNMP package's version.
1179<4> Add specific CFLAGS to the build process. See the +net-snmp-5.7.2.1-1.cfg+
1180    for details.
1181<5> The RTEMS Net-SNMP patch downloaded from the RTEMS Tools git repo.
1182<6> The Net-SNMP standard build configuration.
1183
1184The RSB RTEMS BSP support file +rtems/config/rtems-bsp.cfg+ checks to make sure
1185standard command line options are provided. These include `--host` and
1186`--with-rtems-bsp`. If the `--with-tools` command line option is not given the
1187+${\_prefix}+ is used.
1188
1189.rtems/config/rtems-bsp.cfg
1190-------------------------------------------------------------
1191%if %{_host} == %{nil} <1>
1192 %error No RTEMS target specified: --host=host
1193%endif
1194
1195%ifn %{defined with_rtems_bsp} <2>
1196 %error No RTEMS BSP specified: --with-rtems-bsp=bsp
1197%endif
1198
1199%ifn %{defined with_tools} <3>
1200 %define with_tools %{_prefix}
1201%endif
1202
1203#
1204# Set the path to the tools.
1205#
1206%{path prepend %{with_tools}/bin} <4>
1207-------------------------------------------------------------
1208<1> Check the host has been set.
1209<2> Check a BSP has been specified.
1210<3> If no tools path has been provided assume they are under the %{\_prefix}.
1211<4> Add the tools +bin+ path to the system path.
1212
1213RTEMS exports the build flags used in pkgconfig (.pc) files and the RSB can
1214read and manage them even when there is no pkgconfig support installed on your
1215build machine. Using this support we can obtain a BSP's configuration and set
1216some standard macros variables:
1217
1218.rtems/config/rtems-bsp.cfg
1219-------------------------------------------------------------
1220%{pkgconfig prefix %{_prefix}/lib/pkgconfig} <1>
1221%{pkgconfig crosscompile yes} <2>
1222%{pkgconfig filter-flags yes} <3>
1223
1224#
1225# The RTEMS BSP Flags
1226#
1227%define rtems_bsp           %{with_rtems_bsp}
1228%define rtems_bsp_ccflags   %{pkgconfig ccflags %{_host}-%{rtems_bsp}} <4>
1229%define rtems_bsp_cflags    %{pkgconfig cflags  %{_host}-%{rtems_bsp}}
1230%define rtems_bsp_ldflags   %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
1231%define rtems_bsp_libs      %{pkgconfig libs    %{_host}-%{rtems_bsp}}
1232-------------------------------------------------------------
1233<1> Set the path to the BSP's pkgconfig file.
1234<2> Let pkgconfig know this is a cross-compile build.
1235<3> Filter flags such as warnings. Warning flags are specific to a package.
1236<4> Ask pkgconfig for the various items we require.
1237
1238The flags obtain by pkgconfig and given a `rtems_bsp_` prefix and we uses these
1239to set the RSB host support CFLAGS, LDFLAGS and LIBS flags. When we build a 3rd
1240party library your host computer is the _build_ machine and RTEMS is the _host_
1241machine therefore we set the `host` variables:
1242
1243.rtems/config/rtems-bsp.cfg
1244-------------------------------------------------------------
1245%define host_cflags  %{rtems_bsp_cflags}
1246%define host_ldflags %{rtems_bsp_ldflags}
1247%define host_libs    %{rtems_bsp_libs}
1248-------------------------------------------------------------
1249
1250Finally we provide all the paths you may require when configuring a
1251package. Packages by default consider the `_prefix` the base and install
1252various files under this tree. The package you are building is specific to a
1253BSP and so needs to install into the specific BSP path under the
1254`_prefix`. This allows more than BSP build of this package to be install under
1255the same `_prefix` at the same time:
1256
1257.rtems/config/rtems-bsp.cfg
1258-------------------------------------------------------------
1259%define rtems_bsp_prefix  %{_prefix}/%{_host}/%{rtems_bsp} <1>
1260%define _exec_prefix      %{rtems_bsp_prefix}
1261%define _bindir           %{_exec_prefix}/bin
1262%define _sbindir          %{_exec_prefix}/sbin
1263%define _libexecdir       %{_exec_prefix}/libexec
1264%define _datarootdir      %{_exec_prefix}/share
1265%define _datadir          %{_datarootdir}
1266%define _sysconfdir       %{_exec_prefix}/etc
1267%define _sharedstatedir   %{_exec_prefix}/com
1268%define _localstatedir    %{_exec_prefix}/var
1269%define _includedir       %{_libdir}/include
1270%define _lib              lib
1271%define _libdir           %{_exec_prefix}/%{_lib}
1272%define _libexecdir       %{_exec_prefix}/libexec
1273%define _mandir           %{_datarootdir}/man
1274%define _infodir          %{_datarootdir}/info
1275%define _localedir        %{_datarootdir}/locale
1276%define _localedir        %{_datadir}/locale
1277%define _localstatedir    %{_exec_prefix}/var
1278-------------------------------------------------------------
1279<1> The path to the BSP.
1280
1281When you configure a package you can reference these paths and the RSB will
1282provide sensible default or in this case map them to the BSP:
1283
1284.source-builder/config/ntp-4-1.cfg
1285-------------------------------------------------------------
1286  ../${source_dir_ntp}/configure \ <1>
1287    --host=%{_host} \
1288    --prefix=%{_prefix} \
1289    --bindir=%{_bindir} \
1290    --exec_prefix=%{_exec_prefix} \
1291    --includedir=%{_includedir} \
1292    --libdir=%{_libdir} \
1293    --libexecdir=%{_libexecdir} \
1294    --mandir=%{_mandir} \
1295    --infodir=%{_infodir} \
1296    --datadir=%{_datadir} \
1297    --disable-ipv6 \
1298    --disable-HOPFPCI
1299-------------------------------------------------------------
1300<1> The configure command for NTP.
1301
1302RTEMS BSP Configuration
1303~~~~~~~~~~~~~~~~~~~~~~~
1304
1305To build a package for RTEMS you need to build it with the matching BSP
1306configuration. A BSP can be built with specific flags that require all code
1307being used needs to be built with the same flags.
1308
1309
1310[[H1]]
1311Configuration
1312-------------
1313
1314The RTEMS Source Builder has two types of configuration data:
1315
1316. Build Sets
1317. Package Build Configurations
1318
1319By default these files can be located in two separate directories and
1320searched. The first directory is +config+ in your current working directory
1321(+_topdir+) and the second is +config+ located in the base directory of the
1322RTEMS Source Builder command you run (+_sbdir+). The RTEMS directory +rtems+
1323located at the top of the RTEMS Source Builder source code is an example of a
1324specific build configuration directory. You can create custom or private build
1325configurations and if you run the RTEMS Source Builder command from that
1326directory your configurations will be used.
1327
1328[[X1]] The configuration search path is a macro variable and is reference as
1329+%\{_configdir\}+. It's default is defined as:
1330
1331-------------------------------------------------------------
1332_configdir   : dir  optional<2>  %{_topdir}/config:%{_sbdir}/config <1>
1333-------------------------------------------------------------
1334
1335<1> The +_topdir+ is the directory you run the command from and +_sbdir+ is the
1336location of the RTEMS Source Builder command.
1337<2> A macro definition in a macro file has 4 fields, the label, type,
1338constraint and the definition.
1339
1340Build set files have the file extension +.bset+ and the package build
1341configuration files have the file extension of +.cfg+. The +sb-set-builder+
1342command will search for _build sets_ and the +sb-builder+ commands works with
1343package build configuration files.
1344
1345Both types of configuration files use the \'#' character as a comment
1346character. Anything after this character on the line is ignored. There is no
1347block comment.
1348
1349Source and Patches
1350~~~~~~~~~~~~~~~~~~
1351
1352The RTEMS Source Builder provides a flexible way to manage source. Source and
1353patches are declare in configurations file using the +source+ and +patch+
1354directives. These are a single line containing a Universal Resource Location or
1355URL and can contain macros and shell expansions. The <<_prep,%prep>> section
1356details the source and patch directives
1357
1358The URL can reference remote and local source and patch resources. The
1359following schemes are provided:
1360
1361'http':: Remote access using the HTTP protocol.
1362'https':: Remote access using the Secure HTTP protocol.
1363'ftp':: Remote access using the FTP protocol.
1364'git':: Remote access to a GIT repository.
1365'cvs':: Remote access to a CVS repository.
1366'pm':: Remote access to a patch management repository.
1367'file':: Local access to an existing source directory.
1368
1369HTTP, HTTPS, and FTP
1370^^^^^^^^^^^^^^^^^^^^
1371
1372Remote access to TAR or ZIP files is provided using HTTP, HTTPS and FTP
1373protocols. The full URL provided is used to access the remote file including
1374any query components. The URL is parsed to extract the file component and the
1375local source directory is checked for that file. If the file is located locally
1376the remote file is not downloaded. Currently no other checks are made. If a
1377download fails you need to manually remove the file from the source directory
1378and start the build process again.
1379
1380The URL can contain macros. These are expanded before issuing the request to
1381download the file. The standard GNU GCC compiler source URL is:
1382
1383-------------------------------------------------------------
1384%source set<1> gcc<2> ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
1385-------------------------------------------------------------
1386<1> The +%source+ command's set command sets the source. The first is set and
1387following sets are ignored.
1388<2> The source is part of the +gcc+ group.
1389
1390The type of compression is automatically detected from the file extension. The
1391supported compression formats are:
1392
1393'gz':: GNU ZIP
1394'bzip2':: BZIP2
1395'zip':: ZIP
1396'xy':: XY
1397
1398The output of the decompression tool is feed to the standard `tar` utility if
1399not a ZIP file and unpacked into the build directory. ZIP files are unpacked by
1400the decompression tool and all other files must be in the tar file format.
1401
1402The +%source+ directive typically supports a single source file tar or zip
1403file. The +set+ command is used to set the URL for a specific source group. The
1404first set command encoutner is registered and any further set commands are
1405ignored. This allows you to define a base standard source location and override
1406it in build and architecture specific files. You can also add extra source
1407files to a group. This is typically done when a collection of source is broken
1408down in a number of smaller files and you require the full package. The
1409source's +setup+ command must reide in the +%prep:+ section and it unpacks the
1410source code ready to be built.
1411
1412If the source URL references the GitHub API server 'https://api.github.com/' a
1413tarball of the specified version is download. For example the URL for the
1414STLINK project on GitHub and version is:
1415
1416-------------------------------------------------------------
1417%define stlink_version 3494c11
1418%source set stlink https://api.github.com/repos/texane/stlink/texane-stlink-%{stlink_version}.tar.gz
1419-------------------------------------------------------------
1420
1421GIT
1422^^^
1423
1424A GIT repository can be cloned and used as source. The GIT repository resides
1425in the 'source' directory under the `git` directory. You can edit, update and
1426use the repository as you normally do and the results will used to build the
1427tools. This allows you to prepare and test patches in the build environment the
1428tools are built in. The GIT URL only supports the GIT protocol. You can control
1429the repository via the URL by appending options and arguments to the GIT
1430path. The options are delimited by `?` and option arguments are delimited from
1431the options with `=`. The options are:
1432
1433`protocol`:: Use a specific protocol. The supported values are _ssh_, _git_,
1434_http_, _https_, _ftp_, _ftps_, _rsync_, and _none_.
1435`branch`:: Checkout the specified branch.
1436`pull`:: Perform a pull to update the repository.
1437`fetch`:: Perform a fetch to get any remote updates.
1438`reset`:: Reset the repository. Useful to remove any local changes. You can
1439pass the `hard` argument to force a hard reset.
1440
1441-------------------------------------------------------------
1442%source set gcc git://gcc.gnu.org/git/gcc.git?branch=gcc-4_7-branch?reset=hard
1443-------------------------------------------------------------
1444
1445This will clone the GCC git repository and checkout the 4.7-branch and perform
1446a hard reset. You can select specific branches and apply patches. The
1447repository is cleaned up before each build to avoid various version control
1448errors that can arise.
1449
1450The protocol option lets you set a specific protocol. The 'git://' prefix used
1451by the RSB to select a git repository can be removed using _none_ or replaced
1452with one of the standard git protcols.
1453
1454CVS
1455^^^
1456
1457A CVS repository can be checked out. CVS is more complex than GIT to handle
1458because of the modules support. This can effect the paths the source ends up
1459in. The CVS URL only supports the CVS protocol. You can control the repository
1460via the URL by appending options and arguments to the CVS path. The options are
1461delimited by `?` and option arguments are delimited from the options with
1462`=`. The options are:
1463
1464`module`:: The module to checkout.
1465`src-prefix`:: The path into the source where the module starts.
1466`tag`:: The CVS tag to checkout.
1467`date`:: The CVS date to checkout.
1468
1469-------------------------------------------------------------
1470%source set newlib cvs://pserver:anoncvs@sourceware.org/cvs/src?module=newlib?src-prefix=src
1471-------------------------------------------------------------
1472
1473Macros and Defaults
1474~~~~~~~~~~~~~~~~~~~
1475
1476The RTEMS Source Builder uses tables of _macros_ read in when the tool
1477runs. The initial global set of macros is called the _defaults_. These values
1478are read from a file called `defaults.mc` and modified to suite your host. This
1479host specific adaption lets the Source Builder handle differences in the build
1480hosts.
1481
1482Build set and configuration files can define new values updating and extending
1483the global macro table. For example builds are given a release number. This is
1484typically a single number at the end of the package name. For example:
1485
1486-------------------------------------------------------------
1487%define release 1
1488-------------------------------------------------------------
1489
1490Once defined if can be accessed in a build set or package configuration file
1491with:
1492
1493-------------------------------------------------------------
1494%{release}
1495-------------------------------------------------------------
1496
1497The +sb-defaults+ command lists the defaults for your host. I will not include
1498the output of this command because of its size.
1499
1500-------------------------------------------------------------
1501$ ../source-builder/sb-defaults
1502-------------------------------------------------------------
1503
1504A nested build set is given a separate copy of the global macro maps. Changes
1505in one change set are not seen in other build sets. That same happens with
1506configuration files unless inline includes are used. Inline includes are seen
1507as part of the same build set and configuration and changes are global to that
1508build set and configuration.
1509
1510Macro Maps and Files
1511^^^^^^^^^^^^^^^^^^^^
1512
1513Macros are read in from files when the tool starts. The default settings are
1514read from the defaults macro file called `defaults.mc` located in the top level
1515RTEMS Source Builder command directory. User macros can be read in at start up
1516by using the `--macros` command line option.
1517
1518The format for a macro in macro files is:
1519
1520[options="header,compact",width="50%",cols="15%,15%,15%,55%"]
1521|=================================
1522| Name | Type | Attribute | String
1523|=================================
1524
1525where 'Name' is a case insensitive macro name, the 'Type' field is:
1526
1527[horizontal]
1528`none`:: Nothing, ignore.
1529`dir`:: A directory path.
1530`exe`:: An executable path.
1531`triplet`:: A GNU style architecture, platform, operating system string.
1532
1533the 'Attribute' field is:
1534
1535[horizontal]
1536`none`:: Nothing, ignore
1537`required`:: The host check must find the executable or path.
1538`optional`:: The host check generates a warning if not found.
1539`override`:: Only valid outside of the `global` map to indicate this macro
1540             overrides the same one in the `global` map when the map containing
1541             it is selected.
1542`undefine`:: Only valid outside of the `global` map to undefine the macro if it
1543             exists in the `global` map when the map containing it is
1544             selected. The `global` map's macro is not visible but still
1545             exists.
1546
1547and the 'String' field is a single or tripled multiline quoted string. The
1548'String' can contain references to other macros. Macro that loop are not
1549currently detected and will cause the tool to lock up.
1550
1551Maps are declared anywhere in the map using the map directive:
1552
1553-------------------------------------------------------------
1554# Comments
1555[my-special-map] <1>
1556_host:  none, override, 'abc-xyz'
1557multiline: none, override, '''First line,
1558second line,
1559and finally the last line'''
1560-------------------------------------------------------------
1561<1> The map is set to `my-special-map`.
1562
1563Any macro defintions following a map declaration are placed in that map and the
1564default map is `global` when loading a file. Maps are selected in configuration
1565files by using the `%select` directive.
1566
1567-------------------------------------------------------------
1568%select my-special-map
1569-------------------------------------------------------------
1570
1571Selecting a map means all requests for a macro first check the selected map and
1572if present return that value else the `global` map is used. Any new macros or
1573changes update only the `global` map. This may change in future releases so
1574please make sure you use the `override` attribute.
1575
1576The macro files specificed on the command line are looked for in the
1577`_configdir` paths. See <<X1,+_configdir+>> variable for details. Included
1578files need to add the `%{_configdir}` macro to the start of the file.
1579
1580Macro map files can include other macro map files using the `%include`
1581directive. The macro map to build _binutils_, _gcc_, _newlib_, _gdb_ and
1582_RTEMS_ from version control heads is:
1583
1584-------------------------------------------------------------
1585# <1>
1586# Build all tool parts from version control head.
1587#
1588%include %{_configdir}/snapshots/binutils-head.mc
1589%include %{_configdir}/snapshots/gcc-head.mc
1590%include %{_configdir}/snapshots/newlib-head.mc
1591%include %{_configdir}/snapshots/gdb-head.mc
1592-------------------------------------------------------------
1593<1> The file is `config/snapshots/binutils-gcc-newlib-gdb-head.mc`.
1594
1595The macro map defaults to `global` at the start of each included file and the
1596map setting of the macro file including the other macro files does not change.
1597
1598Personal Macros
1599^^^^^^^^^^^^^^^
1600
1601When the tools start to run they will load personal macros. Personal macros are
1602in the standard format for macros in a file. There are two places personal
1603macros can be configured. The first is the environment variable
1604`RSB_MACROS`. If present the macros from the file the environment variable
1605points to are loaded. The second is a file called `.rsb_macros` in your home
1606directory. You need to have the environment variable `HOME` defined for this
1607work.
1608
1609Report Mailing
1610~~~~~~~~~~~~~~
1611
1612The build reports can be mailed to a specific email address to logging and
1613monitoring. Mailing requires a number of parameters to function. These are:
1614
1615. To mail address
1616. From mail address
1617. SMTP host
1618
1619.To Mail Address
1620
1621The +to+ mail address is taken from the macro `%{_mail_tools_to}` and the
1622default is _rtems-tooltestresults at rtems.org_. You can override the default
1623with a personal or user macro file or via the command line option _--mail-to_.
1624
1625.From Mail Address
1626
1627The +from+ mail address is taken from:
1628
1629. GIT configuration
1630. User `.mailrc` file
1631. Command line
1632
1633If you have configured an email and name in git it will be used used. If you do
1634not a check is made for a `.mailrc` file. The environment variable _MAILRC_ is
1635used if present else your home directory is check. If found the file is scanned
1636for the `from` setting:
1637
1638  set from="Foo Bar <foo@bar>"
1639
1640You can also support a from address on the command line with the _--mail-from_
1641option.
1642
1643.SMTP Host
1644
1645The SMTP host is taken from the macro `%{_mail_smtp_host}` and the default is
1646`localhost`. You can override the default with a personal or user macro file or
1647via the command line option _--smtp-host_.
1648
1649Build Set Files
1650~~~~~~~~~~~~~~~
1651
1652Build set files lets you list the packages in the build set you are defining
1653and have a file extension of +.bset+. Build sets can define macro variables,
1654inline include other files and reference other build set or package
1655configuration files.
1656
1657Defining macros is performed with the +%define+ macro:
1658
1659-------------------------------------------------------------
1660%define _target m32r-rtems4.11
1661-------------------------------------------------------------
1662
1663Inline including another file with the +%include+ macro continues processing
1664with the specified file returning to carry on from just after the include
1665point.
1666
1667-------------------------------------------------------------
1668%include rtems-4.11-base.bset
1669-------------------------------------------------------------
1670
1671This includes the RTEMS 4.11 base set of defines and checks. The configuration
1672paths as defined by +_configdir+ are scanned. The file extension is optional.
1673
1674You reference build set or package configuration files by placing the file name
1675on a single line.
1676
1677-------------------------------------------------------------
1678tools/rtems-binutils-2.22-1
1679-------------------------------------------------------------
1680
1681The +_configdir+ path is scanned for +tools/rtems-binutils-2.22-1.bset+ or
1682+tools/rtems-binutils-2.22-1.cfg+. Build set files take precedent over package
1683configuration files. If +tools/rtems-binutils-2.22-1+ is a build set a new
1684instance of the build set processor is created and if the file is a package
1685configuration the package is built with the package builder. This all happens
1686once the build set file has finished being scanned.
1687
1688Configuration Control
1689~~~~~~~~~~~~~~~~~~~~~
1690
1691The RTEMS Souce Builder is designed to fit within most verification and
1692validation processes. All of the RTEMS Source Builder is source code. The
1693Python code is source and comes with a commercial friendly license. All
1694configuration data is text and can be read or parsed with standard text based
1695tools.
1696
1697File naming provides configuration management. A specific version of a package
1698is captured in a specific set of configuration files. The top level
1699configuration file referenced in a _build set_ or passed to the +sb-builder+
1700command relates to a specific configuration of the package being built. For
1701example the RTEMS configuration file +rtems-gcc-4.7.2-newlib-2.0.0-1.cfg+
1702creates an RTEMS GCC and Newlib package where the GCC version is 4.7.2, the
1703Newlib version is 2.0.0, plus any RTEMS specific patches that related to this
1704version. The configuration defines the version numbers of the various parts
1705that make up this package:
1706
1707-------------------------------------------------------------
1708%define gcc_version    4.7.2
1709%define newlib_version 2.0.0
1710%define mpfr_version   3.0.1
1711%define mpc_version    0.8.2
1712%define gmp_version    5.0.5
1713-------------------------------------------------------------
1714
1715The package build options, if there are any are also defined:
1716
1717-------------------------------------------------------------
1718%define with_threads 1
1719%define with_plugin  0
1720%define with_iconv   1
1721-------------------------------------------------------------
1722
1723The generic configuration may provide defaults in case options are not
1724specified. The patches this specific version of the package requires can be
1725included:
1726
1727-------------------------------------------------------------
1728Patch0: gcc-4.7.2-rtems4.11-20121026.diff
1729-------------------------------------------------------------
1730
1731Finally including the GCC 4.7 configuration script:
1732
1733-------------------------------------------------------------
1734%include %{_configdir}/gcc-4.7-1.cfg
1735-------------------------------------------------------------
1736
1737The +gcc-4.7-1.cfg+ file is a generic script to build a GCC 4.7 compiler with
1738Newlib. It is not specific to RTEMS. A bare no operating system tool set can be
1739built with this file.
1740
1741The +-1+ part of the file names is a revision. The GCC 4.7 script maybe revised
1742to fix a problem and if this fix effects an existing script the file is copied
1743and given a +-2+ revision number. Any dependent scripts referencing the earlier
1744revision number will not be effected by the change. This locks down a specific
1745configuration over time.
1746
1747Personal Configurations
1748~~~~~~~~~~~~~~~~~~~~~~~
1749
1750The RSB supports personal configurations. You can view the RTEMS support in the
1751+rtems+ directory as a private configuration tree that resides within the RSB
1752source. There is also the +bare+ set of configurations. You can create your own
1753configurations away from the RSB source tree yet use all that the RSB provides.
1754
1755To create a private configuration change to a suitable directory:
1756
1757-------------------------------------------------------------
1758$ cd ~/work
1759$ mkdir test
1760$ cd test
1761$ mkdir config
1762-------------------------------------------------------------
1763
1764and create a +config+ directory. Here you can add a new configuration or build
1765set file. The section 'Adding New Configurations' details how to add a new
1766confguration.
1767
1768New Configurations
1769~~~~~~~~~~~~~~~~~~
1770
1771This section describes how to add a new configuration to the RSB. We will add a
1772configuration to build the Device Tree Compiler. The Device Tree Compiler or
1773DTC is part of the Flattened Device Tree project and compiles Device Tree
1774Source (DTS) files into Device Tree Blobs (DTB). DTB files can be loaded by
1775operating systems and used to locate the various resources such as base
1776addresses of devices or interrupt numbers allocated to devices. The Device Tree
1777Compiler source code can be downloaded from http://www.jdl.com/software. The
1778DTC is supported in the RSB and you can find the configuration files under the
1779+bare/config+ tree. I suggest you have a brief look over these files.
1780
1781Layering by Including
1782^^^^^^^^^^^^^^^^^^^^^
1783
1784Configurations can be layered using the +%include+ directive. The user invokes
1785the outer layers which include inner layers until all the required
1786configuration is present and the package can be built. The outer layers can
1787provide high level details such as the version and the release and the inner
1788layers provide generic configuration details that do not change from one
1789release to another. Macro variables are used to provide the specific
1790configuration details.
1791
1792Configuration File Numbering
1793^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1794
1795Configuration files have a number at the end. This is a release number for that
1796configuration and it gives us the ability to track a specific configuration for
1797a specific version. For example lets say the developers of the DTC package
1798change the build system from a single makefile to autoconf and automake between
1799version 1.3.0 and version 1.4.0. The configuration file used to build the
1800package would change have to change. If we did not number the configuration
1801files the ability to build 1.1.0, 1.2.0 or 1.3.0 would be lost if we update a
1802common configuration file to build an autoconf and automake version. For
1803version 1.2.0 the same build script can be used so we can share the same
1804configuration file between version 1.1.0 and version 1.2.0. An update to any
1805previous release lets us still build the package.
1806
1807Common Configuration Scripts
1808^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1809
1810Common configuration scripts that are independent of version, platform and
1811architecture are useful to everyone. These live in the Source Builder's
1812configuration directory. Currently there are scripts to build binutils, expat,
1813DTC, GCC, GDB and libusb. These files contain the recipes to build these
1814package without the specific details of the versions or patches being
1815built. They expect to be wrapped by a configuration file that ties the package
1816to a specific version and optionally specific patches.
1817
1818DTC Example
1819^^^^^^^^^^^
1820
1821We will be building the DTC for your host rather than a package for RTEMS. We
1822will create a file called +source-builder/config/dtc-1-1.cfg+. This is a common
1823script that can be used to build a specific version using a general recipe. The
1824file name is 'dtc-1-1.cfg' where the 'cfg' extension indicates this is a
1825configuration file. The first *1* says this is for the major release 1 of the
1826package and the last *1* is the build configuration version.
1827
1828The file starts with some comments that detail the configuration. If there is
1829anything unusual about the configuration it is a good idea to add something in
1830the comments here. The comments are followed by a check for the release. In
1831this case if a release is not provided a default of 1 is used.
1832
1833-------------------------------------------------------------
1834#
1835# DTC 1.x.x Version 1.
1836#
1837# This configuration file configure's, make's and install's DTC.
1838#
1839
1840%if %{release} == %{nil}
1841%define release 1
1842%endif
1843-------------------------------------------------------------
1844
1845The next section defines some information about the package. It does not effect
1846the build and is used to annotate the reports. It is recommended this
1847information is kept updated and accurate.
1848
1849-------------------------------------------------------------
1850Name:      dtc-%{dtc_version}-%{_host}-%{release}
1851Summary:   Device Tree Compiler v%{dtc_version} for target %{_target} on host %{_host}
1852Version:   %{dtc_version}
1853Release:   %{release}
1854URL:       http://www.jdl.com/software/
1855BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
1856-------------------------------------------------------------
1857
1858The next section defines the source and any patches. In this case there is a
1859single source package and it can be downloaded using the HTTP protocol. The RSB
1860knows this is GZip'ped tar file. If more than one package package is needed add
1861them increasing the index. The +gcc-4.8-1.cfg+ configuration contains examples
1862of more than one source package as well as conditionally including source
1863packages based on the outer configuration options.
1864
1865-------------------------------------------------------------
1866#
1867# Source
1868#
1869%source set dtc http://www.jdl.com/software/dtc-v%{dtc_version}.tgz
1870-------------------------------------------------------------
1871
1872The remainder of the script is broken in to the various phases of a build. They
1873are:
1874
1875. Preperation
1876. Bulding
1877. Installing, and
1878. Cleaning
1879
1880Preparation is the unpacking of the source, applying any patches as well as any
1881package specific set ups. This part of the script is a standard Unix shell
1882script. Be careful with the use of '%' and '$'. The RSB uses '%' while the
1883shell scripts use '$'.
1884
1885A standard pattern you will observe is the saving of the build's top
1886directory. This is used instead of changing into a subdirectory and then
1887changing to the parent when finished. Some hosts will change in a subdirectory
1888that is a link however changing to the parent does not change back to the
1889parent of the link rather it changes to the parent of the target of the link
1890and that is something the RSB nor you can track easily. The RSB configuration
1891script's are a collection of various subtle issues so please ask if you are
1892unsure why something is being done a particular way.
1893
1894The preparation phase will often include source and patch setup commands. Outer
1895layers can set the source package and add patches as needed while being able to
1896use a common recipe for the build. Users can override the standard build and
1897supply a custom patch for testing using the user macro command line interface.
1898
1899-------------------------------------------------------------
1900#
1901# Prepare the source code.
1902#
1903%prep
1904  build_top=$(pwd)
1905
1906  %source setup dtc -q -n dtc-v%{dtc_version}
1907  %patch setup dtc -p1
1908
1909  cd ${build_top}
1910-------------------------------------------------------------
1911
1912The configuration file 'gcc-common-1.cfg' is a complex example of source
1913preparation. It contains a number of source packages and patches and it
1914combines these into a single source tree for building. It uses links to map
1915source into the GCC source tree so GCC can be built using the _single source
1916tree_ method. It also shows how to fetch source code from version
1917control. Newlib is taken directly from its CVS repository.
1918
1919Next is the building phase and for the DTC example this is simply a matter of
1920running +make+. Note the use of the RSB macros for commands. In the case of
1921'%{\__make}' it maps to the correct make for your host. In the case of BSD
1922systems we need to use the GNU make and not the GNU make.
1923
1924If your package requires a configuration stage you need to run this before the
1925make stage. Again the GCC common configuration file provides a detailed example.
1926
1927-------------------------------------------------------------
1928%build
1929  build_top=$(pwd)
1930
1931  cd dtc-v%{dtc_version}
1932
1933  %{build_build_flags}
1934
1935  %{__make} PREFIX=%{_prefix}
1936
1937  cd ${build_top}
1938-------------------------------------------------------------
1939
1940You can invoke make with the macro '%{?_smp_flags}' as a command line
1941argument. This macro is controlled by the '--jobs' command line option and the
1942host CPU detection support in the RSB. If you are on a multicore host you can
1943increase the build speed using this macro. It also lets you disabled building on
1944multicores to aid debugging when testing.
1945
1946Next is the install phase. This phase is a little more complex because you may
1947be building a tar file and the end result of the build is never actually
1948installed into the prefix on the build host and you may not even have
1949permissions to perform a real install. Most packages install to the +prefix+
1950and the prefix is typically supplied via the command to the RSB or the
1951package's default is used. The default can vary depending on the host's
1952operating system. To install to a path that is not the prefix the +DESTDIR+
1953make variable is used. Most packages should honour the +DISTDIR+ make variables
1954and you can typically specify it on the command line to make when invoking the
1955install target. This results in the package being installed to a location that
1956is not the prefix but one you can control. The RSB provides a shell variable
1957called +SB_BUILD_ROOT+ you can use. In a build set where you are building a
1958number of packages you can collect all the built packages in a single tree that
1959is captured in the tar file.
1960
1961Also note the use of the macro +%{\__rmdir}+. The use of these macros allow the
1962RSB to vary specific commands based on the host. This can help on hosts like
1963Windows where bugs can effect the standard commands such as 'rm'. There are
1964many many macros to help you. You can find these listed in the +defaults.mc+
1965file and in the trace output. If you are new to creating and editing
1966configurations learning these can take a little time.
1967
1968-------------------------------------------------------------
1969%install
1970  build_top=$(pwd)
1971
1972  %{__rmdir} -rf $SB_BUILD_ROOT
1973
1974  cd dtc-v%{dtc_version}
1975  %{__make} DESTDIR=$SB_BUILD_ROOT PREFIX=%{_prefix} install
1976
1977  cd ${build_top}
1978-------------------------------------------------------------
1979
1980Finally there is an optional clean section. The RSB will run this section if
1981+--no-clean+ has not been provided on the command line. The RSB does clean up
1982for you.
1983
1984Once we have the configuration files we can execute the build using the
1985`sb-builder` command. The command will perform the build and create a tar file
1986in the +tar+ directory.
1987
1988-------------------------------------------------------------
1989$  ../source-builder/sb-builder --prefix=/usr/local \
1990     --log=log_dtc devel/dtc-1.2.0
1991RTEMS Source Builder, Package Builder v0.2.0
1992config: devel/dtc-1.2.0
1993package: dtc-1.2.0-x86_64-freebsd9.1-1
1994download: http://www.jdl.com/software/dtc-v1.2.0.tgz -> sources/dtc-v1.2.0.tgz
1995building: dtc-1.2.0-x86_64-freebsd9.1-1
1996$ ls tar
1997dtc-1.2.0-x86_64-freebsd9.1-1.tar.bz2
1998-------------------------------------------------------------
1999
2000If you want to have the package installed automatically you need to create a
2001build set. A build set can build one or more packages from their configurations
2002at once to create a single package. For example the GNU tools is typically seen
2003as binutils, GCC and GDB and a build set will build each of these packages and
2004create a single build set tar file or install the tools on the host into the
2005prefix path.
2006
2007The DTC build set file is called +dtc.bset+ and contains:
2008
2009-------------------------------------------------------------
2010#
2011# Build the DTC.
2012#
2013
2014%define release 1
2015
2016devel/dtc-1.2.0.cfg
2017-------------------------------------------------------------
2018
2019To build this you can use something similar to:
2020
2021-------------------------------------------------------------
2022$ ../source-builder/sb-set-builder --prefix=/usr/local --log=log_dtc \
2023   --trace --bset-tar-file --no-install dtc
2024RTEMS Source Builder - Set Builder, v0.2.0
2025Build Set: dtc
2026config: devel/dtc-1.2.0.cfg
2027package: dtc-1.2.0-x86_64-freebsd9.1-1
2028building: dtc-1.2.0-x86_64-freebsd9.1-1
2029tarball: tar/x86_64-freebsd9.1-dtc-set.tar.bz2
2030cleaning: dtc-1.2.0-x86_64-freebsd9.1-1
2031Build Set: Time 0:00:02.865758
2032$ ls tar
2033dtc-1.2.0-x86_64-freebsd9.1-1.tar.bz2   x86_64-freebsd9.1-dtc-set.tar.bz2
2034-------------------------------------------------------------
2035
2036The build is for a FreeBSD host and the prefix is for user installed
2037packages. In this example I cannot let the source builder perform the install
2038because I never run the RSB with root priviledges so a build set or bset tar
2039file is created. This can then be installed using root privildges.
2040
2041The command also supplies the --trace option. The output in the log file will
2042contian all the macros.
2043
2044Debugging
2045^^^^^^^^^
2046
2047New configuration files require debugging. There are two types of
2048debugging. The first is debugging RSB script bugs. The +--dry-run+ option is
2049used here. Suppling this option will result in most of the RSB processing to be
2050performed and suitable output placed in the log file. This with the +--trace+
2051option should help you resolve any issues.
2052
2053The second type of bug to fix are related to the execution of one of
2054phases. These are usually a mix of shell script bugs or package set up or
2055configuration bugs. Here you can use any normal shell script type debug
2056technique such as +set -x+ to output the commands or +echo+
2057statements. Debugging package related issues may require you start a build with
2058teh RSB and supply +--no-clean+ option and then locate the build directories
2059and change directory into them and manually run commands until to figure what
2060the package requires.
2061
2062Snapshot Testing
2063~~~~~~~~~~~~~~~~
2064
2065_This section needs to be updated once I sort out snapshot testing._
2066
2067Testing of release canidates and snapshots is important to those helping
2068maintain tool sets. The RTEMS Source Builder helps by providing a simple and
2069flexible way to use existing build sets and configuration without needing to
2070change them or creating new temporary build sets and configurations.
2071
2072The process uses snapshot macro files loaded via the command line option
2073`--macros`. These files provide macros that override the standard build set and
2074configuration file macros.
2075
2076Lets consider testing a GCC 4.7 snapshot for RTEMS 4.11. Lets assume the
2077current RTEMS 4.11 tools reference GCC 4.7.3 with a patch as the stable tool
2078set. We want to use a recent snapshot with no patches. In the
2079`rtems/config/snapshots` directoy create a file called `gcc-4.7-snapshot.mc`
2080containing:
2081
2082-------------------------------------------------------------
2083[gcc-4.7-snapshot]
2084GCC_Version: none, override, '4.7-20130413'
2085Source:     none, override, 'http://mirrors.kernel.org/sources.redhat.com/gcc/
2086snapshots/%{gcc_version}/gcc-%{gcc_version}.tar.bz2'
2087Patch0:      none, udefine,  ''
2088-------------------------------------------------------------
2089
2090In the standard configuration file `source-builder/config/gcc-4.7-1.cfg` the
2091map is selected with:
2092
2093-------------------------------------------------------------
2094#
2095# Select the GCC 4.7 Snapshot Macro Map
2096#
2097%select gcc-4.7-snapshot
2098-------------------------------------------------------------
2099
2100On the command line add `--macros=snapshots/gcc-4.7-snapshot.mc` and this
2101snapshot will be built. With careful use of the `--prefix` option you can
2102locate the tools in a specific directory and test them without needing to
2103effect your production environment.
2104
2105Scripting
2106~~~~~~~~~
2107
2108Configuration files specify how to build a package. Configuration files are
2109scripts and have a +.cfg+ file extension. The script format is based loosely on
2110the RPM spec file format however the use and purpose in this tool does not
2111compare with the functionality and therefore the important features of the spec
2112format RPM needs and uses.
2113
2114The script language is implemented in terms of macros. The built-in list is:
2115
2116[horizontal]
2117+%{}+:: Macro expansion with conditional logic.
2118+%()+:: Shell expansion.
2119+%prep+:: The source preparation shell commands.
2120+%build+:: The build shell commands.
2121+%install+:: The package install shell commands.
2122+%clean+:: The package clean shell commands.
2123+%include+:: Inline include another configuration file.
2124+%name+:: The name of the package.
2125+%summary+:: A brief package description. Useful when reporting about a build.
2126+%release+:: The package release. A number that is the release as built by this tool.
2127+%version+:: The package's version string.
2128+%buildarch+:: The build architecture.
2129+%source+:: Define a source code package. This macro has a number appended.
2130+%patch+:: Define a patch. This macro has a is number appended.
2131+%hash+:: Define a checksum for a source or patch file.
2132+%echo+:: Print the following string as a message.
2133+%warning+:: Print the following string as a warning and continue.
2134+%error+:: Print the following string as an error and exit.
2135+%select+:: Select the macro map. If there is no map nothing is reported.
2136+%define+:: Define a macro. Macros cannot be redefined, you must first undefine it.
2137+%undefine+:: Undefine a macro.
2138+%if+:: Start a conditional logic block that ends with a +%endif+.
2139+%ifn+:: Inverted start of a conditional logic block.
2140+%ifarch+:: Test the architecture against the following string.
2141+%ifnarch+:: Inverted test of the architecture
2142+%ifos+:: Test the host operating system.
2143+%else+:: Start the _else_ conditional logic block.
2144+%endfi+:: End the conditional logic block.
2145+%bconf_with+:: Test the build condition _with_ setting. This is the +--with-*+
2146command line option.
2147+%bconf_without+:: Test the build condition _without_ setting. This is the
2148+--without-*+ command line option.
2149
2150Expanding
2151^^^^^^^^^
2152
2153A macro can be `%{string}` or the equivalent of `%string`. The following macro
2154expansions supported are:
2155
2156`%{string}`;;
2157Expand the 'string' replacing the entire macro text with the text in the table
2158for the entry 'string . For example if 'var' is 'foo' then `${var}` would
2159become `foo`.
2160
2161`%{expand: string}`;;
2162Expand the 'string' and then use it as a ``string'' to the macro expanding the
2163macro. For example if _foo_ is set to 'bar' and 'bar' is set to 'foobar' then
2164`%{expand:foo}` would result in `foobar`. Shell expansion can also be used.
2165
2166`%{with string}`;;
2167Expand the macro to '1' if the macro `with_`'string' is defined else expand to
2168_0_. Macros with the name `with_`'string' can be define with command line
2169arguments to the RTEMS Source Builder commands.
2170
2171`%{defined string}`;;
2172Expand the macro to '1' if a macro of name 'string' is defined else expand to '0'.
2173
2174`%{?string: expression}`;;
2175Expand the macro to 'expression' if a macro of name 'string' is defined else expand to `%{nil}`.
2176
2177`%{!?string: expression}`;;
2178Expand the macro to 'expression' if a macro of name 'string' is not defined. If
2179the macro is define expand to `%{nil}`.
2180
2181`%(expression)`;;
2182Expand the macro to the result of running the 'expression' in a host shell. It
2183is assumed this is a Unix type shell. For example `%(whoami)` will return your
2184user name and `%(date)` will return the current date string.
2185
2186%prep
2187^^^^^
2188
2189The +%prep+ macro starts a block that continues until the next block macro. The
2190_prep_ or preparation block defines the setup of the package's source and is a
2191mix of RTEMS Source Builder macros and shell scripting. The sequence is
2192typically +%source+ macros for source, +%patch+ macros to patch the source
2193mixed with some shell commands to correct any source issues.
2194
2195-------------------------------------------------------------
2196              <1>                <2>      <3>
2197%source setup gcc -q -c -T -n %{name}-%{version}
2198-------------------------------------------------------------
2199
2200<1> The source group to set up.
2201<2> The source's name.
2202<3> The version of the source.
2203
2204The source set up are declared with the source +set+ and +add+ commands. For
2205example:
2206
2207-------------------------------------------------------------
2208%source set gdb http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2
2209-------------------------------------------------------------
2210
2211This URL is the primary location of the GNU GDB source code and the RTEMS
2212Source Builder can download the file from this location and by inspecting the
2213file extension use +bzip2+ decompression with +tar+. When the +%prep+ section
2214is processed a check of the local +source+ directory is made to see if the file
2215has already been downloaded. If not found in the source cache directory the
2216package is downloaded from the URL. You can append other base URLs via the
2217command line option +--url+. This option accepts a comma delimited list of
2218sites to try.
2219
2220You could optionally have a few source files that make up the package. For
2221example GNU's GCC was a few tar files for a while and it is now a single tar
2222file. Support for multiple source files can be conditionally implemented with
2223the following scripting:
2224
2225-------------------------------------------------------------
2226%source set gcc ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-code-%{gcc_version}.tar.bz2
2227%source add gcc ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-g++-%{gcc_version}.tar.bz2
2228%source setup gcc -q -T -D -n gcc-%{gcc_version}
2229-------------------------------------------------------------
2230
2231Separate modules use separate source groups. The GNU GCC compiler for RTEMS
2232uses Newlib, MPFR, MPC, and GMP source packages. You define the source with:
2233
2234-------------------------------------------------------------
2235%source set gcc ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
2236%source set newlib ftp://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
2237%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
2238%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
2239%source set gmp ftp://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
2240-------------------------------------------------------------
2241
2242and set up with:
2243
2244-------------------------------------------------------------
2245%source setup gcc -q -n gcc-%{gcc_version}
2246%source setup newlib -q -D -n newlib-%{newlib_version}
2247%source setup mpfr -q -D -n mpfr-%{mpfr_version}
2248%source setup mpc -q -D -n mpc-%{mpc_version}
2249%source setup gmp -q -D -n gmp-%{gmp_version}
2250-------------------------------------------------------------
2251
2252Patching also occurs during the preparation stage. Patches are handled in a
2253similar way to the source packages except you only +add+ patches. Patches are
2254applied using the +setup+ command. The +setup+ command takes the default patch
2255option. You can provide options with each patch by adding them as arguments
2256before the patch URL. Patches with no options uses the +setup+ default.
2257
2258-------------------------------------------------------------
2259%patch add gdb %{rtems_gdb_patches}/gdb-sim-arange-inline.diff
2260%patch add gdb -p0 <1> %{rtems_gdb_patches}/gdb-sim-cgen-inline.diff
2261-------------------------------------------------------------
2262<1> This patch has a custom option.
2263
2264To apply these patches:
2265
2266-------------------------------------------------------------
2267%patch setup gdb -p1 <1>
2268-------------------------------------------------------------
2269<1> The default options.
2270
2271%build
2272^^^^^^
2273
2274The +%build+ macro starts a block that continues until the next block
2275macro. The build block is a series of shell commands that execute to build the
2276package. It assumes all source code has been unpacked, patch and adjusted so
2277the build will succeed.
2278
2279The following is an example take from the GutHub STLink project:
2280
2281NOTE: STLink is a JTAG debugging device for the ST ARM family of processors.
2282
2283-------------------------------------------------------------
2284%build
2285  export PATH="%{_bindir}:${PATH}" <1>
2286
2287  cd texane-stlink-%{stlink_version} <2>
2288
2289  ./autogen.sh <3>
2290
2291%if "%{_build}" != "%{_host}"
2292  CFLAGS_FOR_BUILD="-g -O2 -Wall" \ <4>
2293%endif
2294  CPPFLAGS="-I $SB_TMPPREFIX/include/libusb-1.0" \ <5>
2295  CFLAGS="$SB_OPT_FLAGS" \
2296  LDFLAGS="-L $SB_TMPPREFIX/lib" \
2297  ./configure \ <6>
2298    --build=%{_build} --host=%{_host} \
2299    --verbose \
2300    --prefix=%{_prefix} --bindir=%{_bindir} \
2301    --exec-prefix=%{_exec_prefix} \
2302    --includedir=%{_includedir} --libdir=%{_libdir} \
2303    --mandir=%{_mandir} --infodir=%{_infodir}
2304
2305  %{__make} %{?_smp_mflags} all <7>
2306
2307  cd ..
2308-------------------------------------------------------------
2309
2310<1> Setup the PATH environment variable. This is not always needed.
2311<2> This package builds in the source tree so enter it.
2312<3> The package is actually checked directly out from the github project and so
2313    it needs its autoconf and automake files generated.
2314<4> Flags for a cross-compiled build.
2315<5> Various settings passed to configure to customise the build. In this
2316    example an include path is being set to the install point of _libusb_. This
2317    package requires _libusb_ is built before it.
2318<6> The +configure+ command. The RTEMS Source Builder provides all the needed
2319    paths as macro variables. You just need to provide them to +configure+.
2320<7> Running make. Do not use +make+ directly, use the RTEMS Source Builder's
2321    defined value. This value is specific to the host. A large number of
2322    packages need GNU make and on BSD systems this is +gmake+. You can
2323    optionally add the SMP flags if the packages build system can handle
2324    parallel building with multiple jobs. The +_smp_mflags+ value is
2325    automatically setup for SMP hosts to match the number of cores the host has.
2326
2327%install
2328^^^^^^^^
2329
2330The +%install+ macro starts a block that continues until the next block
2331macro. The install block is a series of shell commands that execute to install
2332the package. You can assume the package has build correctly when this block
2333starts executing.
2334
2335Never install the package to the actual _prefix_ the package was built
2336with. Always install to the RTEMS Source Builder's temporary path defined in
2337the macro variable +\__tmpdir+. The RTEMS Source Builder sets up a shell
2338environment variable called +SB_BUILD_ROOT+ as the standard install point. Most
2339packages support adding +DESTDIR=+ to the _make install_ command.
2340
2341Looking at the same example as in <<_build, %build>>:
2342
2343-------------------------------------------------------------
2344%install
2345  export PATH="%{_bindir}:${PATH}" <1>
2346  rm -rf $SB_BUILD_ROOT <2>
2347
2348  cd texane-stlink-%{stlink_version} <3>
2349  %{__make} DESTDIR=$SB_BUILD_ROOT install <4>
2350
2351  cd ..
2352-------------------------------------------------------------
2353
2354<1> Setup the PATH environment variable. This is not always needed.
2355<2> Clean any installed files. This make sure the install is just what
2356    the package installs and not any left over files from a broken build or
2357    install.
2358<3> Enter the build directory. In this example it just happens to be the source
2359    directory.
2360<4> Run +make install+ to install the package overriding the +DESTDIR+ make
2361    variable.
2362
2363%clean
2364^^^^^^
2365
2366The +%clean+ macro starts a block that continues until the next block
2367macro. The clean block is a series of shell commands that execute to clean up
2368after a package has been built and install. This macro is currenly not been
2369used because the RTEMS Source Builder automatically cleans up.
2370
2371%include
2372^^^^^^^^
2373
2374The +%include+ macro inline includes the specific file. The +\__confdir+
2375path is searched. Any relative path component of the include file is appended
2376to each part of the +\__configdir+. Adding an extension is optional as files
2377with +.bset+ and +.cfg+ are automatically searched for.
2378
2379Inline including means the file is processed as part of the configuration at
2380the point it is included. Parsing continues from the next line in the
2381configuration file that contains the +%include+ macro.
2382
2383Including files allow a kind of configuration file reuse. The outer
2384configuration files provide specific information such as package version
2385numbers and patches and then include a generic configuration script which
2386builds the package.
2387
2388-------------------------------------------------------------
2389%include %{_configdir}/gcc-4.7-1.cfg
2390-------------------------------------------------------------
2391
2392%name
2393^^^^^
2394
2395The name of the package being built. The name typically contains the components
2396of the package and their version number plus a revision number. For the GCC
2397with Newlib configuration the name is typically:
2398
2399-------------------------------------------------------------
2400Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
2401-------------------------------------------------------------
2402
2403%summary
2404^^^^^^^^
2405
2406The +%summary+ is a brief description of the package. It is useful when
2407reporting. This information is not capture in the package anywhere. For the GCC
2408with Newlib configuration the summary is typically:
2409
2410-------------------------------------------------------------
2411Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
2412-------------------------------------------------------------
2413
2414%release
2415^^^^^^^^
2416
2417The +%release+ is packaging number that allows revisions of a package to happen
2418where none package versions change. This value typically increases when the
2419configuration building the package changes.
2420
2421-------------------------------------------------------------
2422%define release 1
2423-------------------------------------------------------------
2424
2425%version
2426^^^^^^^^
2427
2428The +%version% macro sets the version the package. If the package is a single
2429component it tracks that component's version number. For example in the
2430_libusb_ configuration the +%version+ is the same as +%libusb_version+, however
2431in a GCC with Newlib configuration there is no single version number. In this
2432case the GCC version is used.
2433
2434-------------------------------------------------------------
2435Version: %{gcc_version}
2436-------------------------------------------------------------
2437
2438%buildarch
2439^^^^^^^^^^
2440
2441The +%buildarch+ macro is set to the architecture the package contains. This is
2442currently not used in the RTEMS Source Builder and may go away. This macro is
2443more important in a real packaging system where the package could end up on the
2444wrong architecture.
2445
2446%source
2447^^^^^^^
2448
2449The +%source+ macro has 3 commands that controls what it does. You can +set+
2450the source files, +add+ source files to a source group, and +setup+ the source
2451file group getting it ready to be used.
2452
2453Source files are source code files in tar or zip files that are unpacked,
2454copied or symbolically linked into the package's build tree. Building a package
2455requires one or more dependent packages. These are typically the packages
2456source code plus dependent libraries or modules. You can create any number of
2457these source groups and set each of them up with a separe source group for each
2458needed library or module. Each source group normally has a single tar, zip or
2459repository and the +set+ defines this. Some projects split the source code into
2460separate tar or zip files and you install them by using the +add+ command.
2461
2462The first instance of a +set+ command creates the source group and sets the
2463source files to be set up. Subsequence +set+ commands for the same source group
2464are ignored. this lets you define the standard source files and override them
2465for specific releases or snapshots.. To set a source file group:
2466
2467-------------------------------------------------------------
2468%source set gcc <1> ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
2469-------------------------------------------------------------
2470<1> The source group is +gcc+.
2471
2472To add another source package to be installed into the same source tree you use
2473the +add+ command:
2474
2475-------------------------------------------------------------
2476%source add gcc ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/g++-%{gcc_version}.tar.bz2
2477-------------------------------------------------------------
2478
2479The source +setup+ command can only be issued in the +%prep:+ section. The
2480setup is:
2481
2482-------------------------------------------------------------
2483%source gcc setup -q -T -D -n %{name}-%{version}
2484-------------------------------------------------------------
2485
2486Accepted options are:
2487
2488[horizontal]
2489*Switch*:: *Description*
2490+-n+:: The -n option is used to set the name of the software's build
2491directory. This is necessary only when the source archive unpacks into a
2492directory named other than +<name>-<version>+.
2493+-c+:: The -c option is used to direct %setup to create the top-level build
2494directory before unpacking the sources.
2495+-D+:: The -D option is used to direct %setup to not delete the build directory
2496prior to unpacking the sources. This option is used when more than one source
2497archive is to be unpacked into the build directory, normally with the +-b+ or
2498+-a+ options.
2499+-T+:: The -T option is used to direct %setup to not perform the default
2500unpacking of the source archive specified by the first Source: macro. It is used
2501with the +-a+ or +-b+ options.
2502+-b <n>+:: The -b option is used to direct %setup to unpack the source archive
2503specified on the nth Source: macro line before changing directory into the build
2504directory.
2505
2506%patch
2507^^^^^^
2508
2509The +%patch+ macro has the same 3 command as the +%source+ command however the
2510+set+ commands is not really that useful with the with command. You add patches
2511with the +add+ command and +setup+ applies the patches. Patch options can be
2512added to each patch by placing them before the patch URL. If no patch option is
2513provided the default options passed to the +setup+ command are used. An option
2514starts with a '-'. The +setup+ command must reside inside the +%prep+ section.
2515
2516Patches are grouped in a similar way to the +%source+ macro so you can control
2517applying a group of patches to a specific source tree.
2518
2519The +__patchdir+ path is search.
2520
2521To add a patch:
2522
2523-------------------------------------------------------------
2524%patch add gcc <1>  gcc-4.7.2-rtems4.11-20121026.diff
2525%patch add gcc -p0 <2>  gcc-4.7.2-rtems4.11-20121101.diff
2526-------------------------------------------------------------
2527<1> The patch group is +gcc+.
2528<2> Option for this specific patch.
2529
2530Placing +%patch setup+ in the +%prep+ section will apply the groups patches.
2531
2532-------------------------------------------------------------
2533%patch setup gcc <1>  -p1 <2>
2534-------------------------------------------------------------
2535<1> The patch group.
2536<2> The default option used to apply the patch.
2537
2538%hash
2539^^^^^
2540
2541The +%hash+ macro requires 3 arguments and defines a checksum for a specific
2542file. The checksum is not applied until the file is checked before downloading
2543and once downloaded. A patch or source file that does not has a hash defined
2544generates a warning.
2545
2546A file to be checksum must be unqiue in the any of the source and patch
2547directories. The basename of the file is used as the key for the hash.
2548
2549The hash algorthim can be 'md5', 'sha1', 'sha224', 'sha256', 'sha384', and
2550'sha512' and we typically use 'md5'.
2551
2552To add a hash:
2553
2554-------------------------------------------------------------
2555%hash md5 <1> net-snmp-%{net_snmp_version}.tar.gz <2> 7db683faba037249837b226f64d566d4 <3>
2556-------------------------------------------------------------
2557<1> The type of checksum.
2558<2> The file to checksum. It can contain macros that are expanded for you.
2559<3> The MD5 hash for the Net-SNMP file +net-snmp-5.7.2.1.tar.gz+.
2560
2561Do not include a path with the file name. Only the basename is required. Files
2562can be searched for from a number of places and having a path conponent would
2563create confusion. This does mean files with hashes must be unique.
2564
2565Downloading of repositories such as git and cvs cannot be checksumed. It is
2566assumed those protocols and tools manage the state of the files.
2567
2568%echo
2569^^^^^
2570
2571The +%echo+ macro outputs the following string to stdout. This can also be used
2572as `%{echo: message}`.
2573
2574%warning
2575^^^^^^^^
2576
2577The +%warning+ macro outputs the following string as a warning. This can also
2578be used as `%{warning: message}`.
2579
2580%error
2581^^^^^^
2582
2583The +%error+ macro outputs the follow string as an error and exits the RTEMS
2584Source Builder. This can also be used as `%{error: message}`.
2585
2586%select
2587^^^^^^^
2588
2589The +%select+ macro selects the map specified. If there is no map no error or
2590warning is generated. Macro maps provide a simple way for a user to override
2591the settings is a configuration file without having to edit it. The changes are
2592recorded in the build report so can be traced.
2593
2594Configuration use different maps so macro overrides can target a specific
2595package.
2596
2597The default map is `global'.
2598
2599-------------------------------------------------------------
2600%select gcc-4.8-snapshot <1>
2601%define one_plus_one 2 <2>
2602-------------------------------------------------------------
2603
2604<1> The map switches to `gcc-4.8-snapshot`. Any overrides in this map will be
2605    used.
2606<2> Defining macros only updates the `global` map and not the selected map.
2607
2608%define
2609^^^^^^^
2610
2611The +%define+ macro defines a new macro or updates an existing one. If no value
2612is given it is assumed to be 1.
2613
2614-------------------------------------------------------------
2615%define foo bar
2616%define one_plus_one 2
2617%define one <1>
2618-------------------------------------------------------------
2619
2620<1> The macro _one_ is set to 1.
2621
2622%undefine
2623^^^^^^^^^
2624
2625The +%undefine+ macro removes a macro if it exists. Any further references to
2626it will result in an undefine macro error.
2627
2628%if
2629^^^
2630
2631The +%if+ macro starts a conditional logic block that can optionally have a
2632_else_ section. A test follows this macro and can have the following operators:
2633
2634[horizontal]
2635*Operator*:: *Description*
2636+%{}+:: Check the macro is set or _true_, ie non-zero.
2637+
2638-------------------------------------------------------------
2639%if ${foo}
2640 %warning The test passes, must not be empty or is non-zero
2641%else
2642 %error The test fails, must be empty or zero
2643%endif
2644-------------------------------------------------------------
2645+!+:: The _not_ operator inverts the test of the macro.
2646+
2647-------------------------------------------------------------
2648%if ! ${foo}
2649 %warning The test passes, must be empty or zero
2650%else
2651 %error The test fails, must not be empty or is non-zero
2652%endif
2653-------------------------------------------------------------
2654+==+:: The left hand size must equal the right hand side. For example:
2655+
2656-------------------------------------------------------------
2657%define one 1
2658%if ${one} == 1
2659 %warning The test passes
2660%else
2661 %error The test fails
2662%endif
2663-------------------------------------------------------------
2664+
2665You can also check to see if a macro is empty:
2666+
2667-------------------------------------------------------------
2668%if ${nothing} == %{nil}
2669 %warning The test passes
2670%else
2671 %error The test fails
2672%endif
2673-------------------------------------------------------------
2674+!=+:: The left hand size does not equal the right hand side. For example:
2675+
2676-------------------------------------------------------------
2677%define one 1
2678%if ${one} != 2
2679 %warning The test passes
2680%else
2681 %error The test fails
2682%endif
2683-------------------------------------------------------------
2684+
2685You can also check to see if something is set:
2686+
2687-------------------------------------------------------------
2688%if ${something} != %{nil}
2689 %warning The test passes
2690%else
2691 %error The test fails
2692%endif
2693-------------------------------------------------------------
2694+>+:: The left hand side is numerically greater than the right hand side.
2695+>=+:: The left hand side is numerically greater than or equal to the right
2696hand side.
2697+<+:: The left hand side is numerically less than the right hand side.
2698+\<=+:: The left hand side is numerically less than or equal to the right hand
2699side.
2700
2701%ifn
2702^^^^
2703
2704The +%ifn+ macro inverts the normal +%if+ logic. It avoids needing to provide
2705empty _if_ blocks followed by _else_ blocks. It is useful when checking if a
2706macro is defined:
2707
2708-------------------------------------------------------------
2709%ifn %{defined foo}
2710 %define foo bar
2711%endif
2712-------------------------------------------------------------
2713
2714%ifarch
2715^^^^^^^
2716
2717The +%ifarch+ is a short cut for "+%if %{\_arch} == i386+". Currently not used.
2718
2719%ifnarch
2720^^^^^^^^
2721
2722The +%ifnarch+ is a short cut for "+%if %{\_arch} != i386+". Currently not
2723used.
2724
2725%ifos
2726^^^^^
2727
2728The +%ifos+ is a short cut for "+%if %{\_os} != mingw32+". It allows
2729conditional support for various operating system differences when building
2730packages.
2731
2732%else
2733^^^^^
2734
2735The +%else+ macro starts the conditional _else_ block.
2736
2737%endfi
2738^^^^^^
2739
2740The +%endif+ macro ends a conditional logic block.
2741
2742%bconf_with
2743^^^^^^^^^^^
2744
2745The +%bconf_with+ macro provides a way to test if the user has passed a
2746specific option on the command line with the +--with-<label>+ option. This
2747option is only available with the +sb-builder+ command.
2748
2749%bconf_without
2750^^^^^^^^^^^^^^
2751
2752The +%bconf_without+ macro provides a way to test if the user has passed a
2753specific option on the command line with the +--without-<label>+ option. This
2754option is only available with the +sb-builder+ command.
2755
2756Commands
2757--------
2758
2759Checker (sb-check)
2760~~~~~~~~~~~~~~~~~~
2761
2762This commands checks your system is set up correctly. Most options are ignored.
2763
2764-------------------------------------------------------------
2765$ ../source-builder/sb-check --help
2766sb-check: [options] [args]
2767RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
2768Options and arguments:
2769--force                : Force the build to proceed
2770--quiet                : Quiet output (not used)
2771--trace                : Trace the execution
2772--dry-run              : Do everything but actually run the build
2773--warn-all             : Generate warnings
2774--no-clean             : Do not clean up the build tree
2775--always-clean         : Always clean the build tree, even with an error
2776--jobs                 : Run with specified number of jobs, default: num CPUs.
2777--host                 : Set the host triplet
2778--build                : Set the build triplet
2779--target               : Set the target triplet
2780--prefix path          : Tools build prefix, ie where they are installed
2781--topdir path          : Top of the build tree, default is $PWD
2782--configdir path       : Path to the configuration directory, default: ./config
2783--builddir path        : Path to the build directory, default: ./build
2784--sourcedir path       : Path to the source directory, default: ./source
2785--tmppath path         : Path to the temp directory, default: ./tmp
2786--macros file[,[file]  : Macro format files to load after the defaults
2787--log file             : Log file where all build out is written too
2788--url url[,url]        : URL to look for source
2789--no-download          : Disable the source downloader
2790--targetcflags flags   : List of C flags for the target code
2791--targetcxxflags flags : List of C++ flags for the target code
2792--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
2793--with-<label>         : Add the --with-<label> to the build
2794--without-<label>      : Add the --without-<label> to the build
2795--regression           : Set --no-install, --keep-going and --always-clean
2796$ ../source-builder/sb-check
2797RTEMS Source Builder - Check, v0.2.0
2798Environment is ok
2799-------------------------------------------------------------
2800
2801Defaults (sb-defaults)
2802~~~~~~~~~~~~~~~~~~~~~~
2803
2804This commands outputs and the default macros for your when given no
2805arguments. Most options are ignored.
2806
2807-------------------------------------------------------------
2808$ ../source-builder/sb-defaults --help
2809sb-defaults: [options] [args]
2810RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
2811Options and arguments:
2812--force                : Force the build to proceed
2813--quiet                : Quiet output (not used)
2814--trace                : Trace the execution
2815--dry-run              : Do everything but actually run the build
2816--warn-all             : Generate warnings
2817--no-clean             : Do not clean up the build tree
2818--always-clean         : Always clean the build tree, even with an error
2819--jobs                 : Run with specified number of jobs, default: num CPUs.
2820--host                 : Set the host triplet
2821--build                : Set the build triplet
2822--target               : Set the target triplet
2823--prefix path          : Tools build prefix, ie where they are installed
2824--topdir path          : Top of the build tree, default is $PWD
2825--configdir path       : Path to the configuration directory, default: ./config
2826--builddir path        : Path to the build directory, default: ./build
2827--sourcedir path       : Path to the source directory, default: ./source
2828--tmppath path         : Path to the temp directory, default: ./tmp
2829--macros file[,[file]  : Macro format files to load after the defaults
2830--log file             : Log file where all build out is written too
2831--url url[,url]        : URL to look for source
2832--no-download          : Disable the source downloader
2833--targetcflags flags   : List of C flags for the target code
2834--targetcxxflags flags : List of C++ flags for the target code
2835--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
2836--with-<label>         : Add the --with-<label> to the build
2837--without-<label>      : Add the --without-<label> to the build
2838--regression           : Set --no-install, --keep-going and --always-clean
2839-------------------------------------------------------------
2840
2841Set Builder (sb-set-builder)
2842~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2843
2844This command builds a set.
2845
2846-------------------------------------------------------------
2847$ ../source-builder/sb-set-builder --help
2848RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
2849Options and arguments:
2850--force                : Force the build to proceed
2851--quiet                : Quiet output (not used)
2852--trace                : Trace the execution
2853--dry-run              : Do everything but actually run the build
2854--warn-all             : Generate warnings
2855--no-clean             : Do not clean up the build tree
2856--always-clean         : Always clean the build tree, even with an error
2857--regression           : Set --no-install, --keep-going and --always-clean
2858---jobs                 : Run with specified number of jobs, default: num CPUs.
2859--host                 : Set the host triplet
2860--build                : Set the build triplet
2861--target               : Set the target triplet
2862--prefix path          : Tools build prefix, ie where they are installed
2863--topdir path          : Top of the build tree, default is $PWD
2864--configdir path       : Path to the configuration directory, default: ./config
2865--builddir path        : Path to the build directory, default: ./build
2866--sourcedir path       : Path to the source directory, default: ./source
2867--tmppath path         : Path to the temp directory, default: ./tmp
2868--macros file[,[file]  : Macro format files to load after the defaults
2869--log file             : Log file where all build out is written too
2870--url url[,url]        : URL to look for source
2871--no-download          : Disable the source downloader
2872--no-install           : Do not install the packages to the prefix
2873--targetcflags flags   : List of C flags for the target code
2874--targetcxxflags flags : List of C++ flags for the target code
2875--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
2876--with-<label>         : Add the --with-<label> to the build
2877--without-<label>      : Add the --without-<label> to the build
2878--mail-from            : Email address the report is from.
2879--mail-to              : Email address to send the email too.
2880--mail                 : Send email report or results.
2881--smtp-host            : SMTP host to send via.
2882--no-report            : Do not create a package report.
2883--report-format        : The report format (text, html, asciidoc).
2884--bset-tar-file        : Create a build set tar file
2885--pkg-tar-files        : Create package tar files
2886--list-bsets           : List available build sets
2887--list-configs         : List available configurations
2888--list-deps            : List the dependent files.
2889-------------------------------------------------------------
2890
2891.Arguments
2892The +[args]+ are a list build sets to build.
2893
2894.Options
2895+--force+;;
2896Force the build to proceed even if the host check fails. Typically this happens
2897if executable files are found in the path at a different location to the host
2898defaults.
2899+--trace+;;
2900Trace enable printing of debug information to stdout. It is really only of use
2901to RTEMS Source Builder's developers.
2902+--dry-run+;;
2903Do everything but actually run the build commands. This is useful when checking
2904a new configuration parses cleanly.
2905+--warn-all+;;
2906Generate warnings.
2907+--no-clean+;;
2908Do not clean up the build tree during the cleaning phase of the build. This
2909leaves the source and the build output on disk so you can make changes, or
2910amend or generate new patches. It also allows you to review configure type
2911output such as +config.log+.
2912+--always-clean+;;
2913Clean away the results of a build even if the build fails. This is normally
2914used with `--keep-going` when regression testing to see which build sets
2915fail to build. It keeps the disk usage down.
2916+--jobs+;;
2917Control the number of jobs make is given. The jobs can be 'none' for only 1
2918job, 'half' so the number of jobs is half the number of detected cores, a
2919fraction such as '0.25' so the number of jobs is a quarter of the number of
2920detected cores and a number such as '25' which forces the number of jobs to
2921that number.
2922+--host+;;
2923Set the host triplet value. Be careful with this option.
2924+--build+;;
2925Set the build triplet. Be careful with this option.
2926+--target+;;
2927Set the target triplet. Be careful with this option. This is useful if you have
2928a generic configuration script that can work for a range of architectures.
2929+--prefix path+;;
2930Tools build prefix, ie where they are installed.
2931+--topdir path+;;
2932Top of the build tree, that is the current directory you are in.
2933+--configdir path+;;
2934Path to the configuration directory. This overrides the built in defaults.
2935+--builddir path+;;
2936Path to the build directory. This overrides the default of +build+.
2937+--sourcedir path+;;
2938Path to the source directory. This overrides the default of +source+.
2939+--tmppath path+;;
2940Path to the temporary directory. This overrides the default of +tmp+.
2941+--macros files+;;
2942Macro files to load. The configuration directory path is searched.
2943+--log file+;;
2944Log all the output from the build process. The output is directed to +stdout+
2945if no log file is provided.
2946+--url url+;;
2947URL to look for source when downloading. This is can be comma separate list.
2948+--no-download+;;
2949Disable downloading of source and patches. If the source is not found an error
2950is raised.
2951+--targetcflags flags+;;
2952List of C flags for the target code. This allows for specific local
2953customisation when testing new variations.
2954+--targetcxxflags flags+;;
2955List of C++ flags for the target code. This allows for specific local
2956customisation when testing new variations.
2957+--libstdcxxflags flags+;;
2958List of C\++ flags to build the target libstdc++ code. This allows for specific
2959local customisation when testing new variations.
2960+--with-<label>+;;
2961Add the --with-<label> to the build. This can be tested for in a script with
2962the +%bconf_with+ macro.
2963+--without-<label>+;;
2964Add the --without-<label> to the build. This can be tested for in a script with
2965the +%bconf_without+ macro.
2966+--mail-from+;;
2967Set the from mail address if report mailing is enabled.
2968+--mail-to+;;
2969Set the to mail address if report mailing is enabled. The report is mailed to
2970this address.
2971+--mail+;;
2972Mail the build report to the mail to address.
2973+--smtp-host+;;
2974The SMTP host to use to send the email. The default is +localhost+.
2975+--no-report+;;
2976Do not create a report format.
2977+--report-format format+;;
2978The report format can be 'text' or 'html'. The default is 'html'.
2979+--keep-going+;;
2980Do not stop on error. This is useful if your build sets performs a large number
2981of testing related builds and there are errors.
2982+--always-clean+.
2983Always clean the build tree even with a failure.
2984+--no-install+;;
2985Do not install the packages to the prefix. Use this if you are only after the
2986tar files.
2987+--regression+;;
2988A convenience option which is the same as +--no-install+, +--keep-going+ and
2989+--bset-tar-file+;;
2990Create a build set tar file. This is a single tar file of all the packages in
2991the build set.
2992+--pkg-tar-files+;;
2993Create package tar files. A tar file will be created for each package built in
2994a build set.
2995+--list-bsets+;;
2996List available build sets.
2997+--list-configs+;;
2998List available configurations.
2999+--list-deps+;;
3000Print a list of dependent files used by a build set. Dependent files have a
3001'dep[?]' prefix where '?' is a number. The files are listed alphabetically.
3002
3003Set Builder (sb-builder)
3004~~~~~~~~~~~~~~~~~~~~~~~~
3005
3006This command builds a configuration as described in a configuration
3007file. Configuration files have the extension of +.cfg+.
3008
3009-------------------------------------------------------------
3010$ ./source-builder/sb-builder --help
3011sb-builder: [options] [args]
3012RTEMS Source Builder, an RTEMS Tools Project (c) 2012 Chris Johns
3013Options and arguments:
3014--force                : Force the build to proceed
3015--quiet                : Quiet output (not used)
3016--trace                : Trace the execution
3017--dry-run              : Do everything but actually run the build
3018--warn-all             : Generate warnings
3019--no-clean             : Do not clean up the build tree
3020--always-clean         : Always clean the build tree, even with an error
3021--jobs                 : Run with specified number of jobs, default: num CPUs.
3022--host                 : Set the host triplet
3023--build                : Set the build triplet
3024--target               : Set the target triplet
3025--prefix path          : Tools build prefix, ie where they are installed
3026--topdir path          : Top of the build tree, default is $PWD
3027--configdir path       : Path to the configuration directory, default: ./config
3028--builddir path        : Path to the build directory, default: ./build
3029--sourcedir path       : Path to the source directory, default: ./source
3030--tmppath path         : Path to the temp directory, default: ./tmp
3031--macros file[,[file]  : Macro format files to load after the defaults
3032--log file             : Log file where all build out is written too
3033--url url[,url]        : URL to look for source
3034--targetcflags flags   : List of C flags for the target code
3035--targetcxxflags flags : List of C++ flags for the target code
3036--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
3037--with-<label>         : Add the --with-<label> to the build
3038--without-<label>      : Add the --without-<label> to the build
3039--list-configs         : List available configurations
3040-------------------------------------------------------------
3041
3042Host Setups
3043-----------
3044
3045The host versions are listed. If a later version of the host operating system
3046exists it should work unless listed.
3047
3048Please provide patches to update these sections if they are wrong or need
3049updating. I cannot install and test each one and rely on getting your feedback.
3050
3051Linux
3052~~~~~
3053
3054A number of different Linux distrubutions are known to work. The following have
3055been tested and report as working.
3056
3057Archlinux
3058^^^^^^^^^
3059
3060The following packages are required on a fresh Archlinux 64bit installation:
3061
3062--------------------------------------------------------------
3063# pacman -S base-devel gdb xz unzip ncurses git zlib
3064--------------------------------------------------------------
3065
3066Archlinux, by default installs `texinfo-5` which is incompatible for building
3067GCC 4.7 tree. You will have to obtain `texinfo-legacy` from `AUR` and provide
3068a manual override.
3069
3070--------------------------------------------------------------
3071# pacman -R texinfo
3072$ yaourt -S texinfo-legacy
3073# ln -s /usr/bin/makeinfo-4.13a /usr/bin/makeinfo
3074--------------------------------------------------------------
3075
3076CentOS
3077^^^^^^
3078
3079The following packages are required on a minimal CentOS 6.3 64bit installation:
3080
3081-------------------------------------------------------------
3082# yum install autoconf automake binutils gcc gcc-c++ gdb make patch \
3083bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git
3084-------------------------------------------------------------
3085
3086The minimal CentOS distribution is a specific DVD that installs a minimal
3087system. If you use a full system some of these packages may have been
3088installed.
3089
3090Fedora
3091^^^^^^
3092
3093The RTEMS Source Builder has been tested on Fedora 19 64bit with the following packages.
3094
3095-------------------------------------------------------------
3096# yum install ncurses-devel python-devel git bison gcc cvs gcc-c++ \
3097         flex texinfo patch perl-Text-ParseWords zlib-devel
3098-------------------------------------------------------------
3099
3100Raspbian
3101^^^^^^^^
3102
3103The is the Debian distribution for the Raspberry Pi. The following packages are
3104required.
3105
3106-------------------------------------------------------------
3107$ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
3108texinfo unzip ncurses-dev python-dev git
3109-------------------------------------------------------------
3110
3111It is recommended you get Model B of the Pi with 512M of memory and to mount a
3112remote disk over the network. The tools can be build with a prefix under your
3113home directory as recommended and end up on the SD card.
3114
3115Ubuntu
3116^^^^^^
3117
3118The latest testing was with Ubuntu 16.04.1 LTS 64bit. This section also includes Xubuntu. A
3119minimal installation was used and the following packages installed.
3120
3121-------------------------------------------------------------
3122$ sudo apt-get build-dep binutils gcc g++ gdb unzip git
3123$ sudo apt-get install python2.7-dev
3124-------------------------------------------------------------
3125
3126FreeBSD
3127~~~~~~~
3128
3129The RTEMS Source Builder has been tested on FreeBSD 9.1 and 10.0 64bit. You
3130need to install some ports. They are:
3131
3132-------------------------------------------------------------
3133# cd /usr/ports
3134# portinstall --batch lang/python27
3135-------------------------------------------------------------
3136
3137If you wish to build Windows (mingw32) tools please install the following
3138ports:
3139
3140-------------------------------------------------------------
3141# cd /usr/ports
3142# portinstall --batch devel/mingw32-binutils devel/mingw32-gcc
3143# portinstall --batch devel/mingw32-zlib devel/mingw32-pthreads
3144-------------------------------------------------------------
3145
3146The +zlip+ and +pthreads+ ports for MinGW32 are used for builiding a Windows
3147QEMU.
3148
3149If you are on FreeBSD 10.0 and you have pkgng installed you can use 'pkg
3150install' rather than 'portinstall'.
3151
3152NetBSD
3153~~~~~~
3154
3155The RTEMS Source Builder has been tested on NetBSD 6.1 i386. Packages to add
3156are:
3157
3158-------------------------------------------------------------
3159# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/devel/gmake-3.82nb7.tgz
3160# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/devel/bison-2.7.1.tgz
3161# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/archivers/xz-5.0.4.tgz
3162-------------------------------------------------------------
3163
3164MacOS
3165~~~~~
3166
3167The RTEMS Source Builder has been tested on Mountain Lion. You will need to
3168install the Xcode app using the _App Store_ tool, run Xcode and install the
3169Developers Tools package within Xcode.
3170
3171Linux Mint
3172^^^^^^^^^^
3173
3174zlib package is required on Linux Mint. It has a different name (other
3175than the usual zlib-dev):
3176
3177-------------------------------------------------------------
3178# sudo apt-get install zlib1g-dev
3179-------------------------------------------------------------
3180
3181Mavericks
3182^^^^^^^^^
3183
3184The RSB works on Mavericks and the GNU tools can be built for RTEMS using the
3185Mavericks clang LLVM tool chain. You will need to build and install a couple of
3186packages to make the RSB pass the +sb-check+. These are CVS and XZ. You can get
3187these tools from a packaging tool for MacOS such as _MacPorts_ or _HomeBrew_.
3188
3189I do not use 3rd party packaging on MacOS and prefer to build the packages from
3190source using a prefix of '/usr/local'. There are good 3rd party packages around
3191however they sometimes bring in extra dependence and that complicates my build
3192environment and I want to know the minimal requirements when building
3193tools. The following are required:
3194
3195. The XZ package's home page is http://tukaani.org/xz/ and I use version
3196  5.0.5. XZ builds and installs cleanly.
3197
3198. CVS can be found at http://cvs.nongnu.org/ and I use version 1.11.23. CVS
3199  requires the following patch
3200  http://ftp.rtems.org/pub/rtems/people/chrisj/source-builder/cvs-1.11.23-osx-maverick.diff
3201  to build. Place the diff in the same directory as the unpacked cvs-1.11.23
3202  and apply with +patch -p0 < cvs-1.11.23-osx-maverick.diff+.
3203
3204Windows
3205~~~~~~~
3206
3207Windows tool sets are supported. The tools are native Windows executable which
3208means they do not need an emulation layer to run once built. The tools
3209understand and use standard Windows paths and integrate easily into Windows IDE
3210environments because they understand and use standard Windows paths. Native
3211Windows tools have proven over time to be stable and reliable with good
3212performance. If you are a Windows user or you are required to use Windows you
3213can still develop RTEMS application as easily as a Unix operating system. Some
3214debugging experiences may vary and if this is an issue please raised the topic
3215on the RTEMS Users mailing list.
3216
3217Building the tools or some other packages may require a Unix or POSIX type
3218shell. There are a few options, Cygwin and MSYS2. I recommend MSYS2.
3219
3220.Ready To Go Windows Tools
3221NOTE: From time to time I provide tools for Windows at
3222http://ftp.rtems.org/pub/rtems/people/chrisj/source-builder/4.11/mingw32/
3223
3224MSYS2
3225
3226This is a new version of the old MinGW project's original MSYS based around the
3227Arch Linux pacman packager. MSYS and MSYS2 are a specific fork of the Cygwin
3228project with some fundamental changes in the handling of paths and mounts that
3229allow easy interaction between the emulated POSIX environment and the native
3230Windows environment.
3231
3232Install MSYS2 using the installer you can download from
3233https://msys2.github.io/. Follow the instructions on the install page and make
3234sure you remove any global path entries to any other Cygwin, MinGW, MSYS or
3235packages that may uses a Cygwin DLL, for example some ports of Git.
3236
3237To build the tools you need install the following packages using pacman:
3238
3239 $ pacman -S git cvs bison make texinfo patch unzip diffutils tar \
3240          mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-binutils
3241
3242To build make sure you add '--without-python --jobs=none' to the standard RSB
3243command line. MSYS2 has a temp file name issue and so the GNU AR steps on
3244itself when running in parallel on SMP hardware which means we have to set the
3245jobs option to none.
3246
3247Install a suitable version of Python from http://www.python.org/ and add it to
3248the start of your path. The MSYS2 python does not work with waf.
3249
3250Cygwin
3251
3252Building on Windows is a little more complicated because the Cygwin shell is
3253used rather than the MSYS2 shell. The MSYS2 shell is simpler because the
3254detected host triple is MinGW so the build is standard cross-compiler build.
3255A Canadian cross-build using Cygwin is supported if you would like native tools.
3256
3257Install a recent Cygwin version using the Cygwin setup tool. Select and install
3258the groups and packages listed:
3259
3260.Cygwin Packages
3261[options="header,compact",width="50%",cols="20%,80%"]
3262|================================
3263|Group   |Package
3264|Archive |bsdtar
3265|        |unzip
3266|        |xz
3267|Devel   |autoconf
3268|        |autoconf2.1
3269|        |autoconf2.5
3270|        |automake
3271|        |binutils
3272|        |bison
3273|        |flex
3274|        |gcc4-core
3275|        |gcc4-g++
3276|        |git
3277|        |make
3278|        |mingw64-x86_64-binutils
3279|        |mingw64-x86_64-gcc-core
3280|        |mingw64-x86_64-g++
3281|        |mingw64-x86_64-runtime
3282|        |mingw64-x86_64-zlib
3283|        |patch
3284|        |zlib-devel
3285|MinGW   |mingw-zlib-devel
3286|Python  |python
3287|================================
3288
3289The setup tool will add a number of dependent package and it is ok to accept
3290them.
3291
3292I have found turning off Windows Defender improves performance if you have
3293another up to date virus detection tool installed and enabled. I used the
3294excellent `Process Hacker 2` tool to monitor the performance and I found the
3295Windows Defender service contributed a high load. In my case I had a 3rd party
3296virus tool installed so the Windows Defender service was not needed.
3297
3298A Canadian cross-compile (Cxc) is required on Cygwin because the host is Cygwin
3299therefore a traditional cross-compile will result in Cygiwn binaries. With a
3300Canadian cross-compile a Cygwin cross-compiler is built as well as the MinGW
3301RTEMS cross-compiler. The Cygwin cross-compiler is required to build the C
3302runtime for the RTEMS target because we are building under Cygiwn. The build
3303output for an RTEMS 4.10 ARM tool set is:
3304
3305-------------------------------------------------------------
3306chris@cygthing ~/development/rtems/src/rtems-source-builder/rtems
3307$ ../source-builder/sb-set-builder --log=l-arm.txt --prefix=$HOME/development/rtems/4.10 4.10/rtems-arm
3308RTEMS Source Builder - Set Builder, v0.2
3309Build Set: 4.10/rtems-arm
3310config: expat-2.1.0-1.cfg
3311package: expat-2.1.0-x86_64-w64-mingw32-1
3312building: expat-2.1.0-x86_64-w64-mingw32-1
3313reporting: expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-w64-mingw32-1.html
3314config: tools/rtems-binutils-2.20.1-1.cfg
3315package: arm-rtems4.10-binutils-2.20.1-1 <1>
3316building: arm-rtems4.10-binutils-2.20.1-1
3317package: (Cxc) arm-rtems4.10-binutils-2.20.1-1 <2>
3318building: (Cxc) arm-rtems4.10-binutils-2.20.1-1
3319reporting: tools/rtems-binutils-2.20.1-1.cfg ->
3320arm-rtems4.10-binutils-2.20.1-1.html
3321config: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg
3322package: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
3323building: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
3324package: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
3325building: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
3326reporting: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg ->
3327arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1.html
3328config: tools/rtems-gdb-7.3.1-1.cfg
3329package: arm-rtems4.10-gdb-7.3.1-1
3330building: arm-rtems4.10-gdb-7.3.1-1
3331reporting: tools/rtems-gdb-7.3.1-1.cfg -> arm-rtems4.10-gdb-7.3.1-1.html
3332config: tools/rtems-kernel-4.10.2.cfg
3333package: arm-rtems4.10-kernel-4.10.2-1
3334building: arm-rtems4.10-kernel-4.10.2-1
3335reporting: tools/rtems-kernel-4.10.2.cfg -> arm-rtems4.10-kernel-4.10.2-1.html
3336installing: expat-2.1.0-x86_64-w64-mingw32-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
3337installing: arm-rtems4.10-binutils-2.20.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10 <3>
3338installing: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
3339installing: arm-rtems4.10-gdb-7.3.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
3340installing: arm-rtems4.10-kernel-4.10.2-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
3341cleaning: expat-2.1.0-x86_64-w64-mingw32-1
3342cleaning: arm-rtems4.10-binutils-2.20.1-1
3343cleaning: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
3344cleaning: arm-rtems4.10-gdb-7.3.1-1
3345cleaning: arm-rtems4.10-kernel-4.10.2-1
3346Build Set: Time 10:09:42.810547 <4>
3347-------------------------------------------------------------
3348
3349<1> The Cygwin version of the ARM cross-binutils.
3350<2> The +(Cxc)+ indicates this is the MinGW build of the package.
3351<3> Only the MinGW version is installed.
3352<4> Cygwin is slow so please be patient. This time was on an AMD Athlon 64bit
3353    Dual Core 6000+ running at 3GHz with 4G RAM running Windows 7 64bit.
3354
3355CAUTION: Cygwin documents the 'Big List Of Dodgy Apps' or 'BLODA'. The link is
3356http://cygwin.com/faq/faq.html#faq.using.bloda and it is worth a
3357look. You will see a large number of common pieces of software found on Windows
3358systems that can cause problems. My testing has been performed with NOD32
3359running and I have seen some failures. The list is for all of Cygwin so I am
3360not sure which of the listed programs effect the RTEMS Source Biulder. The
3361following FAQ item talks about +fork+ failures and presents some technical
3362reasons they cannot be avoided in all cases. Cygwin and it's fork MSYS are
3363fantastic pieces of software in a difficult environment. I have found building
3364a single tool tends to work, building all at once is harder.
3365
3366
3367Build Status By Host
3368~~~~~~~~~~~~~~~~~~~~
3369
3370This table lists the current build and testing status for reported hosts:
3371
3372[grid="rows",format="csv"]
3373[options="header",cols="<,<,<,<,<,<"]
3374|===========================
3375OS,Uname,4.9,4.10,4.11,Comments
3376include::host-results.csv[]
3377|===========================
3378
3379[NOTE]
3380==================================================================
3381Report any unlisted hosts as a patch.
3382==================================================================
3383
3384History
3385-------
3386
3387The RTEMS Source Builder is a stand alone tool based on another tool called the
3388'SpecBuilder'. The SpecBuilder was written for the RTEMS project to give me a
3389way to build tools on hosts that did not support RPMs. At the time the RTEMS
3390tools maintainer only used spec files to create various packages. This meant I
3391had either spec files, RPM files or SRPM files. The RPM and SPRM files where
3392useless because you needed an 'rpm' type tool to extract and manage them. There
3393are versions of 'rpm' for a number of non-RPM hosts however these proved to be
3394in various broken states and randomly maintained. The solution I settled on was
3395to use spec files so I wrote a Python based tool that parsed the spec file
3396format and allowed me to create a shell script I could run to build the
3397package. This approach proved successful and I was able to track the RPM
3398version of the RTEMS tools on a non-RPM host over a number of years. however
3399the SpecBuilder tool did not help me build tools or other packages not related
3400to the RTEMS project where there was no spec file I could use so I needed
3401another tool. Rather than start again I decided to take the parsing code for
3402the spec file format and build a new tool called the RTEMS Source Builder.
Note: See TracBrowser for help on using the repository browser.