source: rtems-source-builder/doc/source-builder.txt @ 90def32

4.104.114.95
Last change on this file since 90def32 was 90def32, checked in by Dhananjay Balan <mb.dhananjay@…>, on 03/19/13 at 04:01:49

Add archlinux to the doc

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