source: rtems-source-builder/doc/source-builder.txt @ 50da39a

4.104.114.95
Last change on this file since 50da39a was 50da39a, checked in by Chris Johns <chrisj@…>, on 03/08/13 at 02:58:48

Macro %define updates an existing macro.

Analysis of the current script shows a number of updates are happening
and this should be the default.

  • Property mode set to 100644
File size: 66.6 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.0, February 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* FreeBSD
36* MacOS (Mountain Lion)
37* Ubuntu
38* Centos
39* Fedora
40* Raspbian
41
42Windows support is being added how-ever there are issues with the Python
43threading used in the RTEMS Source Builder and the MinGW project's MSYS process
44handling of `make`.
45
46The RTEMS Source Builder has two types configuration data. The first is the
47'build set'. A _build set_ describes a collection of packages that define a set
48of tools you would use when developing software for RTEMS. For example the
49basic GNU tool set is binutils, gcc, and gdb and is the typical base suite of
50tools you need for an embedded cross-development type project. The second type
51of configuration data is the configuration files and they define how a package
52is built. Configuration files are scripts loosely based on the RPM spec file
53format and detail the steps needed to build a package. The steps are
54'preparation', 'building', and 'installing'. Scripts support macros, shell
55expansion, logic, includes plus many more features useful when build packages.
56
57The RTEMS Source Builder does not interact with any host package management
58systems. There is no automatic dependence checking between various packages you
59build or packages and software your host system you may have installed. We
60assume the build sets and configuration files you are using have been created
61by developers who do. If you have a problem please ask on the RTEMS Users
62mailing list.
63
64Quick Start
65-----------
66
67The quick start will show you how to build a set of RTEMS tools for a supported
68architecture.
69
70There is no need to become root or the administrator and we recommend you avoid
71doing this. You can build and install the tools anywhere on the host's file
72system you, as a standard user, have read and write access too. I recommend you
73use your home directory and work under the directory `~/development/rtems`. The
74examples shown here will do this.
75
76You can use the build _prefix_ to install and maintain different versions of
77the tools. Doing this lets you try a new set of tools while not touching your
78proven working production set of tools. Once you have proven the new tools are
79working rebuild with the 'production' prefix switching your development to them.
80
81I also suggest you keep your environment to the bare minimum, particularly the
82path variable. Using environment variables has been proven over the years to be
83difficult to manage in production systems.
84
85Setup
86~~~~~
87
88Setup a development work space:
89
90-------------------------------------------------------------
91$ cd
92$ mkdir -p development/rtems/src
93$ cd development/rtems/src
94-------------------------------------------------------------
95
96The RTEMS Source Builder is distributed as source. It is Python code so all you
97need to do is head over to the RTEMS GIT repository and clone the code directly
98from git:
99
100-------------------------------------------------------------
101$ git clone git://git.rtems.org/chrisj/rtems-source-builder.git
102$ cd rtems-source-builder
103-------------------------------------------------------------
104
105Checking
106~~~~~~~~
107
108The next step is to check if your host is set up correctly. The RTEMS Source
109Builder provides a tool to help:
110
111-------------------------------------------------------------
112$ source-builder/sb-check
113warning: exe: absolute exe found in path: (__objcopy) /usr/local/bin/objcopy <1>
114warning: exe: absolute exe found in path: (__objdump) /usr/local/bin/objdump
115error: exe: not found: (_xz) /usr/local/bin/xz <2>
116RTEMS Source Builder environment is not correctly set up
117$ source-builder/sb-check
118RTEMS Source Builder environment is ok <3>
119-------------------------------------------------------------
120
121<1> A tool is in the environment path but does not match the expected path.
122<2> The executable 'xz' is not found.
123<3> The host's environment is set up correct.
124
125The checking tool will output a list of executable files not found if problems
126are detected. Locate those executable files and install them. You may also be
127given a list of warnings about executable files not in the expected location
128how-ever the executable was located somewhere in your environment's path. You
129will need to check each tool to determine if this is an issue. An executable
130not in the standard location may indicate it is not the host operating system's
131standard tool. It maybe ok or it could be buggy, only you can determine this.
132
133The <<_host_setups,Host Setups>> section lists packages you should install for
134common host operating systems. It maybe worth checking if you have those
135installed.
136
137Build Sets
138~~~~~~~~~~
139
140The RTEMS tools can be built within the RTEMS Source Builder's source tree. We
141recommend you do this so lets change into the RTEMS directory in the RTEMS
142Source Builder package:
143
144-------------------------------------------------------------
145$ cd rtems
146-------------------------------------------------------------
147
148If you are unsure how to specify the build set for the architecture you wish to
149build ask the tool:
150
151-------------------------------------------------------------
152$ ../source-builder/sb-set-builder --list-bsets <1>
153RTEMS Source Builder - Set Builder, v0.1
154Examining: config <2>
155Examining: ../source-builder/config <2>
156    4.11/rtems-all.bset <3>
157    4.11/rtems-arm.bset <4>
158    4.11/rtems-avr.bset
159    4.11/rtems-bfin.bset
160    4.11/rtems-h8300.bset
161    4.11/rtems-m32c.bset
162    4.11/rtems-m32r.bset
163    4.11/rtems-m68k.bset
164    4.11/rtems-microblaze.bset
165    4.11/rtems-mips.bset
166    4.11/rtems-moxie.bset
167    4.11/rtems-nios2.bset
168    4.11/rtems-powerpc.bset
169    4.11/rtems-sh.bset
170    4.11/rtems-sparc.bset
171    gnu-tools-4.6.bset
172    rtems-4.11-base.bset
173    unstable/4.11/rtems-all.bset <5>
174    unstable/4.11/rtems-arm.bset
175    unstable/4.11/rtems-avr.bset
176    unstable/4.11/rtems-bfin.bset
177    unstable/4.11/rtems-h8300.bset
178    unstable/4.11/rtems-m32c.bset
179    unstable/4.11/rtems-m32r.bset
180    unstable/4.11/rtems-m68k.bset
181    unstable/4.11/rtems-microblaze.bset
182    unstable/4.11/rtems-mips.bset
183    unstable/4.11/rtems-moxie.bset
184    unstable/4.11/rtems-powerpc.bset
185    unstable/4.11/rtems-sh.bset
186    unstable/4.11/rtems-sparc.bset
187-------------------------------------------------------------
188<1> Only option needed is +--list-bsets+
189<2> The paths inspected. See <<X1,+_configdir+>> variable.
190<3> Build all the architectures.
191<4> The build set for the ARM architecture.
192<5> Unstable tool sets are used by RTEMS developers to test new tool sets. You
193    are welcome to try them but you must remember they are unstable, can change
194    at point in time and your application may not work. If you have an issue
195    with a production tool it may pay to try the unstable tool to see if it has
196    been resolved.
197
198Building
199~~~~~~~~
200
201In this quick start I will build a SPARC tool set.
202
203-------------------------------------------------------------
204$ ../source-builder/sb-set-builder --log=l-sparc.txt <1> \
205                --prefix=$HOME/development/rtems/4.11 <2> 4.11/rtems-sparc <3>
206Source Builder - Set Builder, v0.1
207Build Set: 4.11/rtems-sparc
208config: expat-2.1.0-1.cfg <4>
209package: expat-2.1.0-x86_64-freebsd9.1-1
210building: expat-2.1.0-x86_64-freebsd9.1-1
211installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <5>
212config: tools/rtems-binutils-2.22-1.cfg <6>
213package: sparc-rtems4.11-binutils-2.22-1
214building: sparc-rtems4.11-binutils-2.22-1
215installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
216config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg <7>
217package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
218building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
219installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
220config: tools/rtems-gdb-7.5.1-1.cfg <8>
221package: sparc-rtems4.11-gdb-7.5.1-1
222building: sparc-rtems4.11-gdb-7.5.1-1
223installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
224cleaning: expat-2.1.0-x86_64-freebsd9.1-1 <9>
225cleaning: sparc-rtems4.11-binutils-2.22-1
226cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
227cleaning: sparc-rtems4.11-gdb-7.5.1-1
228Build Set: Time 0:13:43.616383 <10>
229-------------------------------------------------------------
230
231<1> Providing a log file redirects the build output into a file. Logging the
232    build output provides a simple way to report problems.
233<2> The prefix is the location on your file system the tools are installed
234    into. Provide a prefix to a location you have read and write access. You
235    can use the prefix to install different versions or builds of tools. Just
236    use the path to the tools you want to use when building RTEMS.
237<3> The build set. This is the SPARC build set.
238<4> The SPARC build set first builds the expat library as is used in GDB. This
239    is the expat configuration used.
240<5> Installing the expat package to the install prefix.
241<6> The binutils build configuration.
242<7> The GCC and Newlib build configuration.
243<8> The GDB build configuration.
244<9> All the packages built are cleaned at the end. If the build fails all the
245    needed files are present. You may have to clean up by deleting the build
246    directory if the build fails.
247<10> The time to build the package. This lets you see how different host
248     hardware or configurations perform.
249
250Your SPARC RTEMS 4.11 tool set will be installed and ready to build RTEMS and
251RTEMS applications. When the build runs you will notice the tool fetch the
252source code from the internet. These files are cached in a directory called
253+source+. If you run the build again the cached files are used. This is what
254happened in the show example before.
255
256The installed tools:
257
258-------------------------------------------------------------
259$ ls $HOME/development/rtems/4.11
260bin         include     lib         libexec     share       sparc-rtems4.11
261$ ls $HOME/development/rtems/4.11/bin
262sparc-rtems4.11-addr2line       sparc-rtems4.11-cpp
263sparc-rtems4.11-gcc-ar          sparc-rtems4.11-gprof
264sparc-rtems4.11-objdump         sparc-rtems4.11-size
265sparc-rtems4.11-ar              sparc-rtems4.11-elfedit
266sparc-rtems4.11-gcc-nm          sparc-rtems4.11-ld
267sparc-rtems4.11-ranlib          sparc-rtems4.11-strings
268sparc-rtems4.11-as              sparc-rtems4.11-g++
269sparc-rtems4.11-gcc-ranlib      sparc-rtems4.11-ld.bfd
270sparc-rtems4.11-readelf         sparc-rtems4.11-strip
271sparc-rtems4.11-c++             sparc-rtems4.11-gcc
272sparc-rtems4.11-gcov            sparc-rtems4.11-nm
273sparc-rtems4.11-run             xmlwf
274sparc-rtems4.11-c++filt         sparc-rtems4.11-gcc-4.7.2
275sparc-rtems4.11-gdb             sparc-rtems4.11-objcopy
276sparc-rtems4.11-sis
277$ $HOME/development/rtems/4.11/bin/sparc-rtems4.11-gcc -v
278Using built-in specs.
279COLLECT_GCC=/home/chris/development/rtems/4.11/bin/sparc-rtems4.11-gcc
280COLLECT_LTO_WRAPPER=/usr/home/chris/development/rtems/4.11/bin/../ \
281libexec/gcc/sparc-rtems4.11/4.7.2/lto-wrapper
282Target: sparc-rtems4.11
283Configured with: ../gcc-4.7.2/configure
284--prefix=/home/chris/development/rtems/4.11
285--bindir=/home/chris/development/rtems/4.11/bin
286--exec_prefix=/home/chris/development/rtems/4.11
287--includedir=/home/chris/development/rtems/4.11/include
288--libdir=/home/chris/development/rtems/4.11/lib
289--libexecdir=/home/chris/development/rtems/4.11/libexec
290--mandir=/home/chris/development/rtems/4.11/share/man
291--infodir=/home/chris/development/rtems/4.11/share/info
292--datadir=/home/chris/development/rtems/4.11/share
293--build=x86_64-freebsd9.1 --host=x86_64-freebsd9.1 --target=sparc-rtems4.11
294--disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib
295--with-system-zlib --disable-nls --without-included-gettext
296--disable-win32-registry --enable-version-specific-runtime-libs --disable-lto
297--enable-threads --enable-plugin --enable-newlib-io-c99-formats
298--enable-newlib-iconv --enable-languages=c,c++
299Thread model: rtems
300gcc version 4.7.2 20120920 (RTEMS) (GCC)
301-------------------------------------------------------------
302
303Installing and Tar Files
304~~~~~~~~~~~~~~~~~~~~~~~~
305
306The RTEMS Source Builder can install the built packages directly and optionally it can
307create a build set tar file or a tar file per package built. The normal and
308default behaviour is to let the RTEMS Source Builder install the tools. The
309source will be downloaded, built, installed and cleaned up.
310
311The tar files are created with the full build prefix present. This can cause
312problems if you are installing on a host you do not have super user or
313administrator rights on if the prefix path references part you do not have
314write access t0o. You can use the +--strip-components+ option in tar if your
315tar file supports it to remove the parts you do not have write access too or
316you may need to unpack the tar file somewhere and copy the file tree from the
317level you have write access from. Embedding the full prefix path in the tar
318files lets you know what the prefix is.
319
320A build set tar file is created by adding `--bset-tar-file` option to the
321`sb-set-builder` command.
322
323-------------------------------------------------------------
324$ ../source-builder/sb-set-builder --log=l-sparc.txt \
325         --prefix=$HOME/development/rtems/4.11 \
326         --bset-tar-file <1> 4.11/rtems-sparc
327Source Builder - Set Builder, v0.1
328Build Set: 4.11/rtems-sparc
329config: expat-2.1.0-1.cfg
330package: expat-2.1.0-x86_64-freebsd9.1-1
331building: expat-2.1.0-x86_64-freebsd9.1-1
332installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <2>
333config: tools/rtems-binutils-2.22-1.cfg
334package: sparc-rtems4.11-binutils-2.22-1
335building: sparc-rtems4.11-binutils-2.22-1
336installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
337config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
338package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
339building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
340installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
341config: tools/rtems-gdb-7.5.1-1.cfg
342package: sparc-rtems4.11-gdb-7.5.1-1
343building: sparc-rtems4.11-gdb-7.5.1-1
344installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
345tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
346cleaning: expat-2.1.0-x86_64-freebsd9.1-1
347cleaning: sparc-rtems4.11-binutils-2.22-1
348cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
349cleaning: sparc-rtems4.11-gdb-7.5.1-1
350Build Set: Time 0:15:25.92873
351-------------------------------------------------------------
352
353<1> The option to create a build set tar file.
354<2> The installation still happens.
355<3> Creating the build set tar file.
356
357You can also suppress installing the files using the `--no-install` option to
358the `sb-set-builder` command.
359
360-------------------------------------------------------------
361$ ../source-builder/sb-set-builder --log=l-sparc.txt \
362            --prefix=$HOME/development/rtems/4.11 \
363            --bset-tar-file --no-install <1> 4.11/rtems-sparc
364Source Builder - Set Builder, v0.1
365Build Set: 4.11/rtems-sparc
366config: expat-2.1.0-1.cfg
367package: expat-2.1.0-x86_64-freebsd9.1-1
368building: expat-2.1.0-x86_64-freebsd9.1-1
369config: tools/rtems-binutils-2.22-1.cfg
370package: sparc-rtems4.11-binutils-2.22-1
371building: sparc-rtems4.11-binutils-2.22-1
372config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
373package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
374building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
375config: tools/rtems-gdb-7.5.1-1.cfg
376package: sparc-rtems4.11-gdb-7.5.1-1
377building: sparc-rtems4.11-gdb-7.5.1-1
378tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2 <2>
379cleaning: expat-2.1.0-x86_64-freebsd9.1-1
380cleaning: sparc-rtems4.11-binutils-2.22-1
381cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
382cleaning: sparc-rtems4.11-gdb-7.5.1-1
383Build Set: Time 0:14:11.721274
384$ ls tar
385rtems-4.11-sparc-rtems4.11-1.tar.bz2
386-------------------------------------------------------------
387
388<1> The option to supressing installing the packages.
389<2> Create the build set tar.
390
391A package tar file can be created by adding the +--pkg-tar-files+ to the
392+sb-set-builder+ command. This creates a tar file per package built in the
393build set.
394
395-------------------------------------------------------------
396$ ../source-builder/sb-set-builder --log=l-sparc.txt \
397            --prefix=$HOME/development/rtems/4.11 \
398            --bset-tar-file --pkg-tar-files <1> --no-install 4.11/rtems-sparc
399Source Builder - Set Builder, v0.1
400Build Set: 4.11/rtems-sparc
401config: expat-2.1.0-1.cfg
402package: expat-2.1.0-x86_64-freebsd9.1-1
403building: expat-2.1.0-x86_64-freebsd9.1-1
404config: tools/rtems-binutils-2.22-1.cfg
405package: sparc-rtems4.11-binutils-2.22-1
406building: sparc-rtems4.11-binutils-2.22-1
407config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
408package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
409building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
410config: tools/rtems-gdb-7.5.1-1.cfg
411package: sparc-rtems4.11-gdb-7.5.1-1
412building: sparc-rtems4.11-gdb-7.5.1-1
413tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2
414cleaning: expat-2.1.0-x86_64-freebsd9.1-1
415cleaning: sparc-rtems4.11-binutils-2.22-1
416cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
417cleaning: sparc-rtems4.11-gdb-7.5.1-1
418Build Set: Time 0:14:37.658460
419$ ls tar
420expat-2.1.0-x86_64-freebsd9.1-1.tar.bz2           sparc-rtems4.11-binutils-2.22-1.tar.bz2
421sparc-rtems4.11-gdb-7.5.1-1.tar.bz2 <2>           rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
422sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1.tar.bz2
423-------------------------------------------------------------
424
425<1> The option to create packages tar files.
426<2> The GDB package tar file.
427<3> The build set tar file. All the others in a single tar file.
428
429Why Build from Source ?
430-----------------------
431
432The RTEMS Source Builder is not a replacement for the binary install systems
433you have with commercial operating systems or open source operating system
434distributions. Those products and distributions are critically important and
435are the base that allows the Source Builder to work. The RTEMS Source Builder
436sits somewhere between you manually entering the commands to build a tool set
437and a tool such as +yum+ or +apt-get+ to install binary packages made
438specifically for your host operating system. Building manually or installing a
439binary package from a remote repository are valid and real alternatives while
440the Source Builder is attempting to provide a specific service of repeatably
441being able to build tool sets from source code.
442
443If you are developing a system or product that has a long shelf life or is used
444in a critical piece of infrastructure that has a long life cycle being able to
445build from source is important. It insulates the project from the fast ever
446changing world of the host development machines. If your tool set is binary and
447you have lost the ability to build it you have lost a degree of control and
448flexibility open source gives you. Fast moving host environments are
449fantastic. We have powerful multi-core computers with huge amounts of memory
450and state of the art operating systems to run on them how-ever the product or
451project you are part of may need to be maintained well past the life time of
452these host. Being able to build from source an important and critical part of
453this process because you can move to a newer host and create an equivalent tool
454set.
455
456Building from source provides you with control over the configuration of the
457package you are building. If all or the most important dependent parts are
458built from source you limit the exposure to host variations. For example the
459GNU C compiler (gcc) currently uses a number of 3rd party libraries internally
460(gmp, mpfr, etc). If your validated compiler generating code for your target
461processor is dynamically linked against the host's version of these libraries
462any change in the host's configuration may effect you. The changes the host's
463package management system makes may be perfectly reasonable in relation to the
464distribution being managed how-ever this may not extend to you and your
465tools. Building your tools from source and controlling the specific version of
466these dependent parts means you are not exposing yourself to unexpected and
467often difficult to resolve problems. On the other side you need to make sure
468your tools build and work with newer versions of the host operating
469system. Given the stability of standards based libraries like 'libc' and ever
470improving support for standard header file locations this task is becoming
471easier.
472
473The RTEMS Source Builder is designed to be audited and incorporated into a
474project's verification and validation process. If your project is developing
475critical applications that needs to be traced from source to executable code in
476the target, you need to also consider the tools and how to track them.
477
478If your IT department maintains all your computers and you do not have suitable
479rights to install binary packages, building from source lets you create your
480own tool set that you install under your home directory. Avoiding installing
481any extra packages as a super user is always helpful in maintaining a secure
482computing environment.
483
484Configuration
485-------------
486
487The RTEMS Source Builder has two types of configuration data:
488
489. Build Sets
490. Package Build Configurations
491
492By default these files can be located in two separate directories and
493searched. The first directory is +config+ in your current working directory
494(+_topdir+) and the second is +config+ located in the base directory of the
495RTEMS Source Builder command you run (+_sbdir+). The RTEMS directory +rtems+
496located at the top of the RTEMS Source Builder source code is an example of a
497specific build configuration directory. You can create custom or private build
498configurations and if you run the RTEMS Source Builder command from that
499directory your configurations will be used.
500
501[[X1]] The configuration search path is a macro variable and is reference as
502+%\{_configdir\}+. It's default is defined as:
503
504-------------------------------------------------------------
505_configdir          : dir      optional   %{_topdir}/config:%{_sbdir}/config <1>
506-------------------------------------------------------------
507
508<1> The +_topdir+ is the directory you run the command from and +_sbdir+ is the
509location of the RTEMS Source Builder command.
510
511Build set files have the file extension +.bset+ and the package build
512configuration files have the file extension of +.cfg+. The +sb-set-builder+
513command will search for _build sets_ and the +sb-builder+ commands works with
514package build configuration files.
515
516Both types of configuration files use the \'#' character as a comment
517character. Anything after this character on the line is ignored. There is no
518block comment.
519
520Macros and Defaults
521~~~~~~~~~~~~~~~~~~~
522
523The RTEMS Source Builder uses a table of _macros_ called the _defaults_. The
524values the _defaults_ are initialised to is dependent on your host. This lets
525the Source Builder handle differences in the hosts. Build set and configuration
526files can define new values extending the defaults. For example builds are
527given a release number. This is typically a single number at the end of the
528package name. For RTEMS this is set in the top level build set configuration
529file with:
530
531-------------------------------------------------------------
532%define release 1
533-------------------------------------------------------------
534
535Once defined if can be accessed in a build set or package configuration file
536with:
537
538-------------------------------------------------------------
539%{release}
540-------------------------------------------------------------
541
542The +sb-defaults+ command lists the defaults for your host. I will not include
543the output of this command becauses of its size.
544
545-------------------------------------------------------------
546$ ../source-builder/sb-defaults
547-------------------------------------------------------------
548
549A nested build set is given a separate copy of the defaults. Changes in one
550change set are not seen in other build sets. That same happens with
551configuration files unless inline includes are used.
552
553Build Set Files
554~~~~~~~~~~~~~~~
555
556Build set files lets you list the packages in the build set you are defining
557and have a file extension of +.bset+. Build sets can define macro variables,
558inline include other files and reference other build set or package
559configuration files.
560
561Defining macros is performed with the +%define+ macro:
562
563-------------------------------------------------------------
564%define _target m32r-rtems4.11
565-------------------------------------------------------------
566
567Inline including another file with the +%include+ macro continues processing
568with the specified file returning to carry on from just after the include
569point.
570
571-------------------------------------------------------------
572%include rtems-4.11-base.bset
573-------------------------------------------------------------
574
575This includes the RTEMS 4.11 base set of defines and checks. The configuration
576paths as defined by +_configdir+ are scanned. The file extension is optional.
577
578You reference build set or package configuration files by placing the file name
579on a single line.
580
581-------------------------------------------------------------
582tools/rtems-binutils-2.22-1
583-------------------------------------------------------------
584
585The +_configdir+ path is scanned for +tools/rtems-binutils-2.22-1.bset+ or
586+tools/rtems-binutils-2.22-1.cfg+. Build set files take precedent over package
587configuration files. If +tools/rtems-binutils-2.22-1+ is a build set a new
588instance of the build set processor is created and if the file is a package
589configuration the package is built with the package builder. This all happens
590once the build set file has finished being scanned.
591
592Configuration Control
593~~~~~~~~~~~~~~~~~~~~~
594
595The RTEMS Souce Builder is designed to fit within most verification and
596validation processes. All of the RTEMS Source Builder is source code. The
597Python code is source and comes with a commercial friendly license. All
598configuration data is text and can be read or parsed with standard text based
599tools.
600
601File naming provides configuration management. A specific version of a package
602is captured in a specific set of configuration files. The top level
603configuration file referenced in a _build set_ or passed to the +sb-builder+
604command relates to a specific configuration of the package being built. For
605example the RTEMS configuration file +rtems-gcc-4.7.2-newlib-2.0.0-1.cfg+
606creates an RTEMS GCC and Newlib package where the GCC version is 4.7.2, the
607Newlib version is 2.0.0, plus any RTEMS specific patches that related to this
608version. The configuration defines the version numbers of the various parts
609that make up this package:
610
611-------------------------------------------------------------
612%define gcc_version    4.7.2
613%define newlib_version 2.0.0
614%define mpfr_version   3.0.1
615%define mpc_version    0.8.2
616%define gmp_version    5.0.5
617-------------------------------------------------------------
618
619The package build options, if there are any are also defined:
620
621-------------------------------------------------------------
622%define with_threads 1
623%define with_plugin  0
624%define with_iconv   1
625-------------------------------------------------------------
626
627The generic configuration may provide defaults in case options are not
628specified. The patches this specific version of the package requires can be
629included:
630
631-------------------------------------------------------------
632Patch0: gcc-4.7.2-rtems4.11-20121026.diff
633-------------------------------------------------------------
634
635Finally including the GCC 4.7 configuration script:
636
637-------------------------------------------------------------
638%include %{_configdir}/gcc-4.7-1.cfg
639-------------------------------------------------------------
640
641The +gcc-4.7-1.cfg+ file is a generic script to build a GCC 4.7 compiler with
642Newlib. It is not specific to RTEMS. A bare no operating system tool set can be
643built with this file.
644
645The +-1+ part of the file names is a revision. The GCC 4.7 script maybe revised
646to fix a problem and if this fix effects an existing script the file is copied
647and given a +-2+ revision number. Any dependent scripts referencing the earlier
648revision number will not be effected by the change. This locks down a specific
649configuration over time.
650
651Scripting
652~~~~~~~~~
653
654Configuration files specify how to build a package. Configuration files are
655scripts and have a +.cfg+ file extension. The script format is based loosely on
656the RPM spec file format how-ever the use and purpose in this tool does not
657compare with the functionality and therefore the important features of the spec
658format RPM needs and uses.
659
660The script language is implemented in terms of macros. The built-in list is:
661
662[horizontal]
663+%{}+:: Macro expansion with conditional logic.
664+%()+:: Shell expansion.
665+%prep+:: The source preparation shell commands.
666+%build+:: The build shell commands.
667+%install+:: The package install shell commands.
668+%clean+:: The package clean shell commands.
669+%include+:: Inline include another configuration file.
670+%name+:: The name of the package.
671+%summary+:: A brief package description. Useful when reporting about a build.
672+%release+:: The package release. A number that is the release as built by this tool.
673+%version+:: The package's version string.
674+%buildarch+:: The build architecture.
675+%setup+:: Setup a source package.
676+%source+:: Define a source code package. This macro has a number appended.
677+%patch+:: Define a patch. This macro has a is number appended.
678+%echo+:: Print the following string as a message.
679+%warning+:: Print the following string as a warning and continue.
680+%error+:: Print the following string as an error and exit.
681+%define+:: Define a macro. Macros cannot be redefined, you must first undefine it.
682+%undefine+:: Undefine a macro.
683+%if+:: Start a conditional logic block that ends with a +%endif+.
684+%ifn+:: Inverted start of a conditional logic block.
685+%ifarch+:: Test the architecture against the following string.
686+%ifnarch+:: Inverted test of the architecture
687+%ifos+:: Test the host operating system.
688+%else+:: Start the _else_ conditional logic block.
689+%endfi+:: End the conditional logic block.
690+%bconf_with+:: Test the build condition _with_ setting. This is the +--with-*+
691command line option.
692+%bconf_without+:: Test the build condition _without_ setting. This is the
693+--without-*+ command line option.
694
695Expanding
696^^^^^^^^^
697
698A macro can be `%{string}` or the equivalent of `%string`. The following macro
699expansions supported are:
700
701`%{string}`;;
702Expand the 'string' replacing the entire macro text with the text in the table
703for the entry 'string . For example if 'var' is 'foo' then `${var}` would
704become `foo`.
705
706`%{expand: string}`;;
707Expand the 'string' and then use it as a ``string'' to the macro expanding the
708macro. For example if _foo_ is set to 'bar' and 'bar' is set to 'foovar' then
709`%{expand:foo}` would result in `foobar`. Shell expansion can also be used.
710
711`%{with string}`;;
712Expand the macro to '1' if the macro `with_`'string' is defined else expand to
713_0_. Macros with the name `with_`'string' can be define with command line
714arguments to the RTEMS Source Builder commands.
715
716`%{defined string}`;;
717Expand the macro to '1' if a macro of name 'string' is defined else expand to '0'.
718
719`%{?string: expression}`;;
720Expand the macro to 'expression' if a macro of name 'string' is defined else expand to `%{nil}`.
721
722`%{!?string: expression}`;;
723Expand the macro to 'expression' if a macro of name 'string' is not defined. If
724the macro is define expand to `%{nil}`.
725
726`%(expression)`;;
727Expand the macro to the result of running the 'expression' in a host shell. It
728is assumed this is a Unix type shell. For example `%(whoami)` will return your
729user name and `%(date)` will return the current date string.
730
731%prep
732^^^^^
733
734The +%prep+ macro starts a block that continues until the next block macro. The
735_prep_ or preparation block defines the setup of the package's source and is a
736mix of RTEMS Source Builder macros and shell scripting. The sequence is
737typically +%setup+ macros for source, +%patch+ macros to patch the source
738mixed with some shell commands to correct any source issues.  A +%prep+ section
739starts with a +%setup+ command. This creates the package source top level
740directory then is followed by the first source file.
741
742-------------------------------------------------------------
743                     <1>       <2>
744%setup -q -c -T -n %{name}-%{version}
745%setup -q -T -D -n %{name}-%{version} -a0
746-------------------------------------------------------------
747
748<1> The package's name.
749<2> The version of the package.
750
751The source for a package is declared with the +%source*+ macro where +*+ is
752a number. For example +%source0+ is the source 0 tar file and is defined with
753something similar to this:
754
755-------------------------------------------------------------
756Source0: http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2
757-------------------------------------------------------------
758
759This URL is the primary location of the GNU GCC source code and the RTEMS
760Source Builder can download the file from this location and by inspecting the
761file extension use +bzip2+ decompression. When the +%prep+ section is processed
762a check of the local +source+ directory is made to see if the file has already
763been downloaded. If not found in the source cache directory the package is
764downloaded from the URL. You can append other base URLs via the command line
765option +--url+. This option accepts a comma delimited list of sites to try.
766
767You can combine the source macro with conditional logic to implement a default
768that can be over-riden in the top level files. This lets you reuse a generic
769build script with different sources. This happens if you have a private source
770package with local modifications. The following example is taken from the
771+gcc-4.8-1.cfg+ build script.
772
773-------------------------------------------------------------
774%ifn %{defined Source0}
775 Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
776 VersionContro0: git clone git://gcc.gnu.org/git/gcc.git <1>
777%endif
778-------------------------------------------------------------
779
780<1> The version control macro is currently not implemented.
781
782You could optionally have a few source files that make up the package. For
783example GNU's GCC was a few tar files for a while and it is now a single tar
784file. Support for multiple source files can be conditionally implemented with
785the following scripting:
786
787-------------------------------------------------------------
788%{?source1:%setup -q -T -D -n %{name}-%{version} -a1}
789-------------------------------------------------------------
790
791The +source1+ macro value is checked and if present the command string after
792the +:+ is executed. It is common to see a number of these present allowing top
793level configuration files including a base configuration the ability to define
794a number of source packages.
795
796-------------------------------------------------------------
797%{?source1:%setup -q -T -D -n %{name}-%{version} -a1}
798%{?source2:%setup -q -T -D -n %{name}-%{version} -a2}
799%{?source3:%setup -q -T -D -n %{name}-%{version} -a3}
800-------------------------------------------------------------
801
802Patching also occurs during the preparation stage. Patches are handled in a
803similar way to the source packages. Most patches are based around the top of
804the source tree. This is an example of the patch scripting for the GCC 4.8
805series of compilers:
806
807-------------------------------------------------------------
808cd gcc-%{gcc_version} <1>
809%{?patch0:%patch0 -p1} <2>
810%{?patch1:%patch1 -p1}
811%{?patch2:%patch2 -p1}
812%{?patch3:%patch3 -p1}
813%{?patch4:%patch4 -p1}
814%{?patch5:%patch5 -p1}
815%{?patch6:%patch6 -p1}
816%{?patch7:%patch7 -p1}
817%{?patch8:%patch8 -p1}
818%{?patch9:%patch9 -p1}
819cd .. <3>
820-------------------------------------------------------------
821
822<1> Change from the top of the source tree into the package being patched's top
823    directory.
824<2> The conditional macro expansion checks if +%patch0+ is defined and if
825    defined issues the +%patch0" macro giving +-p1+ to the patch command.
826<3> Return back to the top of the source tree.
827
828%build
829^^^^^^
830
831The +%build+ macro starts a block that continues until the next block
832macro. The build block is a series of shell commands that execute to build the
833package. It assumes all source code has been unpacked, patch and adjusted so
834the build will succeed.
835
836The following is an example take from the GutHub STLink project:
837
838NOTE: STLink is a JTAG debugging device for the ST ARM family of processors.
839
840-------------------------------------------------------------
841%build
842  export PATH="%{_bindir}:${PATH}" <1>
843
844  cd texane-stlink-%{stlink_version} <2>
845
846  ./autogen.sh <3>
847
848%if "%{_build}" != "%{_host}"
849  CFLAGS_FOR_BUILD="-g -O2 -Wall" \ <4>
850%endif
851  CPPFLAGS="-I $SB_TMPPREFIX/include/libusb-1.0" \ <5>
852  CFLAGS="$SB_OPT_FLAGS" \
853  LDFLAGS="-L $SB_TMPPREFIX/lib" \
854  ./configure \ <6>
855    --build=%{_build} --host=%{_host} \
856    --verbose \
857    --prefix=%{_prefix} --bindir=%{_bindir} \
858    --exec-prefix=%{_exec_prefix} \
859    --includedir=%{_includedir} --libdir=%{_libdir} \
860    --mandir=%{_mandir} --infodir=%{_infodir}
861
862  %{__make} %{?_smp_mflags} all <7>
863
864  cd ..
865-------------------------------------------------------------
866
867<1> Setup the PATH environment variable. This is not always needed.
868<2> This package builds in the source tree so enter it.
869<3> The package is actually checked directly out from the github project and so
870    it needs its autoconf and automake files generated.
871<4> Flags for a cross-compiled build.
872<5> Various settings passed to configure to customise the build. In this
873    example an include path is being set to the install point of _libusb_. This
874    package requires _libusb_ is built before it.
875<6> The +configure+ command. The RTEMS Source Builder provides all the needed
876    paths as macro variables. You just need to provide them to +configure+.
877<7> Running make. Do not use +make+ directly, use the RTEMS Source Builder's
878    defined value. This value is specific to the host. A large number of
879    packages need GNU make and on BSD systems this is +gmake+. You can
880    optionally add the SMP flags if the packages build system can handle
881    parallel building with multiple jobs. The +_smp_mflags+ value is
882    automatically setup for SMP hosts to match the number of cores the host has.
883
884%install
885^^^^^^^^
886
887The +%install+ macro starts a block that continues until the next block
888macro. The install block is a series of shell commands that execute to install
889the package. You can assume the package has build correctly when this block
890starts executing.
891
892Never install the package to the actual _prefix_ the package was built
893with. Always install to the RTEMS Source Builder's temporary path defined in
894the macro variable +\__tmpdir+. The RTEMS Source Builder sets up a shell
895environment variable called +SB_BUILD_ROOT+ as the standard install point. Most
896packages support adding +DESTDIR=+ to the _make install_ command.
897
898Looking at the same example as in <<_build, %build>>:
899
900-------------------------------------------------------------
901%install
902  export PATH="%{_bindir}:${PATH}" <1>
903  rm -rf $SB_BUILD_ROOT <2>
904
905  cd texane-stlink-%{stlink_version} <3>
906  %{__make} DESTDIR=$SB_BUILD_ROOT install <4>
907
908  cd ..
909-------------------------------------------------------------
910
911<1> Setup the PATH environment variable. This is not always needed.
912<2> Clean any installed files. This make sure the install is just what
913    the package installs and not any left over files from a broken build or
914    install.
915<3> Enter the build directory. In this example it just happens to be the source
916    directory.
917<4> Run +make install+ to install the package overriding the +DESTDIR+ make
918    variable.
919
920%clean
921^^^^^^
922
923The +%clean+ macro starts a block that continues until the next block
924macro. The clean block is a series of shell commands that execute to clean up
925after a package has been built and install. This macro is currenly not been
926used because the RTEMS Source Builder automatically cleans up.
927
928%include
929^^^^^^^^
930
931The +%include+ macro inline includes the specific file. The +\__confdir+
932path is searched. Any relative path component of the include file is appended
933to each part of the +\__configdir+. Adding an extension is optional as files
934with +.bset+ and +.cfg+ are automatically searched for.
935
936Inline including means the file is processed as part of the configuration at
937the point it is included. Parsing continues from the next line in the
938configuration file that contains the +%include+ macro.
939
940Including files allow a kind of configuration file reuse. The outer
941configuration files provide specific information such as package version
942numbers and patches and then include a generic configuration script which
943builds the package.
944
945-------------------------------------------------------------
946%include %{_configdir}/gcc-4.7-1.cfg
947-------------------------------------------------------------
948
949%name
950^^^^^
951
952The name of the package being built. The name typically contains the components
953of the package and their version number plus a revision number. For the GCC
954with Newlib configuration the name is typically:
955
956-------------------------------------------------------------
957Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
958-------------------------------------------------------------
959
960%summary
961^^^^^^^^
962
963The +%summary+ is a brief description of the package. It is useful when
964reporting. This information is not capture in the package anywhere. For the GCC
965with Newlib configuration the summary is typically:
966
967-------------------------------------------------------------
968Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
969-------------------------------------------------------------
970
971%release
972^^^^^^^^
973
974The +%release+ is packaging number that allows revisions of a package to happen
975where none package versions change. This value typically increases when the
976configuration building the package changes.
977
978-------------------------------------------------------------
979%define release 1
980-------------------------------------------------------------
981
982%version
983^^^^^^^^
984
985The +%version% macro sets the version the package. If the package is a single
986component it tracks that component's version number. For example in the
987_libusb_ configuration the +%version+ is the same as +%libusb_version+,
988how-ever in a GCC with Newlib configuration there is no single version
989number. In this case the GCC version is used.
990
991-------------------------------------------------------------
992Version: %{gcc_version}
993-------------------------------------------------------------
994
995%buildarch
996^^^^^^^^^^
997
998The +%buildarch+ macro is set to the architecture the package contains. This is
999currently not used in the RTEMS Source Builder and may go away. This macro is
1000more important in a real packaging system where the package could end up on the
1001wrong architecture.
1002
1003%setup
1004^^^^^^
1005
1006The +%setup+ macro sets up the source code tree and is used in the +%prep+
1007section of the script. The options are:
1008
1009[horizontal]
1010*Switch*:: *Description*
1011+-n+:: The -n option is used to set the name of the software's build
1012directory. This is necessary only when the source archive unpacks into a
1013directory named other than +<name>-<version>+.
1014+-c+:: The -c option is used to direct %setup to create the top-level build
1015directory before unpacking the sources.
1016+-D+:: The -D option is used to direct %setup to not delete the build directory
1017prior to unpacking the sources. This option is used when more than one source
1018archive is to be unpacked into the build directory, normally with the +-b+ or
1019+-a+ options.
1020+-T+:: The -T option is used to direct %setup to not perform the default
1021unpacking of the source archive specified by the first Source: macro. It is used
1022with the +-a+ or +-b+ options.
1023+-b <n>+:: The -b option is used to direct %setup to unpack the source archive
1024specified on the nth Source: macro line before changing directory into the build
1025directory.
1026+-a <n>+:: The -a option is used to direct %setup to unpack the source archive
1027specified on the nth Source: macro line after changing directory into the build
1028directory.
1029
1030%source
1031^^^^^^^
1032
1033The +%source+ macro is numbered and defines a source tar file used in the
1034package. The +%setup+ macro references the packages defined here. A macro is
1035defined as:
1036
1037-------------------------------------------------------------
1038Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
1039-------------------------------------------------------------
1040
1041The setup script is:
1042
1043-------------------------------------------------------------
1044%setup -q -T -D -n %{name}-%{version} -a0
1045-------------------------------------------------------------
1046
1047The +-a0+ means use +%source0+.
1048
1049%patch
1050^^^^^^
1051
1052The +%patch+ macro is numbered and can define a patch and in the +%prep+
1053section applies the patch. To define a patch append a +:+ followed by the patch
1054filename:
1055
1056-------------------------------------------------------------
1057Patch0: gcc-4.7.2-rtems4.11-20121026.diff
1058-------------------------------------------------------------
1059
1060The +__patchdir+ path is search.
1061
1062Placing +%patch+ in the +%prep+ section will apply it with any trailing options
1063passed to the +patch+ command. This allows the +-p+ option to be passed to
1064strip any leading path components from the patch contents.
1065
1066-------------------------------------------------------------
1067%patch0 -p1
1068-------------------------------------------------------------
1069
1070You will typically see the patch conditionally used as:
1071
1072-------------------------------------------------------------
1073%{patch0:%patch0 -p1}
1074-------------------------------------------------------------
1075
1076In this case the patch will only be applied if it is defined.
1077
1078%echo
1079^^^^^
1080
1081The +%echo+ macro outputs the following string to stdout. This can also be used
1082as `%{echo: message}`.
1083
1084%warning
1085^^^^^^^^
1086
1087The +%warning+ macro outputs the following string as a warning. This can also
1088be used as `%{warning: message}`.
1089
1090%error
1091^^^^^^
1092
1093The +%error+ macro outputs the follow string as an error and exits the RTEMS
1094Source Builder. This can also be used as `%{error: message}`.
1095
1096%define
1097^^^^^^^
1098
1099The +%define+ macro defines a new macro or updates an existing one. If no value
1100is given it is assumed to be 1.
1101
1102-------------------------------------------------------------
1103%define foo bar
1104%define one_plus_one 2
1105%define one <1>
1106-------------------------------------------------------------
1107
1108<1> The macro _one_ is set to 1.
1109
1110%undefine
1111^^^^^^^^^
1112
1113The +%undefine+ macro removes a macro if it exists. Any further references to
1114it will result in an undefine macro error.
1115
1116%if
1117^^^
1118
1119The +%if+ macro starts a conditional logic block that can optionally have a
1120_else_ section. A test follows this macro and can have the following operators:
1121
1122[horizontal]
1123*Operator*:: *Description*
1124+%{}+:: Check the macro is set or _true_, ie non-zero.
1125+
1126-------------------------------------------------------------
1127%if ${foo}
1128 %warning The test passes, must not be empty or is non-zero
1129%else
1130 %error The test fails, must be empty or zero
1131%endif
1132-------------------------------------------------------------
1133+!+:: The _not_ operator inverts the test of the macro.
1134+
1135-------------------------------------------------------------
1136%if ! ${foo}
1137 %warning The test passes, must be empty or zero
1138%else
1139 %error The test fails, must not be empty or is non-zero
1140%endif
1141-------------------------------------------------------------
1142+==+:: The left hand size must equal the right hand side. For example:
1143+
1144-------------------------------------------------------------
1145%define one 1
1146%if ${one} == 1
1147 %warning The test passes
1148%else
1149 %error The test fails
1150%endif
1151-------------------------------------------------------------
1152+
1153You can also check to see if a macro is empty:
1154+
1155-------------------------------------------------------------
1156%if ${nothing} == %{nil}
1157 %warning The test passes
1158%else
1159 %error The test fails
1160%endif
1161-------------------------------------------------------------
1162+!=+:: The left hand size does not equal the right hand side. For example:
1163+
1164-------------------------------------------------------------
1165%define one 1
1166%if ${one} != 2
1167 %warning The test passes
1168%else
1169 %error The test fails
1170%endif
1171-------------------------------------------------------------
1172+
1173You can also check to see if something is set:
1174+
1175-------------------------------------------------------------
1176%if ${something} != %{nil}
1177 %warning The test passes
1178%else
1179 %error The test fails
1180%endif
1181-------------------------------------------------------------
1182+>+:: The left hand side is numerically greater than the right hand side.
1183+>=+:: The left hand side is numerically greater than or equal to the right
1184hand side.
1185+<+:: The left hand side is numerically less than the right hand side.
1186+\<=+:: The left hand side is numerically less than or equal to the right hand
1187side.
1188
1189%ifn
1190^^^^
1191
1192The +%ifn+ macro inverts the normal +%if+ logic. It avoids needing to provide
1193empty _if_ blocks followed by _else_ blocks. It is useful when checking if a
1194macro is defined:
1195
1196-------------------------------------------------------------
1197%ifn %{defined foo}
1198 %define foo bar
1199%endif
1200-------------------------------------------------------------
1201
1202%ifarch
1203^^^^^^^
1204
1205The +%ifarch+ is a short cut for "+%if %{\_arch} == i386+". Currently not used.
1206
1207%ifnarch
1208^^^^^^^^
1209
1210The +%ifnarch+ is a short cut for "+%if %{\_arch} != i386+". Currently not
1211used.
1212
1213%ifos
1214^^^^^
1215
1216The +%ifos+ is a short cut for "+%if %{\_os} != mingw32+". It allows
1217conditional support for various operating system differences when building
1218packages.
1219
1220%else
1221^^^^^
1222
1223The +%else+ macro starts the conditional _else_ block.
1224
1225%endfi
1226^^^^^^
1227
1228The +%endif+ macro ends a conditional logic block.
1229
1230%bconf_with
1231^^^^^^^^^^^
1232
1233The +%bconf_with+ macro provides a way to test if the user has passed a
1234specific option on the command line with the +--with-<label>+ option. This
1235option is only available with the +sb-builder+ command.
1236
1237%bconf_without
1238^^^^^^^^^^^^^^
1239
1240The +%bconf_without+ macro provides a way to test if the user has passed a
1241specific option on the command line with the +--without-<label>+ option. This
1242option is only available with the +sb-builder+ command.
1243
1244
1245Project Sets
1246------------
1247
1248The RTEMS Source Builder supports project configurations. Project
1249configurations can be public or private and can be contained in the RTEMS
1250Source Builder project if suitable, other projects they use the RTEM Source
1251Builder or privately on your local file system.
1252
1253The configuration file loader searches the macro +_configdir+ and by default
1254this is set to +%{\_topdir}/config:%{\_sbdir}/config+ where +_topdir+ is the
1255your current working direct, in other words the directory you invoke the RTEMS
1256Source Builder command in, and +_sbdir+ is the directory where the RTEMS Source
1257Builder command resides. Therefore the +config+ directory under each of these
1258is searched so all you need to do is create a +config+ in your project and add
1259your configuration files. They do not need to be under the RTEMS Source Builder
1260source tree. Public projects are included in the main RTEMS Source Builder such
1261as RTEMS.
1262
1263You can also add your own +patches+ directory next to your +config+ directory
1264as the +%patch+ command searches the +_patchdir+ macro variable and it is
1265by default set to +%{\_topdir}/patches:%{\_sbdir}/patches+.
1266
1267The +source-builder/config+ directory provides generic scripts for building
1268various tools. You can specialise these in your private configurations to make
1269use of them. If you add new generic configurations please contribute them back
1270to the project
1271
1272RTEMS Configurations
1273~~~~~~~~~~~~~~~~~~~~
1274
1275The RTEMS Configurations are grouped by RTEMS version. In RTEMS the tools are
1276specific to a specific version because of variations between Newlib and
1277RTEMS. Restructuring in RTEMS and Newlib sometimes moves _libc_ functionality
1278between them and this makes existing tool incompatible with RTEMS.
1279
1280RTEMS allows architectures to have different tool versions and patches. The
1281large number of architectures RTEMS supports can make it difficult to get a
1282common stable version of all the packages. An architecture may require a recent
1283GCC because an existing bug has been fixed, how-ever the more recent version
1284may have a bug in other architecture. Architecture specific patches should be
1285limited to the architecture it relates to. The patch may fix a problem on the
1286effect architecture how-ever it could introduce a problem in another
1287architecture. Limit exposure limits any possible crosstalk between
1288architectures.
1289
1290RTEMS supports _stable_ and _unstable_ configuration of tools. The stable build
1291sets are referenced as +<version>/rtems-<arch>+ and the unstable build sets are
1292references as +<version>/unstable/rtems-<arch>+.
1293
1294Commands
1295--------
1296
1297Checker (sb-check)
1298~~~~~~~~~~~~~~~~~~
1299
1300This commands checks your system is set up correctly. Most options are ignored.
1301
1302-------------------------------------------------------------
1303$ ../source-builder/sb-check --help
1304sb-check: [options] [args]
1305RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1306Options and arguments:
1307--force                : Create directories that are not present
1308--trace                : Trace the execution (not current used)
1309--dry-run              : Do everything but actually run the build
1310--warn-all             : Generate warnings
1311--no-clean             : Do not clean up the build tree
1312--no-smp               : Run with 1 job and not as many as CPUs
1313--rebuild              : Rebuild (not used)
1314--host                 : Set the host triplet
1315--build                : Set the build triplet
1316--target               : Set the target triplet
1317--prefix path          : Tools build prefix, ie where they are installed
1318--prefixbase path      :
1319--topdir path          : Top of the build tree, default is $PWD
1320--configdir path       : Path to the configuration directory, default: ./config
1321--builddir path        : Path to the build directory, default: ./build
1322--sourcedir path       : Path to the source directory, default: ./source
1323--tmppath path         : Path to the temp directory, default: ./tmp
1324--log file             : Log file where all build out is written too
1325--url url              : URL to look for source
1326--targetcflags flags   : List of C flags for the target code
1327--targetcxxflags flags : List of C++ flags for the target code
1328--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1329--with-<label>         : Add the --with-<label> to the build
1330--without-<label>      : Add the --without-<label> to the build
1331$ ../source-builder/sb-check
1332RTEMS Source Builder environment is ok
1333-------------------------------------------------------------
1334
1335Defaults (sb-defaults)
1336~~~~~~~~~~~~~~~~~~~~~~
1337
1338This commands outputs and the default macros for your when given no
1339arguments. Most options are ignored.
1340
1341-------------------------------------------------------------
1342$ ../source-builder/sb-defaults --help
1343sb-defaults: [options] [args]
1344RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1345Options and arguments:
1346--force                : Force the build to proceed
1347--trace                : Trace the execution (not current used)
1348--dry-run              : Do everything but actually run the build
1349--warn-all             : Generate warnings
1350--no-clean             : Do not clean up the build tree
1351--no-smp               : Run with 1 job and not as many as CPUs
1352--rebuild              : Rebuild (not used)
1353--host                 : Set the host triplet
1354--build                : Set the build triplet
1355--target               : Set the target triplet
1356--prefix path          : Tools build prefix, ie where they are installed
1357--prefixbase path      :
1358--topdir path          : Top of the build tree, default is $PWD
1359--configdir path       : Path to the configuration directory, default: ./config
1360--builddir path        : Path to the build directory, default: ./build
1361--sourcedir path       : Path to the source directory, default: ./source
1362--tmppath path         : Path to the temp directory, default: ./tmp
1363--log file             : Log file where all build out is written too
1364--url url              : URL to look for source
1365--targetcflags flags   : List of C flags for the target code
1366--targetcxxflags flags : List of C++ flags for the target code
1367--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1368--with-<label>         : Add the --with-<label> to the build
1369--without-<label>      : Add the --without-<label> to the build
1370-------------------------------------------------------------
1371
1372Set Builder (sb-set-builder)
1373~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1374
1375This command builds a set.
1376
1377-------------------------------------------------------------
1378$ ../source-builder/sb-set-builder --help
1379sb-set-builder: [options] [args]
1380RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
1381Options and arguments:
1382--force                : Force the build to proceed
1383--trace                : Trace the execution (not current used)
1384--dry-run              : Do everything but actually run the build
1385--warn-all             : Generate warnings
1386--no-clean             : Do not clean up the build tree
1387--no-smp               : Run with 1 job and not as many as CPUs
1388--rebuild              : Rebuild (not used)
1389--host                 : Set the host triplet
1390--build                : Set the build triplet
1391--target               : Set the target triplet
1392--prefix path          : Tools build prefix, ie where they are installed
1393--prefixbase path      :
1394--topdir path          : Top of the build tree, default is $PWD
1395--configdir path       : Path to the configuration directory, default: ./config
1396--builddir path        : Path to the build directory, default: ./build
1397--sourcedir path       : Path to the source directory, default: ./source
1398--tmppath path         : Path to the temp directory, default: ./tmp
1399--log file             : Log file where all build out is written too
1400--url url              : URL to look for source
1401--targetcflags flags   : List of C flags for the target code
1402--targetcxxflags flags : List of C++ flags for the target code
1403--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1404--with-<label>         : Add the --with-<label> to the build
1405--without-<label>      : Add the --without-<label> to the build
1406--list-bsets           : List available build sets
1407--keep-going           : Do not stop on error.
1408--no-install           : Do not install the packages to the prefix.
1409--bset-tar-file        : Create a build set tar file
1410--list-configs         : List available configurations
1411--pkg-tar-files        : Create package tar files
1412-------------------------------------------------------------
1413
1414.Arguments
1415The +[args]+ are a list build sets to build.
1416
1417.Options
1418+--force+;;
1419Force the build to proceed even if the host check fails. Typically this happens
1420if executable files are found in the path at a different location to the host
1421defaults.
1422+--trace+;;
1423Trace enable printing of debug information to stdout. It is really only of use
1424to RTEMS Source Builder's developers.
1425+--dry-run+;;
1426Do everything but actually run the build commands. This is useful when checking
1427a new configuration parses cleanly.
1428+--warn-all+;;
1429Generate warnings.
1430+--no-clean+;;
1431Do not clean up the build tree during the cleaning phase of the build. This
1432leaves the source and the build output on disk so you can make changes, or
1433amend or generate new patches. It also allows you to review configure type
1434output such as +config.log+.
1435+--no-smp+;;
1436Run +make+ with 1 job and not as many as there are cores. This option can help
1437isolate parallel make type bugs or make the log file output
1438sequential. Parallel jobs can make the output confusing.
1439+--host+;;
1440Set the host triplet value. Becareful with this option.
1441+--build+;;
1442Set the build triplet. Becareful with this option.
1443+--target+;;
1444Set the target triplet. Becareful with this option. This is useful if you have
1445a generic configuration script that can work for a range of architectures.
1446+--prefix path+;;
1447Tools build prefix, ie where they are installed.
1448+--prefixbase path+;;
1449The prefix base is appended to the build root path.
1450+--topdir path+;;
1451Top of the build tree, that is the current directory you are in.
1452+--configdir path+;;
1453Path to the configuration directory. This overrides the built in defaults.
1454+--builddir path+;;
1455Path to the build directory. This overrides the default of +build+.
1456+--sourcedir path+;;
1457Path to the source directory. This overrides the default of +source+.
1458+--tmppath path+;;
1459Path to the temporary directory. This overrides the default of +tmp+.
1460+--log file+;;
1461Log all the output from the build process. The output is directed to +stdout+
1462if no log file is provided.
1463+--url url+;;
1464URL to look for source when downloading. This is can be comma separate list.
1465+--targetcflags flags+;;
1466List of C flags for the target code. This allows for specific local
1467customisation when testing new variations.
1468+--targetcxxflags flags+;;
1469List of C++ flags for the target code. This allows for specific local
1470customisation when testing new variations.
1471+--libstdcxxflags flags+;;
1472List of C\++ flags to build the target libstdc++ code. This allows for specific
1473local customisation when testing new variations.
1474+--with-<label>+;;
1475Add the --with-<label> to the build. This can be tested for in a script with
1476the +%bconf_with+ macro.
1477+--without-<label>+;;
1478Add the --without-<label> to the build. This can be tested for in a script with
1479the +%bconf_without+ macro.
1480+--list-bsets+;;
1481List available build sets.
1482+--list-configs+;;
1483List available configurations.
1484+--keep-going+;;
1485Do not stop on error. This is useful if your build sets performs a large number
1486of testing related builds and there are errors.
1487+--no-install+;;
1488Do not install the packages to the prefix. Use this if you are only after the
1489tar files.
1490+--bset-tar-file+;;
1491Create a build set tar file. This is a single tar file of all the packages in
1492the build set.
1493+--pkg-tar-files+;;
1494Create package tar files. A tar file will be created for each package built in
1495a build set.
1496
1497Set Builder (sb-builder)
1498~~~~~~~~~~~~~~~~~~~~~~~~
1499
1500This command builds a configuration as described in a configuration
1501file. Configuration files have the extension of +.cfg+.
1502
1503-------------------------------------------------------------
1504$ ./source-builder/sb-builder --help
1505sb-builder: [options] [args]
1506RTEMS Source Builder, an RTEMS Tools Project (c) 2012 Chris Johns
1507Options and arguments:
1508--force                : Create directories that are not present
1509--trace                : Trace the execution (not current used)
1510--dry-run              : Do everything but actually run the build
1511--warn-all             : Generate warnings
1512--no-clean             : Do not clean up the build tree
1513--no-smp               : Run with 1 job and not as many as CPUs
1514--rebuild              : Rebuild (not used)
1515--host                 : Set the host triplet
1516--build                : Set the build triplet
1517--target               : Set the target triplet
1518--prefix path          : Tools build prefix, ie where they are installed
1519--prefixbase path      :
1520--topdir path          : Top of the build tree, default is $PWD
1521--configdir path       : Path to the configuration directory, default: ./config
1522--builddir path        : Path to the build directory, default: ./build
1523--sourcedir path       : Path to the source directory, default: ./source
1524--tmppath path         : Path to the temp directory, default: ./tmp
1525--log file             : Log file where all build out is written too
1526--url url              : URL to look for source
1527--targetcflags flags   : List of C flags for the target code
1528--targetcxxflags flags : List of C++ flags for the target code
1529--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
1530--with-<label>         : Add the --with-<label> to the build
1531--without-<label>      : Add the --without-<label> to the build
1532--list-configs         : List available configurations
1533-------------------------------------------------------------
1534
1535Host Setups
1536-----------
1537
1538MacOS X
1539~~~~~~~
1540
1541The RTEMS Source Builder has been tested on Mountain Lion. You will need to
1542install the Xcode app using the _App Store_ tool, run Xcode and install the
1543Developers Tools package within Xcode.
1544
1545Ubuntu
1546~~~~~~
1547
1548The latest testing was with 12.10. A minimal installation was used and the
1549following packages installed.
1550
1551-------------------------------------------------------------
1552$ sudo apt-get build-dep binutils gcc g++ gdb unzip git
1553-------------------------------------------------------------
1554
1555Raspbian
1556~~~~~~~~
1557
1558The is the Debian distribution for the Raspberry Pi. The following packages are
1559required.
1560
1561-------------------------------------------------------------
1562$ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
1563texinfo unzip ncurses-dev python-dev git
1564-------------------------------------------------------------
1565
1566It is recommended you get Model B of the Pi with 512M of memory and to mount a
1567remote disk over the network. The tools can be build with a prefix under your
1568home directory as recommended and end up on the SD card.
1569
1570CentOS 6
1571~~~~~~~~
1572
1573The following packages are required on a minimal CentOS 6.3 installation:
1574
1575-------------------------------------------------------------
1576# yum install autoconf automake binutils gcc gcc-c++ gdb make patch \
1577bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git
1578-------------------------------------------------------------
1579
1580The minimal CentOS distribution is a specific DVD that installs a minimal
1581system. If you use a full system some of these packages may have been
1582installed.
1583
1584History
1585-------
1586
1587The RTEMS Source Builder is a stand alone tool based on another tool called the
1588'SpecBuilder'. The SpecBuilder was written for the RTEMS project to give me a
1589way to build tools on hosts that did not support RPMs. At the time the RTEMS
1590tools maintainer only used spec files to create various packages. This meant I
1591had either spec files, RPM files or SRPM files. The RPM and SPRM files where
1592useless because you needed an 'rpm' type tool to extract and manage them. There
1593are versions of 'rpm' for a number of non-RPM hosts how-ever these proved to be
1594in various broken states and random-ally maintained. The solution I settled on
1595was to use spec files so I wrote a Python based tool that parsed the spec file
1596format and allowed me to create a shell script I could run to build the
1597package. This approach proved successful and I was able to track the RPM
1598version of the RTEMS tools on a non-RPM host over a number of years. How-ever
1599the SpecBuilder tool did not help me build tools or other packages not related
1600to the RTEMS project where there was no spec file I could use so I needed
1601another tool. Rather than start again I decided to take the parsing code for
1602the spec file format and build a new tool called the RTEMS Source Builder.
Note: See TracBrowser for help on using the repository browser.