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

4.104.114.95
Last change on this file since a2f4757 was a2f4757, checked in by Chris Johns <chrisj@…>, on 06/02/13 at 01:48:13

Update doc with file searching details.

  • Property mode set to 100644
File size: 94.3 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.2, April 2013
13
14RTEMS Tools From Source
15-----------------------
16
17The RTEMS Source Builder is a tool to aid building packages from source. It is
18not a package manager. It helps consolidate the details you need to build a
19package from source in a controlled and verifiable way. The tool is aimed at
20developers of software who use tool sets for embedded type
21development. Embedded development typically uses cross-compiling tool chains,
22debuggers, and debugging aids. Together we call these a 'tool set'. The RTEMS
23Source Builder is not limited to this role but designed to fit with-in this
24specific niche. It can be used outside of the RTEMS project and we welcome this
25happening 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* <<_archlinux,Archlinux>>
36* <<_centos,Centos>>
37* <<_fedora,Fedora>>
38* <<_freebsd,FreeBSD>>
39* <<_macos,MacOS>>
40* <<_opensuse,openSUSE>>
41* <<_raspbian,Raspbian>>
42* <<_ubuntu,Ubuntu>>
43* <<_windows,Windows>>
44
45The RTEMS Source Builder has two types configuration data. The first is the
46'build set'. A _build set_ describes a collection of packages that define a set
47of tools you would use when developing software for RTEMS. For example the
48basic GNU tool set is binutils, gcc, and gdb and is the typical base suite of
49tools you need for an embedded cross-development type project. The second type
50of configuration data is the configuration files and they define how a package
51is built. Configuration files are scripts loosely based on the RPM spec file
52format and detail the steps needed to build a package. The steps are
53'preparation', 'building', and 'installing'. Scripts support macros, shell
54expansion, logic, includes plus many more features useful when build packages.
55
56The RTEMS Source Builder does not interact with any host package management
57systems. There is no automatic dependence checking between various packages you
58build or packages and software your host system you may have installed. We
59assume the build sets and configuration files you are using have been created
60by developers who do. If you have a problem please ask on the RTEMS Users
61mailing list.
62
63Quick Start
64-----------
65
66The quick start will show you how to build a set of RTEMS tools for a supported
67architecture.
68
69There is no need to become root or the administrator and we recommend you avoid
70doing this. You can build and install the tools anywhere on the host's file
71system you, as a standard user, have read and write access too. I recommend you
72use your home directory and work under the directory `~/development/rtems`. The
73examples shown here will do this.
74
75You can use the build _prefix_ to install and maintain different versions of
76the tools. Doing this lets you try a new set of tools while not touching your
77proven working production set of tools. Once you have proven the new tools are
78working rebuild with the 'production' prefix switching your development to them.
79
80I also suggest you keep your environment to the bare minimum, particularly the
81path variable. Using environment variables has been proven over the years to be
82difficult to manage in production systems.
83
84Setup
85~~~~~
86
87Setup a development work space:
88
89-------------------------------------------------------------
90$ cd
91$ mkdir -p development/rtems/src
92$ cd development/rtems/src
93-------------------------------------------------------------
94
95The RTEMS Source Builder is distributed as source. It is Python code so all you
96need to do is head over to the RTEMS GIT repository and clone the code directly
97from git:
98
99-------------------------------------------------------------
100$ git clone git://git.rtems.org/rtems-source-builder.git
101$ cd rtems-source-builder
102-------------------------------------------------------------
103
104Checking
105~~~~~~~~
106
107The next step is to check if your host is set up correctly. The RTEMS Source
108Builder provides a tool to help:
109
110-------------------------------------------------------------
111$ source-builder/sb-check
112warning: exe: absolute exe found in path: (__objcopy) /usr/local/bin/objcopy <1>
113warning: exe: absolute exe found in path: (__objdump) /usr/local/bin/objdump
114error: exe: not found: (_xz) /usr/local/bin/xz <2>
115RTEMS Source Builder environment is not correctly set up
116$ source-builder/sb-check
117RTEMS Source Builder environment is ok <3>
118-------------------------------------------------------------
119
120<1> A tool is in the environment path but does not match the expected path.
121<2> The executable 'xz' is not found.
122<3> The host's environment is set up correct.
123
124The checking tool will output a list of executable files not found if problems
125are detected. Locate those executable files and install them. You may also be
126given a list of warnings about executable files not in the expected location
127however the executable was located somewhere in your environment's path. You
128will need to check each tool to determine if this is an issue. An executable
129not in the standard location may indicate it is not the host operating system's
130standard tool. It maybe ok or it could be buggy, only you can determine this.
131
132The <<_host_setups,Host Setups>> section lists packages you should install for
133common host operating systems. It maybe worth checking if you have those
134installed.
135
136Build Sets
137~~~~~~~~~~
138
139The RTEMS tools can be built within the RTEMS Source Builder's source tree. We
140recommend you do this so lets change into the RTEMS directory in the RTEMS
141Source Builder package:
142
143-------------------------------------------------------------
144$ cd rtems
145-------------------------------------------------------------
146
147If you are unsure how to specify the build set for the architecture you wish to
148build ask the tool:
149
150-------------------------------------------------------------
151$ ../source-builder/sb-set-builder --list-bsets <1>
152RTEMS Source Builder - Set Builder, v0.2.0
153Examining: config <2>
154Examining: ../source-builder/config <2>
155    4.10/rtems-all.bset <3>
156    4.10/rtems-arm.bset <4>
157    4.10/rtems-autotools.bset
158    4.10/rtems-avr.bset
159    4.10/rtems-bfin.bset
160    4.10/rtems-h8300.bset
161    4.10/rtems-i386.bset
162    4.10/rtems-lm32.bset
163    4.10/rtems-m32c.bset
164    4.10/rtems-m32r.bset
165    4.10/rtems-m68k.bset
166    4.10/rtems-mips.bset
167    4.10/rtems-nios2.bset
168    4.10/rtems-powerpc.bset
169    4.10/rtems-sh.bset
170    4.10/rtems-sparc.bset
171    4.11/rtems-all.bset
172    4.11/rtems-arm.bset
173    4.11/rtems-autotools.bset
174    4.11/rtems-avr.bset
175    4.11/rtems-bfin.bset
176    4.11/rtems-h8300.bset
177    4.11/rtems-i386.bset
178    4.11/rtems-lm32.bset
179    4.11/rtems-m32c.bset
180    4.11/rtems-m32r.bset
181    4.11/rtems-m68k.bset
182    4.11/rtems-microblaze.bset
183    4.11/rtems-mips.bset
184    4.11/rtems-moxie.bset
185    4.11/rtems-nios2.bset
186    4.11/rtems-powerpc.bset
187    4.11/rtems-sh.bset
188    4.11/rtems-sparc.bset
189    4.11/rtems-sparc64.bset
190    4.11/rtems-v850.bset
191    4.9/rtems-all.bset
192    4.9/rtems-arm.bset
193    4.9/rtems-autotools.bset
194    4.9/rtems-i386.bset
195    4.9/rtems-m68k.bset
196    4.9/rtems-mips.bset
197    4.9/rtems-powerpc.bset
198    4.9/rtems-sparc.bset
199    gnu-tools-4.6.bset
200    rtems-4.10-base.bset <5>
201    rtems-4.11-base.bset
202    rtems-4.9-base.bset
203    rtems-base.bset <5>
204    unstable/4.11/rtems-all.bset <6>
205    unstable/4.11/rtems-arm.bset
206    unstable/4.11/rtems-avr.bset
207    unstable/4.11/rtems-bfin.bset
208    unstable/4.11/rtems-h8300.bset
209    unstable/4.11/rtems-i386.bset
210    unstable/4.11/rtems-lm32.bset
211    unstable/4.11/rtems-m32c.bset
212    unstable/4.11/rtems-m32r.bset
213    unstable/4.11/rtems-m68k.bset
214    unstable/4.11/rtems-microblaze.bset
215    unstable/4.11/rtems-mips.bset
216    unstable/4.11/rtems-moxie.bset
217    unstable/4.11/rtems-powerpc.bset
218    unstable/4.11/rtems-sh.bset
219    unstable/4.11/rtems-sparc.bset
220    unstable/4.11/rtems-sparc64.bset
221    unstable/4.11/rtems-v850.bset
222-------------------------------------------------------------
223<1> Only option needed is +--list-bsets+
224<2> The paths inspected. See <<X1,+_configdir+>> variable.
225<3> Build all RTEMS 4.10 supported architectures.
226<4> The build set for the ARM architecture on RTEMS 4.10.
227<5> Support build set file with common functionality included by other build
228    set files.
229<6> Unstable tool sets are used by RTEMS developers to test new tool sets. You
230    are welcome to try them but you must remember they are unstable, can change
231    at any point in time and your application may not work. If you have an
232    issue with a production tool it may pay to try the unstable tool to see if
233    it has been resolved.
234
235Building
236~~~~~~~~
237
238In this quick start I will build a SPARC tool set.
239
240-------------------------------------------------------------
241$ ../source-builder/sb-set-builder --log=l-sparc.txt <1> \
242                --prefix=$HOME/development/rtems/4.11 <2> 4.11/rtems-sparc <3>
243Source Builder - Set Builder, v0.2.0
244Build Set: 4.11/rtems-sparc
245config: expat-2.1.0-1.cfg <4>
246package: expat-2.1.0-x86_64-freebsd9.1-1
247building: expat-2.1.0-x86_64-freebsd9.1-1
248config: tools/rtems-binutils-2.22-1.cfg <5>
249package: sparc-rtems4.11-binutils-2.22-1
250building: sparc-rtems4.11-binutils-2.22-1
251config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg <6>
252package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
253building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
254config: tools/rtems-gdb-7.5.1-1.cfg <7>
255package: sparc-rtems4.11-gdb-7.5.1-1
256building: sparc-rtems4.11-gdb-7.5.1-1
257installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <8>
258installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
259installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
260installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
261cleaning: expat-2.1.0-x86_64-freebsd9.1-1 <9>
262cleaning: sparc-rtems4.11-binutils-2.22-1
263cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
264cleaning: sparc-rtems4.11-gdb-7.5.1-1
265Build Set: Time 0:13:43.616383 <10>
266-------------------------------------------------------------
267
268<1> Providing a log file redirects the build output into a file. Logging the
269    build output provides a simple way to report problems.
270<2> The prefix is the location on your file system the tools are installed
271    into. Provide a prefix to a location you have read and write access. You
272    can use the prefix to install different versions or builds of tools. Just
273    use the path to the tools you want to use when building RTEMS.
274<3> The build set. This is the SPARC build set. First a specifically referenced
275    file is checked for and if not found the '%{_configdir} path is
276    searched. The set builder will first look for files with a '.bset'
277    extension and then for a configuration file with a '.cfg' extension.
278<4> The SPARC build set first builds the expat library as is used in GDB. This
279    is the expat configuration used.
280<5> The binutils build configuration.
281<6> The GCC and Newlib build configuration.
282<7> The GDB build configuration.
283<8> Installing the built packages to the install prefix.
284<9> All the packages built are cleaned at the end. If the build fails all the
285    needed files are present. You may have to clean up by deleting the build
286    directory if the build fails.
287<10> The time to build the package. This lets you see how different host
288     hardware or configurations perform.
289
290Your SPARC RTEMS 4.11 tool set will be installed and ready to build RTEMS and
291RTEMS applications. When the build runs you will notice the tool fetch the
292source code from the internet. These files are cached in a directory called
293+source+. If you run the build again the cached files are used. This is what
294happened in the show example before.
295
296The installed tools:
297
298-------------------------------------------------------------
299$ ls $HOME/development/rtems/4.11
300bin         include     lib         libexec     share       sparc-rtems4.11
301$ ls $HOME/development/rtems/4.11/bin
302sparc-rtems4.11-addr2line       sparc-rtems4.11-cpp
303sparc-rtems4.11-gcc-ar          sparc-rtems4.11-gprof
304sparc-rtems4.11-objdump         sparc-rtems4.11-size
305sparc-rtems4.11-ar              sparc-rtems4.11-elfedit
306sparc-rtems4.11-gcc-nm          sparc-rtems4.11-ld
307sparc-rtems4.11-ranlib          sparc-rtems4.11-strings
308sparc-rtems4.11-as              sparc-rtems4.11-g++
309sparc-rtems4.11-gcc-ranlib      sparc-rtems4.11-ld.bfd
310sparc-rtems4.11-readelf         sparc-rtems4.11-strip
311sparc-rtems4.11-c++             sparc-rtems4.11-gcc
312sparc-rtems4.11-gcov            sparc-rtems4.11-nm
313sparc-rtems4.11-run             xmlwf
314sparc-rtems4.11-c++filt         sparc-rtems4.11-gcc-4.7.2
315sparc-rtems4.11-gdb             sparc-rtems4.11-objcopy
316sparc-rtems4.11-sis
317$ $HOME/development/rtems/4.11/bin/sparc-rtems4.11-gcc -v
318Using built-in specs.
319COLLECT_GCC=/home/chris/development/rtems/4.11/bin/sparc-rtems4.11-gcc
320COLLECT_LTO_WRAPPER=/usr/home/chris/development/rtems/4.11/bin/../ \
321libexec/gcc/sparc-rtems4.11/4.7.2/lto-wrapper
322Target: sparc-rtems4.11 <1>
323Configured with: ../gcc-4.7.2/configure <2>
324--prefix=/home/chris/development/rtems/4.11
325--bindir=/home/chris/development/rtems/4.11/bin
326--exec_prefix=/home/chris/development/rtems/4.11
327--includedir=/home/chris/development/rtems/4.11/include
328--libdir=/home/chris/development/rtems/4.11/lib
329--libexecdir=/home/chris/development/rtems/4.11/libexec
330--mandir=/home/chris/development/rtems/4.11/share/man
331--infodir=/home/chris/development/rtems/4.11/share/info
332--datadir=/home/chris/development/rtems/4.11/share
333--build=x86_64-freebsd9.1 --host=x86_64-freebsd9.1 --target=sparc-rtems4.11
334--disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib
335--with-system-zlib --disable-nls --without-included-gettext
336--disable-win32-registry --enable-version-specific-runtime-libs --disable-lto
337--enable-threads --enable-plugin --enable-newlib-io-c99-formats
338--enable-newlib-iconv --enable-languages=c,c++
339Thread model: rtems <3>
340gcc version 4.7.2 20120920 <4>
341 (RTEMS4.11-RSB(cb12e4875c203f794a5cd4b3de36101ff9a88403)-1,gcc-4.7.2/newlib-2.0.0) (GCC)
342-------------------------------------------------------------
343
344<1> The target the compiler is built for.
345<2> The configure options used to build GCC.
346<3> The threading model is always RTEMS. This makes the RTEMS tools difficult
347    for bare metal development more difficult.
348<4> The version string. It contains the Git hash of the RTEMS Source Builder
349    you are using. If your local clone has been modifed that state is also
350    recorded in the version string. The hash allows you to track from a GCC
351    executable back to the original source used to build it.
352
353NOTE: The RTEMS thread model enables specific hooks in GCC so applications
354built with RTEMS tools need the RTEMS runtime to operate correctly. You can use
355RTEMS tools to build bare metal component but it is more difficult than with a
356bare metal tool chain and you need to know what you are doing at a low
357level. The RTEMS Source Builder can build bare metal tool chains.
358
359Installing and Tar Files
360~~~~~~~~~~~~~~~~~~~~~~~~
361
362The RTEMS Source Builder can install the built packages directly and optionally
363it can create a build set tar file or a tar file per package built. The normal
364and default behaviour is to let the RTEMS Source Builder install the tools. The
365source will be downloaded, built, installed and cleaned up.
366
367The tar files are created with the full build prefix present and if you follow
368the examples given in this documentation the path is absolute. This can cause
369problems if you are installing on a host you do not have super user or
370administrator rights on because the prefix path may references part you do not
371have write access too and tar will not extract the files. You can use the
372+--strip-components+ option in tar if your host tar application supports it to
373remove the parts you do not have write access too or you may need to unpack the
374tar file somewhere and copy the file tree from the level you have write access
375from. Embedding the full prefix path in the tar files lets you know what the
376prefix is and is recommended. For example if
377`/home/chris/development/rtems/4.11` is the prefix used you cannot change
378directory to the root (`/`) and install because the `/home` is root access
379only. To install you would:
380
381-------------------------------------------------------------
382$ cd
383$ tar --strip-components=3 -xjf rtems-4.11-sparc-rtems4.11-1.tar.bz2
384-------------------------------------------------------------
385
386A build set tar file is created by adding `--bset-tar-file` option to the
387`sb-set-builder` command.
388
389-------------------------------------------------------------
390$ ../source-builder/sb-set-builder --log=l-sparc.txt \
391         --prefix=$HOME/development/rtems/4.11 \
392         --bset-tar-file <1> 4.11/rtems-sparc
393Source Builder - Set Builder, v0.2.0
394Build Set: 4.11/rtems-sparc
395config: expat-2.1.0-1.cfg
396package: expat-2.1.0-x86_64-freebsd9.1-1
397building: expat-2.1.0-x86_64-freebsd9.1-1
398config: tools/rtems-binutils-2.22-1.cfg
399package: sparc-rtems4.11-binutils-2.22-1
400building: sparc-rtems4.11-binutils-2.22-1
401config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
402package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
403building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
404config: tools/rtems-gdb-7.5.1-1.cfg
405package: sparc-rtems4.11-gdb-7.5.1-1
406building: sparc-rtems4.11-gdb-7.5.1-1
407installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <2>
408installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
409installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
410installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
411tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
412cleaning: expat-2.1.0-x86_64-freebsd9.1-1
413cleaning: sparc-rtems4.11-binutils-2.22-1
414cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
415cleaning: sparc-rtems4.11-gdb-7.5.1-1
416Build Set: Time 0:15:25.92873
417-------------------------------------------------------------
418
419<1> The option to create a build set tar file.
420<2> The installation still happens unless you specify `--no-install`.
421<3> Creating the build set tar file.
422
423You can also suppress installing the files using the `--no-install` option to
424the `sb-set-builder` command.
425
426-------------------------------------------------------------
427$ ../source-builder/sb-set-builder --log=l-sparc.txt \
428            --prefix=$HOME/development/rtems/4.11 \
429            --bset-tar-file --no-install <1> 4.11/rtems-sparc
430Source Builder - Set Builder, v0.2.0
431Build Set: 4.11/rtems-sparc
432config: expat-2.1.0-1.cfg
433package: expat-2.1.0-x86_64-freebsd9.1-1
434building: expat-2.1.0-x86_64-freebsd9.1-1
435config: tools/rtems-binutils-2.22-1.cfg
436package: sparc-rtems4.11-binutils-2.22-1
437building: sparc-rtems4.11-binutils-2.22-1
438config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
439package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
440building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
441config: tools/rtems-gdb-7.5.1-1.cfg
442package: sparc-rtems4.11-gdb-7.5.1-1
443building: sparc-rtems4.11-gdb-7.5.1-1
444tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <2>
445cleaning: expat-2.1.0-x86_64-freebsd9.1-1
446cleaning: sparc-rtems4.11-binutils-2.22-1
447cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
448cleaning: sparc-rtems4.11-gdb-7.5.1-1
449Build Set: Time 0:14:11.721274
450$ ls tar
451rtems-4.11-sparc-rtems4.11-1.tar.bz2
452-------------------------------------------------------------
453
454<1> The option to supressing installing the packages.
455<2> Create the build set tar.
456
457A package tar file can be created by adding the +--pkg-tar-files+ to the
458+sb-set-builder+ command. This creates a tar file per package built in the
459build set.
460
461-------------------------------------------------------------
462$ ../source-builder/sb-set-builder --log=l-sparc.txt \
463            --prefix=$HOME/development/rtems/4.11 \
464            --bset-tar-file --pkg-tar-files <1> --no-install 4.11/rtems-sparc
465Source Builder - Set Builder, v0.2.0
466Build Set: 4.11/rtems-sparc
467config: expat-2.1.0-1.cfg
468package: expat-2.1.0-x86_64-freebsd9.1-1
469building: expat-2.1.0-x86_64-freebsd9.1-1
470config: tools/rtems-binutils-2.22-1.cfg
471package: sparc-rtems4.11-binutils-2.22-1
472building: sparc-rtems4.11-binutils-2.22-1
473config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
474package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
475building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
476config: tools/rtems-gdb-7.5.1-1.cfg
477package: sparc-rtems4.11-gdb-7.5.1-1
478building: sparc-rtems4.11-gdb-7.5.1-1
479tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2
480cleaning: expat-2.1.0-x86_64-freebsd9.1-1
481cleaning: sparc-rtems4.11-binutils-2.22-1
482cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
483cleaning: sparc-rtems4.11-gdb-7.5.1-1
484Build Set: Time 0:14:37.658460
485$ ls tar
486expat-2.1.0-x86_64-freebsd9.1-1.tar.bz2           sparc-rtems4.11-binutils-2.22-1.tar.bz2
487sparc-rtems4.11-gdb-7.5.1-1.tar.bz2 <2>           rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
488sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1.tar.bz2
489-------------------------------------------------------------
490
491<1> The option to create packages tar files.
492<2> The GDB package tar file.
493<3> The build set tar file. All the others in a single tar file.
494
495Why Build from Source ?
496-----------------------
497
498The RTEMS Source Builder is not a replacement for the binary install systems
499you have with commercial operating systems or open source operating system
500distributions. Those products and distributions are critically important and
501are the base that allows the Source Builder to work. The RTEMS Source Builder
502sits somewhere between you manually entering the commands to build a tool set
503and a tool such as +yum+ or +apt-get+ to install binary packages made
504specifically for your host operating system. Building manually or installing a
505binary package from a remote repository are valid and real alternatives while
506the Source Builder is attempting to provide a specific service of repeatably
507being able to build tool sets from source code.
508
509If you are developing a system or product that has a long shelf life or is used
510in a critical piece of infrastructure that has a long life cycle being able to
511build from source is important. It insulates the project from the fast ever
512changing world of the host development machines. If your tool set is binary and
513you have lost the ability to build it you have lost a degree of control and
514flexibility open source gives you. Fast moving host environments are
515fantastic. We have powerful multi-core computers with huge amounts of memory
516and state of the art operating systems to run on them however the product or
517project you are part of may need to be maintained well past the life time of
518these host. Being able to build from source an important and critical part of
519this process because you can move to a newer host and create an equivalent tool
520set.
521
522Building from source provides you with control over the configuration of the
523package you are building. If all or the most important dependent parts are
524built from source you limit the exposure to host variations. For example the
525GNU C compiler (gcc) currently uses a number of 3rd party libraries internally
526(gmp, mpfr, etc). If your validated compiler generating code for your target
527processor is dynamically linked against the host's version of these libraries
528any change in the host's configuration may effect you. The changes the host's
529package management system makes may be perfectly reasonable in relation to the
530distribution being managed however this may not extend to you and your
531tools. Building your tools from source and controlling the specific version of
532these dependent parts means you are not exposing yourself to unexpected and
533often difficult to resolve problems. On the other side you need to make sure
534your tools build and work with newer versions of the host operating
535system. Given the stability of standards based libraries like 'libc' and ever
536improving support for standard header file locations this task is becoming
537easier.
538
539The RTEMS Source Builder is designed to be audited and incorporated into a
540project's verification and validation process. If your project is developing
541critical applications that needs to be traced from source to executable code in
542the target, you need to also consider the tools and how to track them.
543
544If your IT department maintains all your computers and you do not have suitable
545rights to install binary packages, building from source lets you create your
546own tool set that you install under your home directory. Avoiding installing
547any extra packages as a super user is always helpful in maintaining a secure
548computing environment.
549
550Bugs, Crashes, and Build Failures
551---------------------------------
552
553The RTEMS Source Builder is a Python program and every care is taken to test
554the code however bugs, crashes, and build failure can and do happen. If you
555find a bug please report it via the RTEMS Bug tracker tool Bugzilla:
556
557https://www.rtems.org/bugzilla/
558
559or via email on the RTEMS Users list.
560
561Please include the git hash you are running, the host details with the output
562of the +uname -a+ command. If there is a crash please cut and paste the Python
563backtrace into the bug report. If the tools fail to build please locate the
564first error in the log file. This can be difficult to find on hosts with many
565cores so it sometimes pays to run the command with the +--jobs=none+ option to
566get a log that is correctly sequenced.
567
568Configuration
569-------------
570
571The RTEMS Source Builder has two types of configuration data:
572
573. Build Sets
574. Package Build Configurations
575
576By default these files can be located in two separate directories and
577searched. The first directory is +config+ in your current working directory
578(+_topdir+) and the second is +config+ located in the base directory of the
579RTEMS Source Builder command you run (+_sbdir+). The RTEMS directory +rtems+
580located at the top of the RTEMS Source Builder source code is an example of a
581specific build configuration directory. You can create custom or private build
582configurations and if you run the RTEMS Source Builder command from that
583directory your configurations will be used.
584
585[[X1]] The configuration search path is a macro variable and is reference as
586+%\{_configdir\}+. It's default is defined as:
587
588-------------------------------------------------------------
589_configdir          : dir      optional   %{_topdir}/config:%{_sbdir}/config <1>
590-------------------------------------------------------------
591
592<1> The +_topdir+ is the directory you run the command from and +_sbdir+ is the
593location of the RTEMS Source Builder command.
594
595Build set files have the file extension +.bset+ and the package build
596configuration files have the file extension of +.cfg+. The +sb-set-builder+
597command will search for _build sets_ and the +sb-builder+ commands works with
598package build configuration files.
599
600Both types of configuration files use the \'#' character as a comment
601character. Anything after this character on the line is ignored. There is no
602block comment.
603
604Source and Patches
605~~~~~~~~~~~~~~~~~~
606
607The RTEMS Source Builder provides a flexible way to manage source. Source and
608patches are declare in configurations file using the +source+ and +patch+
609directives. There are a single line containing a Universal Resource Location or
610URL and can contain macros and shell expansions. The <<_prep,%prep>> section
611details the source and patch directives
612
613The URL can reference remote and local source and patch resources. The
614following schemes are provided:
615
616'http':: Remote access using the HTTP protocol.
617'https':: Remote access using the Secure HTTP protocol.
618'ftp:: Remote access using the FTP protocol.
619'git:: Remote access to a GIT repository.
620'cvs:: Remote access to a CVS repository.
621'file:: Local access to an existing source directory.
622
623HTTP, HTTPS, and FTP
624^^^^^^^^^^^^^^^^^^^^
625
626Remote access to TAR files is provided using HTTP, HTTPS and FTP protocols. The
627full URL provided is used to access the remote file including any query
628components. The URL is parsed to extract the file component and the local
629source directory is checked for that file. If the file is located the remote
630file is not downloaded. Currently no other checks are made. If a download fails
631you need to manually remove the file from the source directory and start the
632build process again.
633
634The URL can contain macros. These are expand before issuing the request to
635download the file. The GNU GCC compiler source URL is:
636
637-------------------------------------------------------------
638Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
639-------------------------------------------------------------
640
641The type of compression is automatically detected from the file extension. The
642supported compression formats are:
643
644`gz`:: GNU ZIP
645`bzip2`:: BZIP2 ??
646`zip`:: ??
647'xy':: XY ??
648
649The output of the decompression tool is feed to the standard `tar` utility and
650unpacked into the build directory.
651
652If the URL references the GitHub API server 'https://api.github.com/' a tarball
653of the specified version is download. For example the URL for the STLINK
654project on GitHub and version is:
655
656-------------------------------------------------------------
657%define stlink_version 3494c11
658Source0: https://api.github.com/repos/texane/stlink/texane-stlink-%{stlink_version}.tar.gz
659-------------------------------------------------------------
660
661the TAR file is downloaded and used.
662
663GIT
664^^^
665
666A GIT repository can be cloned and used as source. The GIT repository resides
667in the 'source' directory under the `git` directory. You can edit, update and
668use the repository as you normally do and the results will used to build the
669tools. This allows you to prepare and test patches in the build environment the
670tools are built in. The GIT URL only supports the GIT protocol. You can control
671the repository via the URL by appending options and arguments to the GIT
672path. The options are delimited by `?` and option arguments are delimited from
673the options with `=`. The options are:
674
675`branch`:: Checkout the specified branch.
676`pull`:: Perform a pull to update the repository.
677`fetch`:: Perform a fetch to get any remote updates.
678`reset`:: Reset the repository. Useful to remove any local changes. You can
679pass the `hard` argument to force a hard reset.
680
681-------------------------------------------------------------
682Source0: git://gcc.gnu.org/git/gcc.git?branch=gcc-4_7-branch?reset=hard
683-------------------------------------------------------------
684
685This will clone the GCC git repository and checkout the 4.7-branch and perform
686a hard reset.
687
688CVS
689^^^
690
691A CVS repository can be checked out. CVS is more complex than GIT to handle
692because of the modules support. This can effect the paths the source ends up
693in. The CVS URL only supports the CVS protocol. You can control the repository
694via the URL by appending options and arguments to the CVS path. The options are
695delimited by `?` and option arguments are delimited from the options with
696`=`. The options are:
697
698`module`:: The module to checkout.
699`src-prefix`:: The path into the source where the module starts.
700`tag`:: The CVS tag to checkout.
701`date`:: The CVS date to checkout.
702
703-------------------------------------------------------------
704Source0: cvs://pserver:anoncvs@sourceware.org/cvs/src?module=newlib?src-prefix=src
705-------------------------------------------------------------
706
707Macros and Defaults
708~~~~~~~~~~~~~~~~~~~
709
710The RTEMS Source Builder uses tables of _macros_ read in when the tool
711runs. The initial global set of macros is called the _defaults_. These values
712are read from a file called `defaults.mc` and modified to suite your host. This
713host specific adaption lets the Source Builder handle differences in the build
714hosts.
715
716Build set and configuration files can define new values updating and extending
717the global macro table. For example builds are given a release number. This is
718typically a single number at the end of the package name. For example:
719
720-------------------------------------------------------------
721%define release 1
722-------------------------------------------------------------
723
724Once defined if can be accessed in a build set or package configuration file
725with:
726
727-------------------------------------------------------------
728%{release}
729-------------------------------------------------------------
730
731The +sb-defaults+ command lists the defaults for your host. I will not include
732the output of this command becauses of its size.
733
734-------------------------------------------------------------
735$ ../source-builder/sb-defaults
736-------------------------------------------------------------
737
738A nested build set is given a separate copy of the global macro maps. Changes
739in one change set are not seen in other build sets. That same happens with
740configuration files unless inline includes are used. Inline includes are seen
741as part of the same build set and configuration and changes are global to that
742build set and configuration.
743
744Macro Maps and Files
745^^^^^^^^^^^^^^^^^^^^
746
747Macros are read in from files when the tool starts. The default settings are
748read from the defaults macro file called `defaults.mc` located in the top level
749RTEMS Source Builder command directory. User macros can be read in at start up
750by using the `--macros` command line option.
751
752The format for a macro in macro files is:
753
754[options="header,compact",width="50%",cols="15%,15%,15%,55%"]
755|=================================
756| Name | Type | Attribute | String
757|=================================
758
759where 'Name' is a case insensitive macro name, the 'Type' field is:
760
761[horizontal]
762`none`:: Nothing, ignore.
763`dir`:: A directory path.
764`exe`:: An executable path.
765`triplet`:: A GNU style architecture, platform, operating system string.
766
767the 'Attribute' field is:
768
769[horizontal]
770`none`:: Nothing, ignore
771`required`:: The host check must find the executable or path.
772`optional`:: The host check generates a warning if not found.
773`override`:: Only valid outside of the `global` map to indicate this macro
774             overrides the same one in the `global` map when the map containing
775             it is selected.
776`undefine`:: Only valid outside of the `global` map to undefine the macro if it
777             exists in the `global` map when the map containing it is
778             selected. The `global` map's macro is not visible but still
779             exists.
780
781and the 'String' field is a single or tripled multiline quoted string. The
782'String' can contain references to other macros. Macro that loop are not
783currently detected and will cause the tool to lock up.
784
785Maps are declared anywhere in the map using the map directive:
786
787-------------------------------------------------------------
788# Comments
789[my-special-map] <1>
790_host:  none, override, 'abc-xyz'
791multiline: none, override, '''First line,
792second line,
793and finally the last line'''
794-------------------------------------------------------------
795<1> The map is set to `my-special-map`.
796
797Any macro defintions following a map declaration are placed in that map and the
798default map is `global` when loading a file. Maps are selected in configuration
799files by using the `%select` directive.
800
801-------------------------------------------------------------
802%select my-special-map
803-------------------------------------------------------------
804
805Selecting a map means all requests for a macro first check the selected map and
806if present return that value else the `global` map is used. Any new macros or
807changes update only the `global` map. This may change in future releases so
808please make sure you use the `override` attibute.
809
810The macro files specificed on the command line are looked for in the
811`_configdir` paths. See <<X1,+_configdir+>> variable for details. Included
812files need to add the `%{_configdir}` macro to the start of the file.
813
814Macro map files can include other macro map files using the `%include`
815directive. The macro map to build _binutils_, _gcc_, _newlib_, _gdb_ and
816_RTEMS_ from version control heads is:
817
818-------------------------------------------------------------
819# <1>
820# Build all tool parts from version control head.
821#
822%include %{_configdir}/snapshots/binutils-head.mc
823%include %{_configdir}/snapshots/gcc-head.mc
824%include %{_configdir}/snapshots/newlib-head.mc
825%include %{_configdir}/snapshots/gdb-head.mc
826-------------------------------------------------------------
827<1> The file is `config/snapshots/binutils-gcc-newlib-gdb-head.mc`.
828
829The macro map defaults to `global` at the start of each included file and the
830map setting of the macro file including the other macro files does not change.
831
832Personal Macros
833^^^^^^^^^^^^^^^
834
835When the tools start to run they will load personal macros. Personal macros are
836in the standard format for macros in a file. There are two places personal
837macros can be configured. The first is the environment variable
838`RSB_MACROS`. If presentthe macros from the file the environment variable
839points to are loaded. The second is a file called `.rsb_macros` in your home
840directory. You need to have the environment variable `HOME` defined for this
841work.
842
843Report Mailing
844~~~~~~~~~~~~~~
845
846The build reports can be mailed to a specific email address to logging and
847monitoring. Mailing requires a number of parameters to function. These are:
848
849. To mail address
850. From mail address
851. SMTP host
852
853.To Mail Address
854
855The +to+ mail address is taken from the macro `%{_mail_tools_to}` and the
856default is _rtems-tooltestresults at rtems.org_. You can override the default
857with a personal or user macro file or via the command line option _--mail-to_.
858
859.From Mail Address
860
861The +from+ mail address is taken from:
862
863. GIT configuration
864. User `.mailrc` file
865. Command line
866
867If you have configured an email and name in git it will be used used. If you do
868not a check is made for a `.mailrc` file. The environment variable _MAILRC_ is
869used if present else your home directory is check. If found the file is scanned
870for the `from` setting:
871
872  set from="Foo Bar <foo@bar>"
873
874You can also support a from address on the command line with the _--mail-from_
875option.
876
877.SMTP Host
878
879The SMTP host is taken from the macro `%{_mail_smtp_host}` and the default is
880`localhost`. You can override the default with a personal or user macro file or
881via the command line option _--smtp-host_.
882
883Build Set Files
884~~~~~~~~~~~~~~~
885
886Build set files lets you list the packages in the build set you are defining
887and have a file extension of +.bset+. Build sets can define macro variables,
888inline include other files and reference other build set or package
889configuration files.
890
891Defining macros is performed with the +%define+ macro:
892
893-------------------------------------------------------------
894%define _target m32r-rtems4.11
895-------------------------------------------------------------
896
897Inline including another file with the +%include+ macro continues processing
898with the specified file returning to carry on from just after the include
899point.
900
901-------------------------------------------------------------
902%include rtems-4.11-base.bset
903-------------------------------------------------------------
904
905This includes the RTEMS 4.11 base set of defines and checks. The configuration
906paths as defined by +_configdir+ are scanned. The file extension is optional.
907
908You reference build set or package configuration files by placing the file name
909on a single line.
910
911-------------------------------------------------------------
912tools/rtems-binutils-2.22-1
913-------------------------------------------------------------
914
915The +_configdir+ path is scanned for +tools/rtems-binutils-2.22-1.bset+ or
916+tools/rtems-binutils-2.22-1.cfg+. Build set files take precedent over package
917configuration files. If +tools/rtems-binutils-2.22-1+ is a build set a new
918instance of the build set processor is created and if the file is a package
919configuration the package is built with the package builder. This all happens
920once the build set file has finished being scanned.
921
922Configuration Control
923~~~~~~~~~~~~~~~~~~~~~
924
925The RTEMS Souce Builder is designed to fit within most verification and
926validation processes. All of the RTEMS Source Builder is source code. The
927Python code is source and comes with a commercial friendly license. All
928configuration data is text and can be read or parsed with standard text based
929tools.
930
931File naming provides configuration management. A specific version of a package
932is captured in a specific set of configuration files. The top level
933configuration file referenced in a _build set_ or passed to the +sb-builder+
934command relates to a specific configuration of the package being built. For
935example the RTEMS configuration file +rtems-gcc-4.7.2-newlib-2.0.0-1.cfg+
936creates an RTEMS GCC and Newlib package where the GCC version is 4.7.2, the
937Newlib version is 2.0.0, plus any RTEMS specific patches that related to this
938version. The configuration defines the version numbers of the various parts
939that make up this package:
940
941-------------------------------------------------------------
942%define gcc_version    4.7.2
943%define newlib_version 2.0.0
944%define mpfr_version   3.0.1
945%define mpc_version    0.8.2
946%define gmp_version    5.0.5
947-------------------------------------------------------------
948
949The package build options, if there are any are also defined:
950
951-------------------------------------------------------------
952%define with_threads 1
953%define with_plugin  0
954%define with_iconv   1
955-------------------------------------------------------------
956
957The generic configuration may provide defaults in case options are not
958specified. The patches this specific version of the package requires can be
959included:
960
961-------------------------------------------------------------
962Patch0: gcc-4.7.2-rtems4.11-20121026.diff
963-------------------------------------------------------------
964
965Finally including the GCC 4.7 configuration script:
966
967-------------------------------------------------------------
968%include %{_configdir}/gcc-4.7-1.cfg
969-------------------------------------------------------------
970
971The +gcc-4.7-1.cfg+ file is a generic script to build a GCC 4.7 compiler with
972Newlib. It is not specific to RTEMS. A bare no operating system tool set can be
973built with this file.
974
975The +-1+ part of the file names is a revision. The GCC 4.7 script maybe revised
976to fix a problem and if this fix effects an existing script the file is copied
977and given a +-2+ revision number. Any dependent scripts referencing the earlier
978revision number will not be effected by the change. This locks down a specific
979configuration over time.
980
981Snapshot Testing
982~~~~~~~~~~~~~~~~
983
984Testing of release canidates and snapshots is important to those helping
985maintain tool sets. The RTEMS Source Builder helps by providing a simple and
986flexible way to use existing build sets and configuration without needing to
987change them or creating new temporary build sets and configurations.
988
989The process uses snapshot macro files loaded via the command line option
990`--macros`. These files provide macros that override the standard build set and
991configuration file macros.
992
993Lets consider testing a GCC 4.7 snapshot for RTEMS 4.11. Lets assume the
994current RTEMS 4.11 tools reference GCC 4.7.3 with a patch as the stable tool
995set. We want to use a recent snapshot with no patches. In the
996`rtems/config/snapshots` directoy create a file called `gcc-4.7-snapshot.mc`
997containing:
998
999-------------------------------------------------------------
1000[gcc-4.7-snapshot]
1001GCC_Version: none, override, '4.7-20130413'
1002Source0:     none, override, 'http://mirrors.kernel.org/sources.redhat.com/gcc/
1003snapshots/%{gcc_version}/gcc-%{gcc_version}.tar.bz2'
1004Patch0:      none, udefine,  ''
1005-------------------------------------------------------------
1006
1007In the standard configuration file `source-builder/config/gcc-4.7-1.cfg` the
1008map is selected with:
1009
1010-------------------------------------------------------------
1011#
1012# Select the GCC 4.7 Snapshot Macro Map
1013#
1014%select gcc-4.7-snapshot
1015-------------------------------------------------------------
1016
1017On the command line add `--macros=snapshots/gcc-4.7-snapshot.mc` and this
1018snapshot will be built. With careful use of the `--prefix` option you can
1019locate the tools in a specific directory and test them without needing to
1020effect your production environment.
1021
1022Scripting
1023~~~~~~~~~
1024
1025Configuration files specify how to build a package. Configuration files are
1026scripts and have a +.cfg+ file extension. The script format is based loosely on
1027the RPM spec file format however the use and purpose in this tool does not
1028compare with the functionality and therefore the important features of the spec
1029format RPM needs and uses.
1030
1031The script language is implemented in terms of macros. The built-in list is:
1032
1033[horizontal]
1034+%{}+:: Macro expansion with conditional logic.
1035+%()+:: Shell expansion.
1036+%prep+:: The source preparation shell commands.
1037+%build+:: The build shell commands.
1038+%install+:: The package install shell commands.
1039+%clean+:: The package clean shell commands.
1040+%include+:: Inline include another configuration file.
1041+%name+:: The name of the package.
1042+%summary+:: A brief package description. Useful when reporting about a build.
1043+%release+:: The package release. A number that is the release as built by this tool.
1044+%version+:: The package's version string.
1045+%buildarch+:: The build architecture.
1046+%setup+:: Setup a source package.
1047+%source+:: Define a source code package. This macro has a number appended.
1048+%patch+:: Define a patch. This macro has a is number appended.
1049+%echo+:: Print the following string as a message.
1050+%warning+:: Print the following string as a warning and continue.
1051+%error+:: Print the following string as an error and exit.
1052+%select+:: Select the macro map. If there is no map nothing is reported.
1053+%define+:: Define a macro. Macros cannot be redefined, you must first undefine it.
1054+%undefine+:: Undefine a macro.
1055+%if+:: Start a conditional logic block that ends with a +%endif+.
1056+%ifn+:: Inverted start of a conditional logic block.
1057+%ifarch+:: Test the architecture against the following string.
1058+%ifnarch+:: Inverted test of the architecture
1059+%ifos+:: Test the host operating system.
1060+%else+:: Start the _else_ conditional logic block.
1061+%endfi+:: End the conditional logic block.
1062+%bconf_with+:: Test the build condition _with_ setting. This is the +--with-*+
1063command line option.
1064+%bconf_without+:: Test the build condition _without_ setting. This is the
1065+--without-*+ command line option.
1066
1067Expanding
1068^^^^^^^^^
1069
1070A macro can be `%{string}` or the equivalent of `%string`. The following macro
1071expansions supported are:
1072
1073`%{string}`;;
1074Expand the 'string' replacing the entire macro text with the text in the table
1075for the entry 'string . For example if 'var' is 'foo' then `${var}` would
1076become `foo`.
1077
1078`%{expand: string}`;;
1079Expand the 'string' and then use it as a ``string'' to the macro expanding the
1080macro. For example if _foo_ is set to 'bar' and 'bar' is set to 'foobar' then
1081`%{expand:foo}` would result in `foobar`. Shell expansion can also be used.
1082
1083`%{with string}`;;
1084Expand the macro to '1' if the macro `with_`'string' is defined else expand to
1085_0_. Macros with the name `with_`'string' can be define with command line
1086arguments to the RTEMS Source Builder commands.
1087
1088`%{defined string}`;;
1089Expand the macro to '1' if a macro of name 'string' is defined else expand to '0'.
1090
1091`%{?string: expression}`;;
1092Expand the macro to 'expression' if a macro of name 'string' is defined else expand to `%{nil}`.
1093
1094`%{!?string: expression}`;;
1095Expand the macro to 'expression' if a macro of name 'string' is not defined. If
1096the macro is define expand to `%{nil}`.
1097
1098`%(expression)`;;
1099Expand the macro to the result of running the 'expression' in a host shell. It
1100is assumed this is a Unix type shell. For example `%(whoami)` will return your
1101user name and `%(date)` will return the current date string.
1102
1103%prep
1104^^^^^
1105
1106The +%prep+ macro starts a block that continues until the next block macro. The
1107_prep_ or preparation block defines the setup of the package's source and is a
1108mix of RTEMS Source Builder macros and shell scripting. The sequence is
1109typically +%setup+ macros for source, +%patch+ macros to patch the source
1110mixed with some shell commands to correct any source issues.  A +%prep+ section
1111starts with a +%setup+ command. This creates the package source top level
1112directory then is followed by the first source file.
1113
1114-------------------------------------------------------------
1115                     <1>       <2>
1116%setup -q -c -T -n %{name}-%{version}
1117%setup -q -T -D -n %{name}-%{version} -a0
1118-------------------------------------------------------------
1119
1120<1> The package's name.
1121<2> The version of the package.
1122
1123The source for a package is declared with the +%source*+ macro where +*+ is
1124a number. For example +%source0+ is the source 0 tar file and is defined with
1125something similar to this:
1126
1127-------------------------------------------------------------
1128Source0: http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2
1129-------------------------------------------------------------
1130
1131This URL is the primary location of the GNU GCC source code and the RTEMS
1132Source Builder can download the file from this location and by inspecting the
1133file extension use +bzip2+ decompression. When the +%prep+ section is processed
1134a check of the local +source+ directory is made to see if the file has already
1135been downloaded. If not found in the source cache directory the package is
1136downloaded from the URL. You can append other base URLs via the command line
1137option +--url+. This option accepts a comma delimited list of sites to try.
1138
1139You can combine the source macro with conditional logic to implement a default
1140that can be over-riden in the top level files. This lets you reuse a generic
1141build script with different sources. This happens if you have a private source
1142package with local modifications. The following example is taken from the
1143+gcc-4.8-1.cfg+ build script.
1144
1145-------------------------------------------------------------
1146%ifn %{defined Source0}
1147 Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
1148%endif
1149-------------------------------------------------------------
1150
1151You could optionally have a few source files that make up the package. For
1152example GNU's GCC was a few tar files for a while and it is now a single tar
1153file. Support for multiple source files can be conditionally implemented with
1154the following scripting:
1155
1156-------------------------------------------------------------
1157%{?source1:%setup -q -T -D -n %{name}-%{version} -a1}
1158-------------------------------------------------------------
1159
1160The +source1+ macro value is checked and if present the command string after
1161the +:+ is executed. It is common to see a number of these present allowing top
1162level configuration files including a base configuration the ability to define
1163a number of source packages.
1164
1165-------------------------------------------------------------
1166%{?source1:%setup -q -T -D -n %{name}-%{version} -a1}
1167%{?source2:%setup -q -T -D -n %{name}-%{version} -a2}
1168%{?source3:%setup -q -T -D -n %{name}-%{version} -a3}
1169-------------------------------------------------------------
1170
1171Patching also occurs during the preparation stage. Patches are handled in a
1172similar way to the source packages. Most patches are based around the top of
1173the source tree. This is an example of the patch scripting for the GCC 4.8
1174series of compilers:
1175
1176-------------------------------------------------------------
1177cd gcc-%{gcc_version} <1>
1178%{?patch0:%patch0 -p1} <2>
1179%{?patch1:%patch1 -p1}
1180%{?patch2:%patch2 -p1}
1181%{?patch3:%patch3 -p1}
1182%{?patch4:%patch4 -p1}
1183%{?patch5:%patch5 -p1}
1184%{?patch6:%patch6 -p1}
1185%{?patch7:%patch7 -p1}
1186%{?patch8:%patch8 -p1}
1187%{?patch9:%patch9 -p1}
1188cd .. <3>
1189-------------------------------------------------------------
1190
1191<1> Change from the top of the source tree into the package being patched's top
1192    directory.
1193<2> The conditional macro expansion checks if +%patch0+ is defined and if
1194    defined issues the +%patch0" macro giving +-p1+ to the patch command.
1195<3> Return back to the top of the source tree.
1196
1197%build
1198^^^^^^
1199
1200The +%build+ macro starts a block that continues until the next block
1201macro. The build block is a series of shell commands that execute to build the
1202package. It assumes all source code has been unpacked, patch and adjusted so
1203the build will succeed.
1204
1205The following is an example take from the GutHub STLink project:
1206
1207NOTE: STLink is a JTAG debugging device for the ST ARM family of processors.
1208
1209-------------------------------------------------------------
1210%build
1211  export PATH="%{_bindir}:${PATH}" <1>
1212
1213  cd texane-stlink-%{stlink_version} <2>
1214
1215  ./autogen.sh <3>
1216
1217%if "%{_build}" != "%{_host}"
1218  CFLAGS_FOR_BUILD="-g -O2 -Wall" \ <4>
1219%endif
1220  CPPFLAGS="-I $SB_TMPPREFIX/include/libusb-1.0" \ <5>
1221  CFLAGS="$SB_OPT_FLAGS" \
1222  LDFLAGS="-L $SB_TMPPREFIX/lib" \
1223  ./configure \ <6>
1224    --build=%{_build} --host=%{_host} \
1225    --verbose \
1226    --prefix=%{_prefix} --bindir=%{_bindir} \
1227    --exec-prefix=%{_exec_prefix} \
1228    --includedir=%{_includedir} --libdir=%{_libdir} \
1229    --mandir=%{_mandir} --infodir=%{_infodir}
1230
1231  %{__make} %{?_smp_mflags} all <7>
1232
1233  cd ..
1234-------------------------------------------------------------
1235
1236<1> Setup the PATH environment variable. This is not always needed.
1237<2> This package builds in the source tree so enter it.
1238<3> The package is actually checked directly out from the github project and so
1239    it needs its autoconf and automake files generated.
1240<4> Flags for a cross-compiled build.
1241<5> Various settings passed to configure to customise the build. In this
1242    example an include path is being set to the install point of _libusb_. This
1243    package requires _libusb_ is built before it.
1244<6> The +configure+ command. The RTEMS Source Builder provides all the needed
1245    paths as macro variables. You just need to provide them to +configure+.
1246<7> Running make. Do not use +make+ directly, use the RTEMS Source Builder's
1247    defined value. This value is specific to the host. A large number of
1248    packages need GNU make and on BSD systems this is +gmake+. You can
1249    optionally add the SMP flags if the packages build system can handle
1250    parallel building with multiple jobs. The +_smp_mflags+ value is
1251    automatically setup for SMP hosts to match the number of cores the host has.
1252
1253%install
1254^^^^^^^^
1255
1256The +%install+ macro starts a block that continues until the next block
1257macro. The install block is a series of shell commands that execute to install
1258the package. You can assume the package has build correctly when this block
1259starts executing.
1260
1261Never install the package to the actual _prefix_ the package was built
1262with. Always install to the RTEMS Source Builder's temporary path defined in
1263the macro variable +\__tmpdir+. The RTEMS Source Builder sets up a shell
1264environment variable called +SB_BUILD_ROOT+ as the standard install point. Most
1265packages support adding +DESTDIR=+ to the _make install_ command.
1266
1267Looking at the same example as in <<_build, %build>>:
1268
1269-------------------------------------------------------------
1270%install
1271  export PATH="%{_bindir}:${PATH}" <1>
1272  rm -rf $SB_BUILD_ROOT <2>
1273
1274  cd texane-stlink-%{stlink_version} <3>
1275  %{__make} DESTDIR=$SB_BUILD_ROOT install <4>
1276
1277  cd ..
1278-------------------------------------------------------------
1279
1280<1> Setup the PATH environment variable. This is not always needed.
1281<2> Clean any installed files. This make sure the install is just what
1282    the package installs and not any left over files from a broken build or
1283    install.
1284<3> Enter the build directory. In this example it just happens to be the source
1285    directory.
1286<4> Run +make install+ to install the package overriding the +DESTDIR+ make
1287    variable.
1288
1289%clean
1290^^^^^^
1291
1292The +%clean+ macro starts a block that continues until the next block
1293macro. The clean block is a series of shell commands that execute to clean up
1294after a package has been built and install. This macro is currenly not been
1295used because the RTEMS Source Builder automatically cleans up.
1296
1297%include
1298^^^^^^^^
1299
1300The +%include+ macro inline includes the specific file. The +\__confdir+
1301path is searched. Any relative path component of the include file is appended
1302to each part of the +\__configdir+. Adding an extension is optional as files
1303with +.bset+ and +.cfg+ are automatically searched for.
1304
1305Inline including means the file is processed as part of the configuration at
1306the point it is included. Parsing continues from the next line in the
1307configuration file that contains the +%include+ macro.
1308
1309Including files allow a kind of configuration file reuse. The outer
1310configuration files provide specific information such as package version
1311numbers and patches and then include a generic configuration script which
1312builds the package.
1313
1314-------------------------------------------------------------
1315%include %{_configdir}/gcc-4.7-1.cfg
1316-------------------------------------------------------------
1317
1318%name
1319^^^^^
1320
1321The name of the package being built. The name typically contains the components
1322of the package and their version number plus a revision number. For the GCC
1323with Newlib configuration the name is typically:
1324
1325-------------------------------------------------------------
1326Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
1327-------------------------------------------------------------
1328
1329%summary
1330^^^^^^^^
1331
1332The +%summary+ is a brief description of the package. It is useful when
1333reporting. This information is not capture in the package anywhere. For the GCC
1334with Newlib configuration the summary is typically:
1335
1336-------------------------------------------------------------
1337Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
1338-------------------------------------------------------------
1339
1340%release
1341^^^^^^^^
1342
1343The +%release+ is packaging number that allows revisions of a package to happen
1344where none package versions change. This value typically increases when the
1345configuration building the package changes.
1346
1347-------------------------------------------------------------
1348%define release 1
1349-------------------------------------------------------------
1350
1351%version
1352^^^^^^^^
1353
1354The +%version% macro sets the version the package. If the package is a single
1355component it tracks that component's version number. For example in the
1356_libusb_ configuration the +%version+ is the same as +%libusb_version+, however
1357in a GCC with Newlib configuration there is no single version number. In this
1358case the GCC version is used.
1359
1360-------------------------------------------------------------
1361Version: %{gcc_version}
1362-------------------------------------------------------------
1363
1364%buildarch
1365^^^^^^^^^^
1366
1367The +%buildarch+ macro is set to the architecture the package contains. This is
1368currently not used in the RTEMS Source Builder and may go away. This macro is
1369more important in a real packaging system where the package could end up on the
1370wrong architecture.
1371
1372%setup
1373^^^^^^
1374
1375The +%setup+ macro sets up the source code tree and is used in the +%prep+
1376section of the script. The options are:
1377
1378[horizontal]
1379*Switch*:: *Description*
1380+-n+:: The -n option is used to set the name of the software's build
1381directory. This is necessary only when the source archive unpacks into a
1382directory named other than +<name>-<version>+.
1383+-c+:: The -c option is used to direct %setup to create the top-level build
1384directory before unpacking the sources.
1385+-D+:: The -D option is used to direct %setup to not delete the build directory
1386prior to unpacking the sources. This option is used when more than one source
1387archive is to be unpacked into the build directory, normally with the +-b+ or
1388+-a+ options.
1389+-T+:: The -T option is used to direct %setup to not perform the default
1390unpacking of the source archive specified by the first Source: macro. It is used
1391with the +-a+ or +-b+ options.
1392+-b <n>+:: The -b option is used to direct %setup to unpack the source archive
1393specified on the nth Source: macro line before changing directory into the build
1394directory.
1395+-a <n>+:: The -a option is used to direct %setup to unpack the source archive
1396specified on the nth Source: macro line after changing directory into the build
1397directory.
1398
1399%source
1400^^^^^^^
1401
1402The +%source+ macro is numbered and defines a source tar file used in the
1403package. The +%setup+ macro references the packages defined here. A macro is
1404defined as:
1405
1406-------------------------------------------------------------
1407Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
1408-------------------------------------------------------------
1409
1410The setup script is:
1411
1412-------------------------------------------------------------
1413%setup -q -T -D -n %{name}-%{version} -a0
1414-------------------------------------------------------------
1415
1416The +-a0+ means use +%source0+.
1417
1418%patch
1419^^^^^^
1420
1421The +%patch+ macro is numbered and can define a patch and in the +%prep+
1422section applies the patch. To define a patch append a +:+ followed by the patch
1423filename:
1424
1425-------------------------------------------------------------
1426Patch0: gcc-4.7.2-rtems4.11-20121026.diff
1427-------------------------------------------------------------
1428
1429The +__patchdir+ path is search.
1430
1431Placing +%patch+ in the +%prep+ section will apply it with any trailing options
1432passed to the +patch+ command. This allows the +-p+ option to be passed to
1433strip any leading path components from the patch contents.
1434
1435-------------------------------------------------------------
1436%patch0 -p1
1437-------------------------------------------------------------
1438
1439You will typically see the patch conditionally used as:
1440
1441-------------------------------------------------------------
1442%{patch0:%patch0 -p1}
1443-------------------------------------------------------------
1444
1445In this case the patch will only be applied if it is defined.
1446
1447%echo
1448^^^^^
1449
1450The +%echo+ macro outputs the following string to stdout. This can also be used
1451as `%{echo: message}`.
1452
1453%warning
1454^^^^^^^^
1455
1456The +%warning+ macro outputs the following string as a warning. This can also
1457be used as `%{warning: message}`.
1458
1459%error
1460^^^^^^
1461
1462The +%error+ macro outputs the follow string as an error and exits the RTEMS
1463Source Builder. This can also be used as `%{error: message}`.
1464
1465%select
1466^^^^^^^
1467
1468The +%select+ macro selects the map specified. If there is no map no error or
1469warning is generated. Macro maps provide a simple way for a user to override
1470the settings is a configuration file without having to edit it. The changes are
1471recorded in the build report so can be traced.
1472
1473Configuration use different maps so macro overrides can target a specific
1474package.
1475
1476The default map is `global'.
1477
1478-------------------------------------------------------------
1479%select gcc-4.8-snapshot <1>
1480%define one_plus_one 2 <2>
1481-------------------------------------------------------------
1482
1483<1> The map switches to `gcc-4.8-snapshot`. Any overrides in this map will be
1484    used.
1485<2> Defining macros only updates the `global` map and not the selected map.
1486
1487%define
1488^^^^^^^
1489
1490The +%define+ macro defines a new macro or updates an existing one. If no value
1491is given it is assumed to be 1.
1492
1493-------------------------------------------------------------
1494%define foo bar
1495%define one_plus_one 2
1496%define one <1>
1497-------------------------------------------------------------
1498
1499<1> The macro _one_ is set to 1.
1500
1501%undefine
1502^^^^^^^^^
1503
1504The +%undefine+ macro removes a macro if it exists. Any further references to
1505it will result in an undefine macro error.
1506
1507%if
1508^^^
1509
1510The +%if+ macro starts a conditional logic block that can optionally have a
1511_else_ section. A test follows this macro and can have the following operators:
1512
1513[horizontal]
1514*Operator*:: *Description*
1515+%{}+:: Check the macro is set or _true_, ie non-zero.
1516+
1517-------------------------------------------------------------
1518%if ${foo}
1519 %warning The test passes, must not be empty or is non-zero
1520%else
1521 %error The test fails, must be empty or zero
1522%endif
1523-------------------------------------------------------------
1524+!+:: The _not_ operator inverts the test of the macro.
1525+
1526-------------------------------------------------------------
1527%if ! ${foo}
1528 %warning The test passes, must be empty or zero
1529%else
1530 %error The test fails, must not be empty or is non-zero
1531%endif
1532-------------------------------------------------------------
1533+==+:: The left hand size must equal the right hand side. For example:
1534+
1535-------------------------------------------------------------
1536%define one 1
1537%if ${one} == 1
1538 %warning The test passes
1539%else
1540 %error The test fails
1541%endif
1542-------------------------------------------------------------
1543+
1544You can also check to see if a macro is empty:
1545+
1546-------------------------------------------------------------
1547%if ${nothing} == %{nil}
1548 %warning The test passes
1549%else
1550 %error The test fails
1551%endif
1552-------------------------------------------------------------
1553+!=+:: The left hand size does not equal the right hand side. For example:
1554+
1555-------------------------------------------------------------
1556%define one 1
1557%if ${one} != 2
1558 %warning The test passes
1559%else
1560 %error The test fails
1561%endif
1562-------------------------------------------------------------
1563+
1564You can also check to see if something is set:
1565+
1566-------------------------------------------------------------
1567%if ${something} != %{nil}
1568 %warning The test passes
1569%else
1570 %error The test fails
1571%endif
1572-------------------------------------------------------------
1573+>+:: The left hand side is numerically greater than the right hand side.
1574+>=+:: The left hand side is numerically greater than or equal to the right
1575hand side.
1576+<+:: The left hand side is numerically less than the right hand side.
1577+\<=+:: The left hand side is numerically less than or equal to the right hand
1578side.
1579
1580%ifn
1581^^^^
1582
1583The +%ifn+ macro inverts the normal +%if+ logic. It avoids needing to provide
1584empty _if_ blocks followed by _else_ blocks. It is useful when checking if a
1585macro is defined:
1586
1587-------------------------------------------------------------
1588%ifn %{defined foo}
1589 %define foo bar
1590%endif
1591-------------------------------------------------------------
1592
1593%ifarch
1594^^^^^^^
1595
1596The +%ifarch+ is a short cut for "+%if %{\_arch} == i386+". Currently not used.
1597
1598%ifnarch
1599^^^^^^^^
1600
1601The +%ifnarch+ is a short cut for "+%if %{\_arch} != i386+". Currently not
1602used.
1603
1604%ifos
1605^^^^^
1606
1607The +%ifos+ is a short cut for "+%if %{\_os} != mingw32+". It allows
1608conditional support for various operating system differences when building
1609packages.
1610
1611%else
1612^^^^^
1613
1614The +%else+ macro starts the conditional _else_ block.
1615
1616%endfi
1617^^^^^^
1618
1619The +%endif+ macro ends a conditional logic block.
1620
1621%bconf_with
1622^^^^^^^^^^^
1623
1624The +%bconf_with+ macro provides a way to test if the user has passed a
1625specific option on the command line with the +--with-<label>+ option. This
1626option is only available with the +sb-builder+ command.
1627
1628%bconf_without
1629^^^^^^^^^^^^^^
1630
1631The +%bconf_without+ macro provides a way to test if the user has passed a
1632specific option on the command line with the +--without-<label>+ option. This
1633option is only available with the +sb-builder+ command.
1634
1635
1636Project Sets
1637------------
1638
1639The RTEMS Source Builder supports project configurations. Project
1640configurations can be public or private and can be contained in the RTEMS
1641Source Builder project if suitable, other projects they use the RTEM Source
1642Builder or privately on your local file system.
1643
1644The configuration file loader searches the macro +_configdir+ and by default
1645this is set to +%{\_topdir}/config:%{\_sbdir}/config+ where +_topdir+ is the
1646your current working direct, in other words the directory you invoke the RTEMS
1647Source Builder command in, and +_sbdir+ is the directory where the RTEMS Source
1648Builder command resides. Therefore the +config+ directory under each of these
1649is searched so all you need to do is create a +config+ in your project and add
1650your configuration files. They do not need to be under the RTEMS Source Builder
1651source tree. Public projects are included in the main RTEMS Source Builder such
1652as RTEMS.
1653
1654You can also add your own +patches+ directory next to your +config+ directory
1655as the +%patch+ command searches the +_patchdir+ macro variable and it is
1656by default set to +%{\_topdir}/patches:%{\_sbdir}/patches+.
1657
1658The +source-builder/config+ directory provides generic scripts for building
1659various tools. You can specialise these in your private configurations to make
1660use of them. If you add new generic configurations please contribute them back
1661to the project
1662
1663RTEMS Configurations
1664~~~~~~~~~~~~~~~~~~~~
1665
1666The RTEMS Configurations are grouped by RTEMS version. In RTEMS the tools are
1667specific to a specific version because of variations between Newlib and
1668RTEMS. Restructuring in RTEMS and Newlib sometimes moves _libc_ functionality
1669between these two parts and this makes existing tools incompatible with RTEMS.
1670
1671RTEMS allows architectures to have different tool versions and patches. The
1672large number of architectures RTEMS supports can make it difficult to get a
1673common stable version of all the packages. An architecture may require a recent
1674GCC because an existing bug has been fixed, however the more recent version may
1675have a bug in other architecture. Architecture specific patches should be
1676limited to the architecture it relates to. The patch may fix a problem on the
1677effect architecture however it could introduce a problem in another
1678architecture. Limit exposure limits any possible crosstalk between
1679architectures.
1680
1681RTEMS supports _stable_ and _unstable_. Stable configurations are fixed while
1682unstable configurations are supporting using snapshots of user macros and
1683reference release candidates or source extracted directly from version
1684control. The stable build sets are referenced as +<version>/rtems-<arch>+ and
1685include `autoconf` and `automake`.
1686
1687If you are building a released version of RTEMS the release RTEMS tar file will
1688be downloaded and built as part of the build process. If you are building a
1689tool set for use with the development branch of RTEMS, the development branch
1690will be cloned directly from the RTEMS GIT repository and built.
1691
1692When building RTEMS within the RTEMS Source Builder it needs a suitable working
1693`autoconf` and `automake`. These packages need to built and installed in their
1694prefix in order for them to work. The RTEMS Source Builder installs all
1695packages only after they have been built so if you host does not have a
1696recent enough version of `autoconf` and `automake` you first need to build them
1697and install them then build your tool set. The commands are:
1698
1699-------------------------------------------------------------
1700$ ../source-builder/sb-set-builder --log=l-4.11-at.txt \
1701   --prefix=$HOME/development/rtems/4.11 4.11/rtems-autotools
1702$ export PATH=~/development/rtems/4.11/bin:$PATH <1>
1703$ ../source-builder/sb-set-builder --log=l-4.11-sparc.txt \
1704   --prefix=$HOME/development/rtems/4.11 4.11/rtems-sparc
1705-------------------------------------------------------------
1706<1> Setting the path.
1707
1708TIP: If this is your first time building the tools and RTEMS it pays to add the
1709`--dry-run` option. This will run through all the configuration files and if
1710any checks fail you will see this quickly rather than waiting for until the
1711build fails a check.
1712
1713To build snapshots for testing purposes you use the available macro maps
1714passing them on the command line using the `--macros` option. For RTEMS these
1715are held in `config/snapshots` directory. The following builds _newlib_ from
1716CVS:
1717
1718-------------------------------------------------------------
1719$ ../source-builder/sb-set-builder --log=l-4.11-sparc.txt \
1720   --prefix=$HOME/development/rtems/4.11 \
1721   --macros=snapshots/newlib-head.mc \
1722   4.11/rtems-sparc
1723-------------------------------------------------------------
1724
1725and the following uses the version control heads for _binutils_, _gcc_,
1726_newlib_, _gdb_ and _RTEMS_:
1727
1728-------------------------------------------------------------
1729$ ../source-builder/sb-set-builder --log=l-heads-sparc.txt \
1730   --prefix=$HOME/development/rtems/4.11-head \
1731   --macros=snapshots/binutils-gcc-newlib-gdb-head.mc \
1732   4.11/rtems-sparc
1733-------------------------------------------------------------
1734
1735Commands
1736--------
1737
1738Checker (sb-check)
1739~~~~~~~~~~~~~~~~~~
1740
1741This commands checks your system is set up correctly. Most options are ignored.
1742
1743-------------------------------------------------------------
1744$ ../source-builder/sb-check --help
1745sb-check: [options] [args]
1746RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1747Options and arguments:
1748--force                : Force the build to proceed
1749--quiet                : Quiet output (not used)
1750--trace                : Trace the execution
1751--dry-run              : Do everything but actually run the build
1752--warn-all             : Generate warnings
1753--no-clean             : Do not clean up the build tree
1754--always-clean         : Always clean the build tree, even with an error
1755--jobs                 : Run with specified number of jobs, default: num CPUs.
1756--host                 : Set the host triplet
1757--build                : Set the build triplet
1758--target               : Set the target triplet
1759--prefix path          : Tools build prefix, ie where they are installed
1760--topdir path          : Top of the build tree, default is $PWD
1761--configdir path       : Path to the configuration directory, default: ./config
1762--builddir path        : Path to the build directory, default: ./build
1763--sourcedir path       : Path to the source directory, default: ./source
1764--tmppath path         : Path to the temp directory, default: ./tmp
1765--macros file[,[file]  : Macro format files to load after the defaults
1766--log file             : Log file where all build out is written too
1767--url url[,url]        : URL to look for source
1768--no-download          : Disable the source downloader
1769--targetcflags flags   : List of C flags for the target code
1770--targetcxxflags flags : List of C++ flags for the target code
1771--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1772--with-<label>         : Add the --with-<label> to the build
1773--without-<label>      : Add the --without-<label> to the build
1774--regression           : Set --no-install, --keep-going and --always-clean
1775$ ../source-builder/sb-check
1776RTEMS Source Builder - Check, v0.2.0
1777Environment is ok
1778-------------------------------------------------------------
1779
1780Defaults (sb-defaults)
1781~~~~~~~~~~~~~~~~~~~~~~
1782
1783This commands outputs and the default macros for your when given no
1784arguments. Most options are ignored.
1785
1786-------------------------------------------------------------
1787$ ../source-builder/sb-defaults --help
1788sb-defaults: [options] [args]
1789RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1790Options and arguments:
1791--force                : Force the build to proceed
1792--quiet                : Quiet output (not used)
1793--trace                : Trace the execution
1794--dry-run              : Do everything but actually run the build
1795--warn-all             : Generate warnings
1796--no-clean             : Do not clean up the build tree
1797--always-clean         : Always clean the build tree, even with an error
1798--jobs                 : Run with specified number of jobs, default: num CPUs.
1799--host                 : Set the host triplet
1800--build                : Set the build triplet
1801--target               : Set the target triplet
1802--prefix path          : Tools build prefix, ie where they are installed
1803--topdir path          : Top of the build tree, default is $PWD
1804--configdir path       : Path to the configuration directory, default: ./config
1805--builddir path        : Path to the build directory, default: ./build
1806--sourcedir path       : Path to the source directory, default: ./source
1807--tmppath path         : Path to the temp directory, default: ./tmp
1808--macros file[,[file]  : Macro format files to load after the defaults
1809--log file             : Log file where all build out is written too
1810--url url[,url]        : URL to look for source
1811--no-download          : Disable the source downloader
1812--targetcflags flags   : List of C flags for the target code
1813--targetcxxflags flags : List of C++ flags for the target code
1814--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1815--with-<label>         : Add the --with-<label> to the build
1816--without-<label>      : Add the --without-<label> to the build
1817--regression           : Set --no-install, --keep-going and --always-clean
1818-------------------------------------------------------------
1819
1820Set Builder (sb-set-builder)
1821~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1822
1823This command builds a set.
1824
1825-------------------------------------------------------------
1826$ ../source-builder/sb-set-builder --help
1827RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1828Options and arguments:
1829--force                : Force the build to proceed
1830--quiet                : Quiet output (not used)
1831--trace                : Trace the execution
1832--dry-run              : Do everything but actually run the build
1833--warn-all             : Generate warnings
1834--no-clean             : Do not clean up the build tree
1835--always-clean         : Always clean the build tree, even with an error
1836--regression           : Set --no-install, --keep-going and --always-clean
1837---jobs                 : Run with specified number of jobs, default: num CPUs.
1838--host                 : Set the host triplet
1839--build                : Set the build triplet
1840--target               : Set the target triplet
1841--prefix path          : Tools build prefix, ie where they are installed
1842--topdir path          : Top of the build tree, default is $PWD
1843--configdir path       : Path to the configuration directory, default: ./config
1844--builddir path        : Path to the build directory, default: ./build
1845--sourcedir path       : Path to the source directory, default: ./source
1846--tmppath path         : Path to the temp directory, default: ./tmp
1847--macros file[,[file]  : Macro format files to load after the defaults
1848--log file             : Log file where all build out is written too
1849--url url[,url]        : URL to look for source
1850--no-download          : Disable the source downloader
1851--no-install           : Do not install the packages to the prefix
1852--targetcflags flags   : List of C flags for the target code
1853--targetcxxflags flags : List of C++ flags for the target code
1854--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1855--with-<label>         : Add the --with-<label> to the build
1856--without-<label>      : Add the --without-<label> to the build
1857--mail-from            : Email address the report is from.
1858--mail-to              : Email address to send the email too.
1859--mail                 : Send email report or results.
1860--smtp-host            : SMTP host to send via.
1861--no-report            : Do not create a package report.
1862--report-format        : The report format (text, html, asciidoc).
1863--bset-tar-file        : Create a build set tar file
1864--pkg-tar-files        : Create package tar files
1865--list-bsets           : List available build sets
1866--list-configs         : List available configurations
1867--list-deps            : List the dependent files.
1868-------------------------------------------------------------
1869
1870.Arguments
1871The +[args]+ are a list build sets to build.
1872
1873.Options
1874+--force+;;
1875Force the build to proceed even if the host check fails. Typically this happens
1876if executable files are found in the path at a different location to the host
1877defaults.
1878+--trace+;;
1879Trace enable printing of debug information to stdout. It is really only of use
1880to RTEMS Source Builder's developers.
1881+--dry-run+;;
1882Do everything but actually run the build commands. This is useful when checking
1883a new configuration parses cleanly.
1884+--warn-all+;;
1885Generate warnings.
1886+--no-clean+;;
1887Do not clean up the build tree during the cleaning phase of the build. This
1888leaves the source and the build output on disk so you can make changes, or
1889amend or generate new patches. It also allows you to review configure type
1890output such as +config.log+.
1891+--always-clean+;;
1892Clean away the results of a build even if the build fails. This is normally
1893used with `--keep-going` when regression testing to see which build sets
1894fail to build. It keeps the disk usage down.
1895+--jobs+;;
1896Control the number of jobs make is given. The jobs can be 'none' for only 1
1897job, 'half' so the number of jobs is half the number of detected cores, a
1898fraction such as '0.25' so the number of jobs is a quarter of the number of
1899detected cores and a number such as '25' which forces the number of jobs to
1900that number.
1901+--host+;;
1902Set the host triplet value. Be careful with this option.
1903+--build+;;
1904Set the build triplet. Be careful with this option.
1905+--target+;;
1906Set the target triplet. Be careful with this option. This is useful if you have
1907a generic configuration script that can work for a range of architectures.
1908+--prefix path+;;
1909Tools build prefix, ie where they are installed.
1910+--topdir path+;;
1911Top of the build tree, that is the current directory you are in.
1912+--configdir path+;;
1913Path to the configuration directory. This overrides the built in defaults.
1914+--builddir path+;;
1915Path to the build directory. This overrides the default of +build+.
1916+--sourcedir path+;;
1917Path to the source directory. This overrides the default of +source+.
1918+--tmppath path+;;
1919Path to the temporary directory. This overrides the default of +tmp+.
1920+--macros files+;;
1921Macro files to load. The configuration directory path is searched.
1922+--log file+;;
1923Log all the output from the build process. The output is directed to +stdout+
1924if no log file is provided.
1925+--url url+;;
1926URL to look for source when downloading. This is can be comma separate list.
1927+--no-download+;;
1928Disable downloading of source and patches. If the source is not found an error
1929is raised.
1930+--targetcflags flags+;;
1931List of C flags for the target code. This allows for specific local
1932customisation when testing new variations.
1933+--targetcxxflags flags+;;
1934List of C++ flags for the target code. This allows for specific local
1935customisation when testing new variations.
1936+--libstdcxxflags flags+;;
1937List of C\++ flags to build the target libstdc++ code. This allows for specific
1938local customisation when testing new variations.
1939+--with-<label>+;;
1940Add the --with-<label> to the build. This can be tested for in a script with
1941the +%bconf_with+ macro.
1942+--without-<label>+;;
1943Add the --without-<label> to the build. This can be tested for in a script with
1944the +%bconf_without+ macro.
1945+--mail-from+;;
1946Set the from mail address if report mailing is enabled.
1947+--mail-to+;;
1948Set the to mail address if report mailing is enabled. The report is mailed to
1949this address.
1950+--mail+;;
1951Mail the build report to the mail to address.
1952+--smtp-host+;;
1953The SMTP host to use to send the email. The default is +localhost+.
1954+--no-report+;;
1955Do not create a report format.
1956+--report-format format+;;
1957The report format can be 'text' or 'html'. The default is 'html'.
1958+--keep-going+;;
1959Do not stop on error. This is useful if your build sets performs a large number
1960of testing related builds and there are errors.
1961+--always-clean+.
1962Always clean the build tree even with a failure.
1963+--no-install+;;
1964Do not install the packages to the prefix. Use this if you are only after the
1965tar files.
1966+--regression+;;
1967A convenience option which is the same as +--no-install+, +--keep-going+ and
1968+--bset-tar-file+;;
1969Create a build set tar file. This is a single tar file of all the packages in
1970the build set.
1971+--pkg-tar-files+;;
1972Create package tar files. A tar file will be created for each package built in
1973a build set.
1974+--list-bsets+;;
1975List available build sets.
1976+--list-configs+;;
1977List available configurations.
1978+--list-deps+;;
1979Print a list of dependent files used by a build set. Dependent files have a
1980'dep[?]' prefix where '?' is a number. The files are listed alphabetically.
1981
1982Set Builder (sb-builder)
1983~~~~~~~~~~~~~~~~~~~~~~~~
1984
1985This command builds a configuration as described in a configuration
1986file. Configuration files have the extension of +.cfg+.
1987
1988-------------------------------------------------------------
1989$ ./source-builder/sb-builder --help
1990sb-builder: [options] [args]
1991RTEMS Source Builder, an RTEMS Tools Project (c) 2012 Chris Johns
1992Options and arguments:
1993--force                : Force the build to proceed
1994--quiet                : Quiet output (not used)
1995--trace                : Trace the execution
1996--dry-run              : Do everything but actually run the build
1997--warn-all             : Generate warnings
1998--no-clean             : Do not clean up the build tree
1999--always-clean         : Always clean the build tree, even with an error
2000--jobs                 : Run with specified number of jobs, default: num CPUs.
2001--host                 : Set the host triplet
2002--build                : Set the build triplet
2003--target               : Set the target triplet
2004--prefix path          : Tools build prefix, ie where they are installed
2005--topdir path          : Top of the build tree, default is $PWD
2006--configdir path       : Path to the configuration directory, default: ./config
2007--builddir path        : Path to the build directory, default: ./build
2008--sourcedir path       : Path to the source directory, default: ./source
2009--tmppath path         : Path to the temp directory, default: ./tmp
2010--macros file[,[file]  : Macro format files to load after the defaults
2011--log file             : Log file where all build out is written too
2012--url url[,url]        : URL to look for source
2013--targetcflags flags   : List of C flags for the target code
2014--targetcxxflags flags : List of C++ flags for the target code
2015--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
2016--with-<label>         : Add the --with-<label> to the build
2017--without-<label>      : Add the --without-<label> to the build
2018--list-configs         : List available configurations
2019-------------------------------------------------------------
2020
2021Host Setups
2022-----------
2023
2024The host versions are listed. If a later version of the host operating system
2025exists it should unless listed.
2026
2027Linux
2028~~~~~
2029
2030A number of different Linux distrubutions are known to work. The following have
2031been tested and report as working.
2032
2033Archlinux
2034^^^^^^^^^
2035
2036The following packages are required on a fresh Archlinux 64bit installation:
2037
2038--------------------------------------------------------------
2039# pacman -S base-devel gdb xz unzip ncurses git zlib
2040--------------------------------------------------------------
2041
2042Archlinux, by default installs `texinfo-5` which is incompatible for building
2043GCC 4.7 tree. You will have to obtain `texinfo-legacy` from `AUR` and provide
2044a manual override.
2045
2046--------------------------------------------------------------
2047# pacman -R texinfo
2048$ yaourt -S texinfo-legacy
2049# ln -s /usr/bin/makeinfo-4.13a /usr/bin/makeinfo
2050--------------------------------------------------------------
2051
2052CentOS
2053^^^^^^
2054
2055The following packages are required on a minimal CentOS 6.3 64bit installation:
2056
2057-------------------------------------------------------------
2058# yum install autoconf automake binutils gcc gcc-c++ gdb make patch \
2059bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git
2060-------------------------------------------------------------
2061
2062The minimal CentOS distribution is a specific DVD that installs a minimal
2063system. If you use a full system some of these packages may have been
2064installed.
2065
2066Fedora
2067^^^^^^
2068
2069The RTEMS Source Builder has been tested on Fedora 18 64bit.
2070
2071Raspbian
2072^^^^^^^^
2073
2074The is the Debian distribution for the Raspberry Pi. The following packages are
2075required.
2076
2077-------------------------------------------------------------
2078$ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
2079texinfo unzip ncurses-dev python-dev git
2080-------------------------------------------------------------
2081
2082It is recommended you get Model B of the Pi with 512M of memory and to mount a
2083remote disk over the network. The tools can be build with a prefix under your
2084home directory as recommended and end up on the SD card.
2085
2086Ubuntu
2087^^^^^^
2088
2089The latest testing was with Ubuntu 12.10 64bit. A minimal installation was used
2090and the following packages installed.
2091
2092-------------------------------------------------------------
2093$ sudo apt-get build-dep binutils gcc g++ gdb unzip git
2094-------------------------------------------------------------
2095
2096FreeBSD
2097~~~~~~~
2098
2099The RTEMS Source Builder has been tested on FreeBSD 9.1 64bit.
2100
2101MacOS X
2102~~~~~~~
2103
2104The RTEMS Source Builder has been tested on Mountain Lion. You will need to
2105install the Xcode app using the _App Store_ tool, run Xcode and install the
2106Developers Tools package within Xcode.
2107
2108Windows
2109~~~~~~~
2110
2111Windows tool sets are supported creating native Windows executable. Native
2112Windows tools are built using a MinGW compiler and do not need any extra
2113libraries or emulation layer to run once built. The tools understand and use
2114standard Windows paths and integrate easly into Windows IDE environments. A
2115shell maybe needed to build other parts of your system however if your
2116development tools are all native Windows tool you can easly integrate these
2117tool sets.
2118
2119Building on Windows is a little more complicated because the Cygwin shell is
2120used rather than the MinGW MSYS shell. The MSYS shell is simpler because the
2121detected host triple is MinGW so the build is standard cross-compiler build.
2122The age of the MSYS code base, its stability and ability to to complete a build
2123with limitations such as the length of file names support make using MSYS
2124difficult therefore the more complex path of a Canadian cross-build using
2125Cygwin is supported.
2126
2127Install a recent Cygwin version using the Cygwin setup tool. Select and install
2128the groups and packages listed:
2129
2130.Cygwin Packages
2131[options="header,compact",width="50%",cols="20%,80%"]
2132|================================
2133|Group   |Package
2134|Archive |bsdtar
2135|        |unzip
2136|        |xz
2137|Devel   |autoconf
2138|        |autoconf2.1
2139|        |autoconf2.5
2140|        |automake
2141|        |binutils
2142|        |bison
2143|        |flex
2144|        |gcc4-core
2145|        |gcc4-g++
2146|        |git
2147|        |make
2148|        |mingw64-x86_64-binutils
2149|        |mingw64-x86_64-gcc-core
2150|        |mingw64-x86_64-g++
2151|        |mingw64-x86_64-runtime
2152|        |mingw64-x86_64-zlib
2153|        |zlib-devel
2154|MinGW   |mingw-zlib-devel
2155|Python  |python
2156|================================
2157
2158The setup tool will add a number of dependent package and it is ok to accept
2159them.
2160
2161I have found turning off Windows Defender improves performance if you have
2162another up to date virus detection tool installed and enabled. I used the
2163excellent `Process Hacker 2` tool to monitor the performance and I found the
2164Windows Defender service contributed a high load. In my case I had a 3rd party
2165virus tool installed so the Windows Defender service was not needed.
2166
2167A Canadian cross-compile (Cxc) is required on Cygwin because the host is Cygwin
2168therefore a traditional cross-compile will result in Cygiwn binaries. With a
2169Canadian cross-compile a Cygwin cross-compiler is built as well as the MinGW
2170RTEMS cross-compiler. The Cygwin cross-compiler is required to build the C
2171runtime for the RTEMS target because we are building under Cygiwn. The build
2172output for an RTEMS 4.10 ARM tool set is:
2173
2174-------------------------------------------------------------
2175chris@cygthing ~/development/rtems/src/rtems-source-builder/rtems
2176$ ../source-builder/sb-set-builder --log=l-arm.txt --prefix=$HOME/development/rtems/4.10 4.10/rtems-arm
2177RTEMS Source Builder - Set Builder, v0.2
2178Build Set: 4.10/rtems-arm
2179config: expat-2.1.0-1.cfg
2180package: expat-2.1.0-x86_64-w64-mingw32-1
2181building: expat-2.1.0-x86_64-w64-mingw32-1
2182reporting: expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-w64-mingw32-1.html
2183config: tools/rtems-binutils-2.20.1-1.cfg
2184package: arm-rtems4.10-binutils-2.20.1-1 <1>
2185building: arm-rtems4.10-binutils-2.20.1-1
2186package: (Cxc) arm-rtems4.10-binutils-2.20.1-1 <2>
2187building: (Cxc) arm-rtems4.10-binutils-2.20.1-1
2188reporting: tools/rtems-binutils-2.20.1-1.cfg ->
2189arm-rtems4.10-binutils-2.20.1-1.html
2190config: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg
2191package: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
2192building: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
2193package: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
2194building: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
2195reporting: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg ->
2196arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1.html
2197config: tools/rtems-gdb-7.3.1-1.cfg
2198package: arm-rtems4.10-gdb-7.3.1-1
2199building: arm-rtems4.10-gdb-7.3.1-1
2200reporting: tools/rtems-gdb-7.3.1-1.cfg -> arm-rtems4.10-gdb-7.3.1-1.html
2201config: tools/rtems-kernel-4.10.2.cfg
2202package: arm-rtems4.10-kernel-4.10.2-1
2203building: arm-rtems4.10-kernel-4.10.2-1
2204reporting: tools/rtems-kernel-4.10.2.cfg -> arm-rtems4.10-kernel-4.10.2-1.html
2205installing: expat-2.1.0-x86_64-w64-mingw32-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
2206installing: arm-rtems4.10-binutils-2.20.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10 <3>
2207installing: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
2208installing: arm-rtems4.10-gdb-7.3.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
2209installing: arm-rtems4.10-kernel-4.10.2-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
2210cleaning: expat-2.1.0-x86_64-w64-mingw32-1
2211cleaning: arm-rtems4.10-binutils-2.20.1-1
2212cleaning: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
2213cleaning: arm-rtems4.10-gdb-7.3.1-1
2214cleaning: arm-rtems4.10-kernel-4.10.2-1
2215Build Set: Time 10:09:42.810547 <4>
2216-------------------------------------------------------------
2217
2218<1> The Cygwin version of the ARM cross-binutils.
2219<2> The +(Cxc)+ indicates this is the MinGW build of the package.
2220<3> Only the MinGW version is installed.
2221<4> Cygwin is slow so please be patient. This time was on an AMD Athlon 64bit
2222    Dual Core 6000+ running at 3GHz with 4G RAM running Windows 7 64bit.
2223
2224CAUTION: Cygwin documents the 'Big List Of Dodgy Apps' or 'BLODA'. The link is
2225http://cygwin.com/faq/faq.using.html#faq.using.bloda and it is worth a
2226look. You will see a large number of common pieces of software found on Windows
2227systems that can cause problems. My testing has been performed with NOD32
2228running and I have seen some failures. The list is for all of Cygwin so I am
2229not sure which of the listed programs effect the RTEMS Source Biulder. The
2230following FAQ item talks about +fork+ failures and presents some technical
2231reasons they cannot be avoided in all cases. Cygwin and it's fork MSYS are
2232fantastic pieces of software in a difficult environment. I have found building
2233a single tool tends to work, building all at once is harder.
2234
2235
2236
2237Build Status By Host
2238~~~~~~~~~~~~~~~~~~~~
2239
2240This table lists the current build and testing status for reported hosts:
2241
2242[grid="rows",format="csv"]
2243[options="header",cols="<,<,<,<,<,<"]
2244|===========================
2245OS,Uname,4.9,4.10,4.11,Comments
2246include::host-results.csv[]
2247|===========================
2248
2249[NOTE]
2250==================================================================
2251Report any unlisted hosts as a patch.
2252==================================================================
2253
2254History
2255-------
2256
2257The RTEMS Source Builder is a stand alone tool based on another tool called the
2258'SpecBuilder'. The SpecBuilder was written for the RTEMS project to give me a
2259way to build tools on hosts that did not support RPMs. At the time the RTEMS
2260tools maintainer only used spec files to create various packages. This meant I
2261had either spec files, RPM files or SRPM files. The RPM and SPRM files where
2262useless because you needed an 'rpm' type tool to extract and manage them. There
2263are versions of 'rpm' for a number of non-RPM hosts however these proved to be
2264in various broken states and randomly maintained. The solution I settled on was
2265to use spec files so I wrote a Python based tool that parsed the spec file
2266format and allowed me to create a shell script I could run to build the
2267package. This approach proved successful and I was able to track the RPM
2268version of the RTEMS tools on a non-RPM host over a number of years. however
2269the SpecBuilder tool did not help me build tools or other packages not related
2270to the RTEMS project where there was no spec file I could use so I needed
2271another tool. Rather than start again I decided to take the parsing code for
2272the spec file format and build a new tool called the RTEMS Source Builder.
Note: See TracBrowser for help on using the repository browser.