source: rtems-source-builder/doc/source-builder.txt @ cac72a2

4.104.95
Last change on this file since cac72a2 was cac72a2, checked in by Gedare Bloom <gedare@…>, on 08/01/16 at 18:43:29

doc: add example of a local patch

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