Changeset 6e4f5e7 in rtems-source-builder


Ignore:
Timestamp:
02/26/13 06:55:39 (10 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, 5, master
Children:
99eee0e
Parents:
eef48f9
Message:

Updated doco.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/source-builder.txt

    reef48f9 r6e4f5e7  
    198198~~~~~~~~
    199199
    200 In this quick start I will build an SPARC tool set.
     200In this quick start I will build a SPARC tool set.
    201201
    202202-------------------------------------------------------------
     
    551551configuration files.
    552552
    553 Defining macros is performed with the +%define+ directive:
     553Defining macros is performed with the +%define+ macro:
    554554
    555555-------------------------------------------------------------
     
    560560referenced files or an undefined macro error is reported.
    561561
    562 Inline including another file with the +%include+ directive continues
    563 processing with the specified file returning to carry on from just after the
    564 include point.
     562Inline including another file with the +%include+ macro continues processing
     563with the specified file returning to carry on from just after the include
     564point.
    565565
    566566-------------------------------------------------------------
     
    585585has finished being scanned.
    586586
    587 Configuration Files
    588 ~~~~~~~~~~~~~~~~~~~
     587Configuration Control
     588~~~~~~~~~~~~~~~~~~~~~
     589
     590The RTEMS Souce Builder is designed to fit within most verification and
     591validation processes. All of the RTEMS Source Builder is source code. The
     592Python code is source and comes with a commercial friendly license. All
     593configuration data is text and can be read or parsed with standard text based
     594tools.
     595
     596File naming provides configuration management. A specific version of a package
     597is captured in a specific set of configuration files. The top level
     598configuration file referenced in a _build set_ or passed to the +sb-builder+
     599command relates to a specific configuration of the package being built. For
     600example the RTEMS configuration file +rtems-gcc-4.7.2-newlib-2.0.0-1.cfg+
     601creates an RTEMS GCC and Newlib package where the GCC version is 4.7.2, the
     602Newlib version is 2.0.0, plus any RTEMS specific patches that related to this
     603version. The configuration defines the version numbers of the various parts
     604that make up this package:
     605
     606-------------------------------------------------------------
     607%define gcc_version    4.7.2
     608%define newlib_version 2.0.0
     609%define mpfr_version   3.0.1
     610%define mpc_version    0.8.2
     611%define gmp_version    5.0.5
     612-------------------------------------------------------------
     613
     614The package build options, if there are any are also defined:
     615
     616-------------------------------------------------------------
     617%define with_threads 1
     618%define with_plugin  0
     619%define with_iconv   1
     620-------------------------------------------------------------
     621
     622The generic configuration may provide defaults incase options are not
     623specified. The patches this specific version of the package requires can be
     624included:
     625
     626-------------------------------------------------------------
     627Patch0: gcc-4.7.2-rtems4.11-20121026.diff
     628-------------------------------------------------------------
     629
     630Finally including the GCC 4.7 configuration script:
     631
     632-------------------------------------------------------------
     633%include %{_configdir}/gcc-4.7-1.cfg
     634-------------------------------------------------------------
     635
     636The +gcc-4.7-1.cfg+ is a generic script to build a GCC 4.7 compiler with
     637Newlib. It is not specific to RTEMS. A bare no operating system tool set can be
     638built with this file.
     639
     640The +-1+ part of the file names is a revision. The GCC 4.7 script maybe revised
     641to fix a problem and if this fix effects an existing script the file is copied
     642and given a +-2+ revision number. Any dependent scripts referencing the earlier
     643revision number will not be effected by the change. This locks down a specific
     644configuration over time.
     645
     646Configuration Script Language
     647~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    589648
    590649Configuration files specify how to build a package. Configuration files are
     
    594653format RPM needs and uses.
    595654
    596 Script Language
    597 ~~~~~~~~~~~~~~~
    598 
    599 The script language is implemented in terms of directives. The directive list is:
     655The script language is implemented in terms of macross. The builtin list is:
    600656
    601657[horizontal]
     
    605661+%clean+:: The package clean shell commands.
    606662+%include+:: Inline include another configuration file.
    607 +%package+:: The package being built.
    608663+%name+:: The name of the package.
    609 +%description+:: A package description. Useful when reporting about a build.
     664+%summary+:: A brief package description. Useful when reporting about a build.
    610665+%release+:: The package release. A number that is the release as built by this tool.
    611666+%version+:: The package's verison string.
    612667+%buildarch+:: The build architecture.
    613668+%setup+:: Setup a source package.
    614 +%source+:: Define a source code package. This directive is number.
    615 +%patch+:: Define a patch. This directive is number.
     669+%source+:: Define a source code package. This macro has a number appended.
     670+%patch+:: Define a patch. This macro has a is number appended.
    616671+%warning+:: Print the following string as a warning and continue.
    617672+%error+:: Print the following string as an error and exit.
     
    633688^^^^^
    634689
    635 The +%prep+ directive starts a block that continues until the next block
    636 directive. The _prep_ or preparation block defines the setup of the package's
    637 source and is a mix of RTEMS Source Builder directives and shell scripting. The
    638 sequence is typically +%setup+ directives for source, +%patch+ directives to
    639 patch the source mixed with some shell commands to correct any source issues.
    640 A +%prep+ section starts with a +%setup+ command. This creates the package
    641 source top level directory then is followed by the first source file.
     690The +%prep+ macro starts a block that continues until the next block macro. The
     691_prep_ or preparation block defines the setup of the package's source and is a
     692mix of RTEMS Source Builder macros and shell scripting. The sequence is
     693typically +%setup+ macros for source, +%patch+ macros to patch the source
     694mixed with some shell commands to correct any source issues.  A +%prep+ section
     695starts with a +%setup+ command. This creates the package source top level
     696directory then is followed by the first source file.
    642697
    643698-------------------------------------------------------------
     
    650705<2> The version of the package.
    651706
    652 The source for a package is declared with the +%source*+ directive where +*+ is
     707The source for a package is declared with the +%source*+ macro where +*+ is
    653708a number. For example +%source0+ is the source 0 tar file and is defined with
    654709something similar to this:
     
    666721option +--url+. This option accepts a comma delimited list of sites to try.
    667722
    668 You can combine the source directive with connditional logic to implement a
    669 default that can be overriden in the top level files. This lets you reuse a
    670 generic build script with different sources. This happens if you have a private
    671 source package with local modifications. The following example is taken from
    672 the +gcc-4.8-1.cfg+ build script.
     723You can combine the source macro with connditional logic to implement a default
     724that can be overriden in the top level files. This lets you reuse a generic
     725build script with different sources. This happens if you have a private source
     726package with local modifications. The following example is taken from the
     727+gcc-4.8-1.cfg+ build script.
    673728
    674729-------------------------------------------------------------
     
    679734-------------------------------------------------------------
    680735
    681 <1> The version control directive is currently not implemented.
     736<1> The version control macro is currently not implemented.
    682737
    683738You could optionally have a few source files that make up the package. For
     
    724779    directory.
    725780<2> The conditional macro expansion checks if +%patch0+ is defined and if
    726     defined issues the +%patch0" directive giving +-p1+ to the patch command.
     781    defined issues the +%patch0" macro giving +-p1+ to the patch command.
    727782<3> Return back to the top of the source tree.
    728783
     
    730785^^^^^^
    731786
    732 The +%build+ directive starts a block that continues until the next block
    733 directive. The build block is a series of shell commands that execute to build
    734 the package. It assumes all source code has been unpacked, patch and adjusted
    735 so the build will succeed.
     787The +%build+ macro starts a block that continues until the next block
     788macro. The build block is a series of shell commands that execute to build the
     789package. It assumes all source code has been unpacked, patch and adjusted so
     790the build will succeed.
    736791
    737792The following is an example take from the GutHub STLink project [footnote:
     
    772827<5> Various settings passed to configure to customise the build. In this
    773828    example an include path is being set to the install point of _libusb_. This
    774     package requires _libusb_ is build before it.
     829    package requires _libusb_ is built before it.
    775830<6> The +configure+ command. The RTEMS Source Builder provides all the needed
    776831    paths as macro variables. You just need to provide them to +configure+.
     
    785840^^^^^^^^
    786841
    787 The +%install+ directive starts a block that continues until the next block
    788 directive. The install block is a series of shell commands that execute to
    789 install the package. You can assumes the package has build correctly when this
    790 shell script executes.
     842The +%install+ macro starts a block that continues until the next block
     843macro. The install block is a series of shell commands that execute to install
     844the package. You can assume the package has build correctly when this block
     845starts executing.
    791846
    792847Never install the package to the actual _prefix_ the package was built
    793848with. Always install to the RTEMS Source Builder's temporary path defined in
    794 the macro variable +__tmpdir+. The RTEMS Source Builder sets up a shell
     849the macro variable +\__tmpdir+. The RTEMS Source Builder sets up a shell
    795850environment variable called +SB_BUILD_ROOT+ as the standard install point. Most
    796851packages support adding +DESTDIR=+ to the _make install_ command.
     
    815870<3> Enter the build directory. In this example it just happens to be the source
    816871    directory.
    817 <4> Run +make install_ to install the package overriding the +DESTDIR+ make
     872<4> Run +make install+ to install the package overriding the +DESTDIR+ make
    818873    variable.
    819874
     
    821876^^^^^^
    822877
     878The +%clean+ macro starts a block that continues until the next block
     879macro. The clean block is a series of shell commands that execute to clean up
     880after a package has been built and install. This macro is currenly not been
     881used because the RTEMS Source Builder automatically cleans up.
     882
    823883%include
    824884^^^^^^^^
    825885
    826 %package
    827 ^^^^^^^^
     886The +%include+ macro inline includes the specific file. The +\__confdir+
     887path is searched. Any relative path component of the include file is appended
     888to each part of the +\__configdir+. Adding an extension is optional as files
     889with +.bset+ and +.cfg+ are automatically searched for.
     890
     891Inline including means the file is processed as part of the configuration at
     892the point it is included. Parsing continues from the next line in the
     893configuration file that contains the +%include+ macro.
     894
     895Including files allow a kind of configuration file reuse. The outter
     896configuration files provide specific information such as package version
     897numbers and patches and then include a generic configuration script which
     898builds the package.
     899
     900-------------------------------------------------------------
     901%include %{_configdir}/gcc-4.7-1.cfg
     902-------------------------------------------------------------
    828903
    829904%name
    830905^^^^^
    831906
    832 %description
    833 ^^^^^^^^^^^^
     907The name of the package being built. The name typically contains the components
     908of the package and their version number plus a revision number. For the GCC
     909with Newlib configuration the name is typically:
     910
     911-------------------------------------------------------------
     912Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
     913-------------------------------------------------------------
     914
     915%summary
     916^^^^^^^^
     917
     918The +%summary+ is a brief description of the package. It is useful when
     919reporting. This information is not capture in the package anywhere. For the GCC
     920with Newlib configuration the summary is typically:
     921
     922-------------------------------------------------------------
     923Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
     924-------------------------------------------------------------
    834925
    835926%release
    836927^^^^^^^^
    837928
     929The +%release+ is packaging number that allows revisions of a package to happen
     930where none package versions change. This value typically increases when the
     931configuration building the package changes.
     932
     933-------------------------------------------------------------
     934%define release 1
     935-------------------------------------------------------------
     936
    838937%version
    839938^^^^^^^^
    840939
     940The +%version% macro sets the version the package. If the package is a single
     941component it tracks that component's version number. For example in the
     942_libusb_ configuration the +%version+ is the same as +%libusb_version+,
     943how-ever in a GCC with Newlib configuration there is no single version
     944number. In this case the GCC version is used.
     945
     946-------------------------------------------------------------
     947Version: %{gcc_version}
     948-------------------------------------------------------------
     949
    841950%buildarch
    842951^^^^^^^^^^
    843952
     953The +%buildarch+ macro is set to the architecture the package contains. This is
     954currently not used in the RTEMS Source Builder and may go away. This macro is
     955more important in a real packaging system where the package could end up on the
     956wrong architecture.
     957
    844958%setup
    845959^^^^^^
    846960
     961The +%setup+ macro sets up the source code tree and is used in the +%prep+
     962section of the script. The options are:
     963
     964[horizontal]
     965*Switch*:: *Description*
     966+-n+:: The -n option is used to set the name of the software's build
     967directory. This is necessary only when the source archive unpacks into a
     968directory named other than +<name>-<version>+.
     969+-c+:: The -c option is used to direct %setup to create the top-level build
     970directory before unpacking the sources.
     971+-D+:: The -D option is used to direct %setup to not delete the build directory
     972prior to unpacking the sources. This option is used when more than one source
     973archive is to be unpacked into the build directory, normally with the +-b+ or
     974+-a+ options.
     975+-T+:: The -T option is used to direct %setup to not perform the default
     976unpacking of the source archive specified by the first Source: macro. It is used
     977with the +-a+ or +-b+ options.
     978+-b <n>+:: The -b option is used to direct %setup to unpack the source archive
     979specified on the nth Source: macro line before changing directory into the build
     980directory.
     981+-a <n>+:: The -a option is used to direct %setup to unpack the source archive
     982specified on the nth Source: macro line after changing directory into the build
     983directory.
     984
    847985%source
    848986^^^^^^^
    849987
     988The +%source+ macro is numbered and defines a source tar file used in the
     989package. The +%setup+ macro references the packages defined here. A macro is
     990defined as:
     991
     992-------------------------------------------------------------
     993Source0: ftp://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.bz2
     994-------------------------------------------------------------
     995
     996The setup script is:
     997
     998-------------------------------------------------------------
     999%setup -q -T -D -n %{name}-%{version} -a0
     1000-------------------------------------------------------------
     1001
     1002The +-a0+ means use +%source0+.
     1003
    8501004%patch
    8511005^^^^^^
    8521006
     1007The +%patch+ macro is numbered and can define a patch and in the +%prep+
     1008section applies the patch. To define a patch append a +:+ followed by the patch
     1009filename:
     1010
     1011-------------------------------------------------------------
     1012Patch0: gcc-4.7.2-rtems4.11-20121026.diff
     1013-------------------------------------------------------------
     1014
     1015The +__patchdir+ path is search.
     1016
     1017Placing +%patch+ in the +%prep+ section will apply it with any trailing options
     1018passed to the +patch+ command. This allows the +-p+ option to be passed to
     1019strip any leading path components from the patch contents.
     1020
     1021-------------------------------------------------------------
     1022%patch0 -p1
     1023-------------------------------------------------------------
     1024
     1025You will typically see the patch conditionally used as:
     1026
     1027-------------------------------------------------------------
     1028%{patch0:%patch0 -p1}
     1029-------------------------------------------------------------
     1030
     1031In this case the patch will only be applied if it is defined.
     1032
    8531033%warning
    8541034^^^^^^^^
    8551035
     1036The +%warning+ macro outputs the following string as a warning.
     1037
    8561038%error
    8571039^^^^^^
    8581040
     1041The +%error+ macro outputs the follow string as an error and exits the RTEMS
     1042Source Builder.
     1043
    8591044%define
    8601045^^^^^^^
    8611046
     1047The +%define+ macro defines a new macro. If the macro being defined already
     1048exists a warning is raised. If you value is given it is assumed to be 1.
     1049
     1050-------------------------------------------------------------
     1051%define foo bar
     1052%define one_plus_one 2
     1053%define one <1>
     1054-------------------------------------------------------------
     1055
     1056<1> The macro _one_ is set to 1.
     1057
    8621058%undefine
    8631059^^^^^^^^^
    8641060
     1061The +%undefine+ macro removes a macro if it exists. Any further references to
     1062it will result in an undefine macro error.
     1063
    8651064%if
    8661065^^^
    8671066
     1067The +%if+ macro starts a conditional logic block that can optionally have a
     1068_else_ section. A test follows this macro and can have the following operators:
     1069
     1070[horizontal]
     1071*Operator*:: *Description*
     1072+%{}+:: Check the macro is set or _true_, ie non-zero.
     1073+
     1074-------------------------------------------------------------
     1075%if ${foo}
     1076 %warning The test passes, must not be empty or is non-zero
     1077%else
     1078 %error The test fails, must be empty or zero
     1079%endif
     1080-------------------------------------------------------------
     1081+!+:: The _not_ operator inverts the test of the macro.
     1082+
     1083-------------------------------------------------------------
     1084%if ! ${foo}
     1085 %warning The test passes, must be empty or zero
     1086%else
     1087 %error The test fails, must not be empty or is non-zero
     1088%endif
     1089-------------------------------------------------------------
     1090+==+:: The left hand size must equal the right hand side. For example:
     1091+
     1092-------------------------------------------------------------
     1093%define one 1
     1094%if ${one} == 1
     1095 %warning The test passes
     1096%else
     1097 %error The test fails
     1098%endif
     1099-------------------------------------------------------------
     1100+
     1101You can also check to see if a macro is empty:
     1102+
     1103-------------------------------------------------------------
     1104%if ${nothing} == %{nil}
     1105 %warning The test passes
     1106%else
     1107 %error The test fails
     1108%endif
     1109-------------------------------------------------------------
     1110+!=+:: The left hand size does not equal the right hand side. For example:
     1111+
     1112-------------------------------------------------------------
     1113%define one 1
     1114%if ${one} != 2
     1115 %warning The test passes
     1116%else
     1117 %error The test fails
     1118%endif
     1119-------------------------------------------------------------
     1120+
     1121You can also check to see if something is set:
     1122+
     1123-------------------------------------------------------------
     1124%if ${something} != %{nil}
     1125 %warning The test passes
     1126%else
     1127 %error The test fails
     1128%endif
     1129-------------------------------------------------------------
     1130+>+:: The left hand side is numerically greater than the right hand side.
     1131+>=+:: The left hand side is numerically greater than or equal to the right
     1132hand side.
     1133+<+:: The left hand side is numerically less than the right hand side.
     1134+\<=+:: The left hand side is numerically less than or equal to the right hand
     1135side.
     1136
    8681137%ifn
    8691138^^^^
    8701139
     1140The +%ifn+ macro inverts the normal +%if+ logic. It avoids needing to provide
     1141empty _if_ blocks followed by _else_ blocks. It is useful when checking if a
     1142macro is defined:
     1143
     1144-------------------------------------------------------------
     1145%ifn %{defined foo}
     1146 %define foo bar
     1147%endif
     1148-------------------------------------------------------------
     1149
    8711150%ifarch
    8721151^^^^^^^
    8731152
     1153The +%ifarch+ is a short cut for "+%if %{\_arch} == i386+". Currently not used.
     1154
    8741155%ifnarch
    8751156^^^^^^^^
    8761157
     1158The +%ifnarch+ is a short cut for "+%if %{\_arch} != i386+". Currently not
     1159used.
     1160
    8771161%ifos
    8781162^^^^^
    8791163
     1164The +%ifos+ is a short cut for "+%if %{\_os} != mingw32+". It allows
     1165conditional support for various operating system differences when building
     1166packages.
     1167
    8801168%else
    8811169^^^^^
    8821170
     1171The +%else+ macro starts the conditional _else_ block.
     1172
    8831173%endfi
    8841174^^^^^^
    8851175
     1176The +%endif+ macro ends a conditional logic block.
     1177
    8861178%bconf_with
    8871179^^^^^^^^^^^
    8881180
     1181The +%bconf_with+ macro provides a way to test if the user has passed a
     1182specific option on the command line with the +--with-<label>+ option. This
     1183option is only available with the +sb-builder+ command.
     1184
    8891185%bconf_without
    8901186^^^^^^^^^^^^^^
    8911187
    892 
    893 RTEMS Build Sets
    894 ----------------
    895 
    896 Configuration files are typically structured as outer files that are specific
    897 to a version of the package being built and become more generic as you move
    898 deeper. The outter layers are required to define various macro.
    899 
    900 
    901 Set Builder and the Builder
    902 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    903 
    904 The RTEMS Source Builder provides two commands, the +sb-set-builder+ to build sets of
    905 packages and the +sb-builder+ to build a specific package. The set builder uses
    906 the builder to build a set of packages. You could write a shell script that did
    907 the same thing so the set builder is a convenience command that allows you to
    908 define and control specific features of the packages you are building. The set
    909 builder looks for files with the +.bset" extension in the +config+
    910 directories. The builder command uses configuration files which have the +.cfg+
    911 file extension to control the build. The configuration files are written in a
    912 script language based on the _spec_ format the RPM builder uses. They also
    913 live in the +config+ directories.
    914 
    915 The build set files for the RTEMS 4.11 can be found in +rtems/4.11/+. There is
    916 one per architecture RTEMS supports. This allows variation between
    917 architectures is bugs or patches are needed. Sometimes a specific version of a
    918 tool may needed to resolve an issue in an architecture, how-ever that version
    919 may have a bug in another architecture. We also want to limit architecture
    920 specific patches to the architecture it relates to. This avoids any crosstalk a
    921 patch may have with another architecture. An example of this is the NIOS2
    922 tools. They are built using a version of GCC released by Altera currently not
    923 in the Free Software Foundation's GCC project.
    924 
    925 This is the build set for the Blackfin processor or +bfin+.
    926 
    927 -------------------------------------------------------------
    928 #
    929 # Tools Set for RTEMS 4.10
    930 #
    931 
    932 %define rtems_version 4.10 <1>
    933 
    934 %define release 1 <2>
    935 
    936 package: rtems-%{rtems_version}-%{_target}-%{release} <3>
    937 
    938 #
    939 # Project custom message
    940 #
    941 %define gcc_version_message RTEMS %{rtems_version}-%{release},gcc-%{gcc_version}/newlib-%{newlib_version} <4>
    942 
    943 #
    944 # Tools configuration.
    945 #
    946 rtems-binutils-2.20.1-1 <5>
    947 rtems-gcc-4.4.7-newlib-1.18.0-1
    948 rtems-gdb-7.3.1-1
    949 -------------------------------------------------------------
    950 
    951 <1> Define the version of RTEMS.
    952 <2> Define the release. This allows us to number the tool releases.
    953 <3> The top level name of the package. The finaly tar file name.
    954 <4> The GCC configuration allow a custom message to be embedded into GCC.
    955 <5> The list of packages this build set contains.
    956 
    957 Currently the syntax of the set builder scripts is limited. It support
    958 comments, the package command, macros (the +%{}+), and defining macros
    959 (+%define+). It is planned to allow more of the configuration file syntax in
    960 the future.
    961 
    962 The builder uses configuration files that allow the full range of the
    963 configuration script syntax. Configuration files follow most of the RPM spec
    964 file format. They support macros and logic as well as the ability to include
    965 other configuration files. The ability to include other configuration files
    966 allow a simple way to configuration control the builds. Configuration files
    967 have four main areas:
    968 
    969 . Descriptions and definitions.
    970 +
    971 The description lists various useful pieces of information about the
    972 package. None of this is currently enforced how-ever it is good practice to
    973 provide it. The definitions are the sources and the patches.
    974 . Preparation
    975 +
    976 The preparation is the set up of the source code ready for building. The set up
    977 follows the unusual command structure used by RPM. The follwing macro
    978 trickshows how to conditional patch the source if a patch has been declared.
    979 +
    980 -------------------------------------------------------------
    981 cd expat-%{expat_version}
    982 %{?patch0:%patch0 -p1}
    983 cd ..
    984 -------------------------------------------------------------
    985 +
    986 . Build
    987 +
    988 The build phase. This is a fragment of shell script that can be mixed with
    989 conditional configuration scripting to create the list of build commands.
    990 +
    991 . Install
    992 +
    993 The install phase. Again this is a fragment of shell script.
    994 
    995 This is a configuration script to build gdb:
    996 
    997 -------------------------------------------------------------
    998 #
    999 # GDB 7.xx Version 1.
    1000 #
    1001 # This configuration file configure's, make's and install's gdb.
    1002 #
    1003 
    1004 %include %{_configdir}/checks.cfg <1>
    1005 
    1006 Name:      %{_target}-gdb-%{gdb_version}-%{release} <2>
    1007 Summary:   GDB v%{gdb_version} for target %{_target} on host %{_host}
    1008 Version:   %{gdb_version}
    1009 Release:   %{release}
    1010 URL:       http://www.gnu.org/software/gdb/
    1011 BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
    1012 
    1013 #
    1014 # Source
    1015 #
    1016 Source0: http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2 <3>
    1017 VersionControl0 git clone git://sourceware.org/git/gdb.git
    1018 
    1019 #
    1020 # Prepare the source code.
    1021 #
    1022 %prep <4>
    1023 %setup -q -c -T -n %{name}-%{version}
    1024 cd gdb-%{gdb_version}
    1025 %{?patch0:%patch0 -p1}
    1026 cd ..
    1027 
    1028 %build <5>
    1029   export PATH="%{_bindir}:${PATH}"
    1030   mkdir -p build
    1031   cd build
    1032 %if "%{_build}" != "%{_host}"
    1033   CFLAGS_FOR_BUILD="-g -O2 -Wall" \
    1034 %endif
    1035   CFLAGS="$SB_OPT_FLAGS" \
    1036   ../gdb-%{gdb_version}/configure \
    1037     --build=%{_build} --host=%{_host} \
    1038     --target=%{_target} \
    1039     --verbose --disable-nls \
    1040     --without-included-gettext \
    1041     --disable-win32-registry \
    1042     --disable-werror \
    1043     --enable-sim \
    1044     --with-expat \
    1045     --with-python \
    1046     --prefix=%{_prefix} --bindir=%{_bindir} \
    1047     --exec-prefix=%{_exec_prefix} \
    1048     --includedir=%{_includedir} --libdir=%{_libdir} \
    1049     --mandir=%{_mandir} --infodir=%{_infodir}
    1050 
    1051   %{__make} %{?_smp_mflags} all
    1052   cd ..
    1053 
    1054 %install <6>
    1055   export PATH="%{_bindir}:${PATH}"
    1056   rm -rf $SB_BUILD_ROOT
    1057 
    1058   cd build
    1059   %{__make} DESTDIR=$SB_BUILD_ROOT install
    1060 
    1061   # Dropped in FSF-binutils-2.9.5, but Cygwin still ships it.
    1062   rm -rf $SB_BUILD_ROOT%{_infodir}/configure.info*
    1063 
    1064   rm -f $SB_BUILD_ROOT%{_infodir}/dir
    1065   touch $SB_BUILD_ROOT%{_infodir}/dir
    1066 
    1067   cd ..
    1068 -------------------------------------------------------------
    1069 
    1070 <1> Including a file. The +_configdir+ macro searchs a list of paths.
    1071 <2> The description section.
    1072 <3> The source file as a URL. If not found in the +sources+ directories it is
    1073 downloaded.
    1074 <4> Preparing the source code.
    1075 <5> The commands to build +gdb+.
    1076 <6> The installation phase. Notice the +DESTDIR=+ feature is used.
    1077 
    1078 Controlling Configurations
    1079 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1080 
    1081 This is a simple process of including the specific pieces you need. There
    1082 typically is three layers where the top level is specific and each sub-layer is
    1083 more generic configured by the layer above it. The typical layering is:
    1084 
    1085 . Build Set
    1086 . Package definition
    1087 . Package configuration
    1088 
    1089 The build set defines the packages to be built plus any specific configuration
    1090 needed. Some packages default to standard values if the build set does not
    1091 provide any specific configuration and some configurations raise an error
    1092 indicating a required configuration is missing.
    1093 
    1094 Using the RTEMS 4.10 Tools Set build as an example the build set configuration
    1095 is:
    1096 
    1097 -------------------------------------------------------------
    1098 #
    1099 # Tools Set for RTEMS 4.10
    1100 #
    1101 
    1102 %define rtems_version 4.10
    1103 
    1104 %define release 1 <1>
    1105 
    1106 package: rtems-%{rtems_version}-%{_target}-%{release}
    1107 
    1108 #
    1109 # Project custom message
    1110 #
    1111 %define gcc_version_message RTEMS %{rtems_version}-%{release},gcc-%{gcc_version}/newlib-%{newlib_version}
    1112 
    1113 #
    1114 # Tools configuration.
    1115 #
    1116 rtems-binutils-2.20.1-1 <2>
    1117 rtems-gcc-4.4.7-newlib-1.18.0-1
    1118 rtems-gdb-7.3.1-1
    1119 -------------------------------------------------------------
    1120 
    1121 <1> The release of the RTEMS 4.10 tools package.
    1122 <2> The build configurations. These reference the specific version of the tools
    1123 including the related patches. You should note the configurations referenced
    1124 are RTEMS specific, that is prefixed with +rtems-+.
    1125 
    1126 The GCC and Newlib file +rtems-gcc-4.4.7-newlib-1.18.0-1+ is:
    1127 
    1128 -------------------------------------------------------------
    1129 #
    1130 # GCC 4.4.7, Newlib 1.18.0
    1131 #
    1132 
    1133 %include %{_configdir}/checks.cfg <1>
    1134 %include %{_configdir}/base.cfg <2>
    1135 
    1136 %define gcc_version    4.4.7 <3>
    1137 %define newlib_version 1.18.0
    1138 %define mpfr_version   2.4.1
    1139 %define mpc_version    0.8.2
    1140 %define gmp_version    5.0.5
    1141 
    1142 %define with_threads 1 <4>
    1143 %define with_plugin  0
    1144 %define with_iconv   1
    1145 
    1146 #
    1147 # AVR C++ does not work.
    1148 #   configure: error: unable to detect exception model
    1149 #
    1150 %if %{_target} == avr-rtems4.10 <5>
    1151 %define enable_cxx 0
    1152 %endif
    1153 
    1154 #
    1155 # M32C C++ does not work.
    1156 #   gcc-4.4.7/libstdc++-v3/src/mt_allocator.cc:76: error: cast from 'void*' to 'size_t' loses precision
    1157 #
    1158 %if %{_target} == m32c-rtems4.10
    1159 %define enable_cxx 0
    1160 %endif
    1161 
    1162 %ifn %{defined enable_cxx} <6>
    1163 %define enable_cxx 1
    1164 %endif
    1165 
    1166 #
    1167 # The RTEMS 4.10 patches
    1168 #
    1169 Patch0:  gcc-core-4.4.7-rtems4.10-20120314.diff <7>
    1170 %if %{enable_cxx}
    1171 Patch1:  gcc-g++-4.4.7-rtems4.10-20120314.diff
    1172 %endif
    1173 Patch10: newlib-1.18.0-rtems4.10-20110518.diff
    1174 
    1175 #
    1176 # The gcc/newlib build instructions. We use 4.4 Release 1.
    1177 #
    1178 %include %{_configdir}/gcc-4.4-1.cfg <8>
    1179 -------------------------------------------------------------
    1180 
    1181 <1> Perform some standard checks such as the release being set.
    1182 <2> Set up some standard macros needed by most configure type packages.
    1183 <3> The specific versions of the various parts that make a GCC embedded
    1184 cross-compiler.
    1185 <4> Configure some specific parts of GCC and Newlib for RTEMS.
    1186 <5> Disable C++ for the AVR target because it does not build for RTEMS.
    1187 <6> Default is to build C++.
    1188 <7> The various patches. This file's revision increases with each patch change.
    1189 <8> The generic GCC/Newlib build configuration for gcc-4.4.x.
    1190 
    1191 Project Configuration
    1192 ~~~~~~~~~~~~~~~~~~~~~
    1193 
    1194 The RTEMS Source Builder has a +config+ and +patches+ directory that contain some
    1195 useful and often needed configurations and patches. You do not need to add your
    1196 project specific configurations into the RTEMS Source Builder. You can create a
    1197 private set and then use the RTEMS Source Builder to build your packages.
    1198 
    1199 Create a +config+ directory and place your build sets and configuration in
    1200 them. If you have private patches add them to a +patches+ directory next to the
    1201 +config+ directiory. When you run a RTEMS Source Builder command it will first search
    1202 the for the specific file then the local +config+ directoy then the Source
    1203 Builder's +config+ directory. The same goes for +patches+.
    1204 
    1205 For example of this set up look in the +rtems+ directory in the Source
    1206 Builder. It is actually a standard alone project configuration private to the
    1207 RTEMS project.
    1208 
    1209 If you are an open source project and you find the RTEMS Source Builder useful and
    1210 would like your configuration held in the RTEMS Source Builder's repository please
    1211 contact me directly.
    1212 
    1213 The Builder
    1214 ~~~~~~~~~~~
    1215 
    1216 TBD
     1188The +%bconf_without+ macro provides a way to test if the user has passed a
     1189specific option on the command line with the +--without-<label>+ option. This
     1190option is only available with the +sb-builder+ command.
     1191
     1192
     1193Project Configuration Sets
     1194--------------------------
     1195
     1196The RTEMS Source Builder supports project configurations. Project
     1197configurations can be public or private and can be contained in the RTEMS
     1198Source Builder project if suitable, other projects they use the RTEM Source
     1199Builder or privately on your local file system.
     1200
     1201The configuration file loader searches the macro +_configdir+ and by default
     1202this is set to +%{\_topdir}/config:%{\_sbdir}/config+ where +_topdir+ is the
     1203your current working direct, in other words the directory you invoke the RTEMS
     1204Source Builder command in, and +_sbdir+ is the directory where the RTEMS Source
     1205Builder command resides. Therefore the +config+ directory under each of these
     1206is searched so all you need to do is create a +config+ in your project and add
     1207your configuration files. They do not need to be under the RTEMS Source Builder
     1208source tree. Public projects are included in the main RTEMS Source Builder such
     1209as RTEMS.
     1210
     1211You can also add your own +patches+ directory next to your +config+ directort
     1212as the +%patch+ command searches the +_patchdir+ macro variable and it is
     1213by default set to +%{\_topdir}/patches:%{\_sbdir}/patches+.
     1214
     1215The +source-builder/config+ directory provides generic scripts for building
     1216various tools. You can specialise these in your private configurations to make
     1217use of them. If you add new generic configurations please contribute them back
     1218to the project
     1219
     1220RTEMS Configurations
     1221~~~~~~~~~~~~~~~~~~~~
     1222
     1223The RTEMS Configurations are grouped by RTEMS version. In RTEMS the tools are
     1224specific to a specific version because of variations between Newlib and
     1225RTEMS. Restructuring in RTEMS and Newlib sometimes moves _libc_ functionality
     1226between them and this makes existing tool incompatible with RTEMS.
     1227
     1228RTEMS allows architectures to have different tool versions and patches. The
     1229large number of architectures RTEMS supports can make it difficult to get a
     1230common stable version of all the packages. An architecture may require a recent
     1231GCC because an existing bug has been fixed, how-ever the more recent verison
     1232may have a bug in other architecture. Architecture specific patches should be
     1233limited to the architecture it relates to. The patch may fix a problem on the
     1234effect architecture how-ever it could introduce a problem in another
     1235architecture. Limit exposure limits any possible crosstalk bewteen
     1236architectures.
     1237
     1238RTEMS supports _stable_ and _unstable_ configuration of tools. The stable build sets
     1239are referenced as +<version>/rtems-<arch>+ and the unstable build sets are
     1240references as +<version>/unstable/rtems-<arch>+.
    12171241
    12181242Commands
     
    12221246~~~~~~~~~~~~~~~~~~
    12231247
    1224 This commands checks your system is set up correctly.
    1225 
    1226 -------------------------------------------------------------
    1227 $ ./source-builder/sb-check --help
     1248This commands checks your system is set up correctly. Most options are ignored.
     1249
     1250-------------------------------------------------------------
     1251$ ../source-builder/sb-check --help
    12281252sb-check: [options] [args]
    1229 RTEMS Source Builder, an RTEMS Tools Project (c) 2012 Chris Johns
     1253RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
    12301254Options and arguments:
    12311255--force                : Create directories that are not present
     
    12531277--with-<label>         : Add the --with-<label> to the build
    12541278--without-<label>      : Add the --without-<label> to the build
    1255 -------------------------------------------------------------
    1256 
    1257 Set Builder (sb-set-builder)
    1258 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1259 
    1260 This command builds a set as described in a build set. Build set files have the
    1261 extension of +.bset+.
    1262 
    1263 -------------------------------------------------------------
    1264 $ ./source-builder/sb-set-builder --help
    1265 sb-set-builder: [options] [args]
    1266 RTEMS Source Builder, an RTEMS Tools Project (c) 2012 Chris Johns
     1279$ ../source-builder/sb-check
     1280RTEMS Source Builder environent is ok
     1281-------------------------------------------------------------
     1282
     1283Defaults (sb-defaults)
     1284~~~~~~~~~~~~~~~~~~~~~~
     1285
     1286This commands outputs and the default macros for your when given no
     1287arguments. Most options are ignored.
     1288
     1289-------------------------------------------------------------
     1290$ ../source-builder/sb-defaults --help
     1291sb-defaults: [options] [args]
     1292RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
    12671293Options and arguments:
    1268 --force                : Create directories that are not present
     1294--force                : Force the build to proceed
    12691295--trace                : Trace the execution (not current used)
    12701296--dry-run              : Do everything but actually run the build
     
    12901316--with-<label>         : Add the --with-<label> to the build
    12911317--without-<label>      : Add the --without-<label> to the build
     1318-------------------------------------------------------------
     1319
     1320Set Builder (sb-set-builder)
     1321~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1322
     1323This command builds a set.
     1324
     1325-------------------------------------------------------------
     1326$ ../source-builder/sb-set-builder --help
     1327sb-set-builder: [options] [args]
     1328RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns
     1329Options and arguments:
     1330--force                : Force the build to proceed
     1331--trace                : Trace the execution (not current used)
     1332--dry-run              : Do everything but actually run the build
     1333--warn-all             : Generate warnings
     1334--no-clean             : Do not clean up the build tree
     1335--no-smp               : Run with 1 job and not as many as CPUs
     1336--rebuild              : Rebuild (not used)
     1337--host                 : Set the host triplet
     1338--build                : Set the build triplet
     1339--target               : Set the target triplet
     1340--prefix path          : Tools build prefix, ie where they are installed
     1341--prefixbase path      :
     1342--topdir path          : Top of the build tree, default is $PWD
     1343--configdir path       : Path to the configuration directory, default: ./config
     1344--builddir path        : Path to the build directory, default: ./build
     1345--sourcedir path       : Path to the source directory, default: ./source
     1346--tmppath path         : Path to the temp directory, default: ./tmp
     1347--log file             : Log file where all build out is written too
     1348--url url              : URL to look for source
     1349--targetcflags flags   : List of C flags for the target code
     1350--targetcxxflags flags : List of C++ flags for the target code
     1351--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code
     1352--with-<label>         : Add the --with-<label> to the build
     1353--without-<label>      : Add the --without-<label> to the build
     1354--list-bsets           : List available build sets
     1355--keep-going           : Do not stop on error.
     1356--no-install           : Do not install the packages to the prefix.
     1357--bset-tar-file        : Create a build set tar file
    12921358--list-configs         : List available configurations
    1293 --list-bsets           : List available build sets
    1294 -------------------------------------------------------------
     1359--pkg-tar-files        : Create package tar files
     1360-------------------------------------------------------------
     1361
     1362.Arguments
     1363The +[args]+ are a list build sets to build.
     1364
     1365.Options
     1366+--force+;;
     1367Force the build to proceed even if the host check fails. Typically this happens
     1368if executables are found in the path at a different location to the host
     1369defaults.
     1370+--trace+;;
     1371Trace enable printing of debug information to stdout. It is really only of use
     1372to RTEMS Source Builder's developers.
     1373+--dry-run+;;
     1374Do everything but actually run the build commands. This is useful when checking
     1375a new configuration parses cleanly.
     1376+--warn-all+;;
     1377Generate warnings.
     1378+--no-clean+;;
     1379Do not clean up the build tree during the cleaning phase of the build. This
     1380leaves the source and the build output on disk so you can make changes, or
     1381amend or generate new patches. It also allows you to review configure type
     1382output such as +config.log+.
     1383+--no-smp+;;
     1384Run +make+ with 1 job and not as many as there are cores. This option can help
     1385isolate parallel make type bugs or make the log file output
     1386sequential. Parallel jobs can make the output confusing.
     1387+--host+;;
     1388Set the host triplet value. Becareful with this option.
     1389+--build+;;
     1390Set the build triplet. Becareful with this option.
     1391+--target+;;
     1392Set the target triplet. Becareful with this option. This is useful if you have
     1393a generic configuration script that can work for a range of architectures.
     1394+--prefix path+;;
     1395Tools build prefix, ie where they are installed.
     1396+--prefixbase path+;;
     1397The prefix base is appended to the build root path.
     1398+--topdir path+;;
     1399Top of the build tree, that is the current directory you are in.
     1400+--configdir path+;;
     1401Path to the configuration directory. This overrides the built in defaults.
     1402+--builddir path+;;
     1403Path to the build directory. This overrides the default of +build+.
     1404+--sourcedir path+;;
     1405Path to the source directory. This overrides the default of +source+.
     1406+--tmppath path+;;
     1407Path to the temporary directory. This overrides the default of +tmp+.
     1408+--log file+;;
     1409Log all the output from the build process. The output is directed to +stdout+
     1410if no log file is provided.
     1411+--url url+;;
     1412URL to look for source when downloading. This is can be comma separate list.
     1413+--targetcflags flags+;;
     1414List of C flags for the target code. This allows for specific local
     1415customisation when testing new variations.
     1416+--targetcxxflags flags+;;
     1417List of C++ flags for the target code. This allows for specific local
     1418customisation when testing new variations.
     1419+--libstdcxxflags flags+;;
     1420List of C\++ flags to build the target libstdc++ code. This allows for specific
     1421local customisation when testing new variations.
     1422+--with-<label>+;;
     1423Add the --with-<label> to the build. This can be tested for in a script with
     1424the +%bconf_with+ macro.
     1425+--without-<label>+;;
     1426Add the --without-<label> to the build. This can be tested for in a script with
     1427the +%bconf_without+ macro.
     1428+--list-bsets+;;
     1429List available build sets.
     1430+--list-configs+;;
     1431List available configurations.
     1432+--keep-going+;;
     1433Do not stop on error. This is useful if your build sets performs a large number
     1434of testing related builds and there are errors.
     1435+--no-install+;;
     1436Do not install the packages to the prefix. Use this if you are only after the
     1437tar files.
     1438+--bset-tar-file+;;
     1439Create a build set tar file. This is a single tar file of all the packages in
     1440the build set.
     1441+--pkg-tar-files+;;
     1442Create package tar files. A tar file will be created for each package built in
     1443a build set.
    12951444
    12961445Set Builder (sb-builder)
     
    13601509-------------------------------------------------------------
    13611510$ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
    1362 texinfo unzip ncurses-dev python-dev
     1511texinfo unzip ncurses-dev python-dev git
    13631512-------------------------------------------------------------
    13641513
Note: See TracChangeset for help on using the changeset viewer.