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

4.104.114.9
Last change on this file since b30a539 was b30a539, checked in by Chris Johns <chrisj@…>, on Apr 23, 2013 at 7:31:20 AM

Fix the autotools prefix in the RTEMS example.

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