docs/overview.txt
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Feb 11 21:28:10 2010 +0100 (2010-02-11)
changeset 1803 2c0ed9ec9a8c
parent 1745 41c2a6716511
child 1842 2535545dd450
permissions -rw-r--r--
scripts: add action to extract config from a build.log file

That got removed quite some time ago, but is really usefull to get the
configuration from a build.log file of a failing build.
yann@1
     1
File.........: overview.txt
yann@197
     2
Content......: Overview of how crosstool-NG works.
yann@92
     3
Copyrigth....: (C) 2007 Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
yann@192
     4
License......: Creative Commons Attribution Share Alike (CC-by-sa), v2.5
yann@92
     5
yann@628
     6
____________________
yann@628
     7
                   /
yann@628
     8
Table Of Content  /
yann@628
     9
_________________/
yann@628
    10
yann@628
    11
yann@628
    12
Introduction
yann@628
    13
History
yann@1581
    14
Referring to crosstool-NG
yann@628
    15
Installing crosstool-NG
yann@628
    16
  Install method
yann@628
    17
  The hacker's way
yann@1048
    18
  Preparing for packaging
yann@837
    19
  Shell completion
yann@628
    20
  Contributed code
yann@628
    21
Configuring crosstool-NG
yann@628
    22
  Interesting config options
yann@628
    23
  Re-building an existing toolchain
yann@628
    24
Running crosstool-NG
yann@628
    25
  Stopping and restarting a build
yann@628
    26
  Testing all toolchains at once
yann@628
    27
  Overriding the number of // jobs
yann@1491
    28
  Note on // jobs
yann@1493
    29
  Tools wrapper
yann@628
    30
Using the toolchain
yann@1554
    31
  The 'populate' script
yann@628
    32
Toolchain types
yann@1551
    33
  Seemingly-native toolchains
yann@1575
    34
Contributing
yann@1575
    35
  Sending a bug report
yann@1575
    36
  Sending patches
yann@628
    37
Internals
yann@628
    38
  Makefile front-end
yann@628
    39
  Kconfig parser
yann@628
    40
  Architecture-specific
yann@628
    41
  Adding a new version of a component
yann@628
    42
  Build scripts
yann@628
    43
yann@1580
    44
yann@1
    45
________________
yann@1
    46
               /
yann@1
    47
Introduction  /
yann@1
    48
_____________/
yann@1
    49
yann@1
    50
crosstool-NG aims at building toolchains. Toolchains are an essential component
yann@1
    51
in a software development project. It will compile, assemble and link the code
rpjday@436
    52
that is being developed. Some pieces of the toolchain will eventually end up
yann@1
    53
in the resulting binary/ies: static libraries are but an example.
yann@1
    54
yann@1
    55
So, a toolchain is a very sensitive piece of software, as any bug in one of the
yann@1
    56
components, or a poorly configured component, can lead to execution problems,
yann@1
    57
ranging from poor performance, to applications ending unexpectedly, to
yann@1
    58
mis-behaving software (which more than often is hard to detect), to hardware
rpjday@436
    59
damage, or even to human risks (which is more than regrettable).
yann@1
    60
yann@1
    61
Toolchains are made of different piece of software, each being quite complex
yann@1
    62
and requiring specially crafted options to build and work seamlessly. This
yann@1
    63
is usually not that easy, even in the not-so-trivial case of native toolchains.
yann@1
    64
The work reaches a higher degree of complexity when it comes to cross-
yann@40
    65
compilation, where it can become quite a nightmare...
yann@1
    66
yann@40
    67
Some cross-toolchains exist on the internet, and can be used for general
yann@1
    68
development, but they have a number of limitations:
yann@1
    69
  - they can be general purpose, in that they are configured for the majority:
yann@1
    70
    no optimisation for your specific target,
yann@1
    71
  - they can be prepared for a specific target and thus are not easy to use,
yann@1
    72
    nor optimised for, or even supporting your target,
rpjday@436
    73
  - they often are using aging components (compiler, C library, etc...) not
yann@1
    74
    supporting special features of your shiny new processor;
yann@1
    75
On the other side, these toolchain offer some advantages:
yann@1
    76
  - they are ready to use and quite easy to install and setup,
yann@1
    77
  - they are proven if used by a wide community.
yann@1
    78
yann@1
    79
But once you want to get all the juice out of your specific hardware, you will
yann@197
    80
want to build your own toolchain. This is where crosstool-NG comes into play.
yann@1
    81
rpjday@436
    82
There are also a number of tools that build toolchains for specific needs,
rpjday@436
    83
which are not really scalable. Examples are:
rpjday@436
    84
  - buildroot (buildroot.uclibc.org) whose main purpose is to build root file
yann@1
    85
    systems, hence the name. But once you have your toolchain with buildroot,
yann@1
    86
    part of it is installed in the root-to-be, so if you want to build a whole
yann@1
    87
    new root, you either have to save the existing one as a template and
yann@1
    88
    restore it later, or restart again from scratch. This is not convenient,
yann@1
    89
  - ptxdist (www.pengutronix.de/software/ptxdist), whose purpose is very
yann@1
    90
    similar to buildroot,
yann@702
    91
  - other projects (openembedded.org for example), which are again used to
yann@1
    92
    build root file systems.
yann@1
    93
rpjday@436
    94
crosstool-NG is really targeted at building toolchains, and only toolchains.
yann@1
    95
It is then up to you to use it the way you want.
yann@1
    96
yann@1580
    97
yann@1
    98
___________
yann@1
    99
          /
yann@1
   100
History  /
yann@1
   101
________/
yann@1
   102
rpjday@436
   103
crosstool was first 'conceived' by Dan Kegel, who offered it to the community
yann@1
   104
as a set of scripts, a repository of patches, and some pre-configured, general
yann@1
   105
purpose setup files to be used to configure crosstool. This is available at
yann@203
   106
http://www.kegel.com/crosstool, and the subversion repository is hosted on
yann@203
   107
google at http://code.google.com/p/crosstool/.
yann@1
   108
yann@1
   109
I once managed to add support for uClibc-based toolchains, but it did not make
yann@437
   110
into mainline, mostly because I didn't have time to port the patch forward to
yann@1
   111
the new versions, due in part to the big effort it was taking.
yann@1
   112
yann@1
   113
So I decided to clean up crosstool in the state it was, re-order the things
yann@437
   114
in place, add appropriate support for what I needed, that is uClibc support
yann@437
   115
and a menu-driven configuration, named the new implementation crosstool-NG,
yann@437
   116
(standing for crosstool Next Generation, as many other comunity projects do,
yann@437
   117
and as a wink at the TV series "Star Trek: The Next Generation" ;-) ) and
yann@437
   118
made it available to the community, in case it was of interest to any one.
yann@1
   119
yann@1580
   120
yann@1581
   121
_____________________________
yann@1581
   122
                            /
yann@1581
   123
Referring to crosstool-NG  /
yann@1581
   124
__________________________/
yann@1581
   125
yann@1581
   126
yann@1581
   127
The long name of the project is crosstool-NG:
yann@1581
   128
  * no leading uppercase (except as first word in a sentence)
yann@1581
   129
  * crosstool and NG separated with a hyphen (dash)
yann@1581
   130
  * NG in uppercase
yann@1581
   131
yann@1581
   132
Crosstool-NG can also be referred to by its short name CT-NG:
yann@1581
   133
  * all in uppercase
yann@1581
   134
  * CT and NG separated with a hyphen (dash)
yann@1581
   135
yann@1581
   136
The long name is preferred over the short name, except in mail subjects, where
yann@1581
   137
the short name is a better fit.
yann@1581
   138
yann@1581
   139
When referring to a specific version of crosstool-NG, append the version number
yann@1581
   140
either as:
yann@1581
   141
  * crosstool-NG X.Y.Z
yann@1581
   142
    - the long name, a space, and the version string
yann@1581
   143
  * crosstool-ng-X.Y.Z
yann@1581
   144
    - the long name in lowercase, a hyphen (dash), and the version string
yann@1581
   145
    - this is used to name the release tarballs
yann@1581
   146
  * crosstool-ng-X.Y.Z+hg_id
yann@1581
   147
    - the long name in lowercase, a hyphen, the version string, and the Hg id
yann@1581
   148
      (as returned by: ct-ng version)
yann@1581
   149
    - this is used to differentiate between releases and snapshots
yann@1581
   150
yann@1581
   151
The frontend to crosstool-NG is the command ct-ng:
yann@1581
   152
  * all in lowercase
yann@1581
   153
  * ct and ng separated by a hyphen (dash)
yann@1581
   154
yann@1581
   155
yann@294
   156
___________________________
yann@294
   157
                          /
yann@294
   158
Installing crosstool-NG  /
yann@294
   159
________________________/
yann@294
   160
yann@294
   161
There are two ways you can use crosstool-NG:
yann@294
   162
 - build and install it, then get rid of the sources like you'd do for most
yann@294
   163
   programs,
yann@294
   164
 - or only build it and run from the source directory.
yann@294
   165
yann@294
   166
The former should be used if you got crosstool-NG from a packaged tarball, see
rpjday@436
   167
"Install method", below, while the latter is most useful for developpers that
yann@1576
   168
use a clone of the repository, and want to submit patches, see "The Hacker's
yann@294
   169
way", below.
yann@294
   170
yann@294
   171
Install method |
yann@294
   172
---------------+
yann@294
   173
yann@294
   174
If you go for the install, then you just follow the classical, but yet easy
yann@294
   175
./configure way:
yann@294
   176
  ./configure --prefix=/some/place
yann@294
   177
  make
yann@294
   178
  make install
yann@294
   179
  export PATH="${PATH}:/some/place/bin"
yann@294
   180
yann@294
   181
You can then get rid of crosstool-NG source. Next create a directory to serve
yann@294
   182
as a working place, cd in there and run:
yann@294
   183
  ct-ng help
yann@294
   184
yann@294
   185
See below for complete usage.
yann@294
   186
yann@294
   187
The Hacker's way |
yann@294
   188
-----------------+
yann@294
   189
yann@294
   190
If you go the hacker's way, then the usage is a bit different, although very
yann@294
   191
simple:
yann@294
   192
  ./configure --local
yann@294
   193
  make
yann@294
   194
yann@294
   195
Now, *do not* remove crosstool-NG sources. They are needed to run crosstool-NG!
yann@294
   196
Stay in the directory holding the sources, and run:
yann@294
   197
  ./ct-ng help
yann@294
   198
yann@294
   199
See below for complete usage.
yann@294
   200
yann@1554
   201
Now, provided you used a clone of the repository, you can send me your changes.
yann@1575
   202
See the section titled CONTRIBUTING, below, for how to submit changees.
yann@294
   203
yann@1048
   204
Preparing for packaging |
yann@1048
   205
------------------------+
yann@1048
   206
yann@1048
   207
If you plan on packaging crosstool-NG, you surely don't want to install it
yann@1048
   208
in your root file system. The install procedure of crosstool-NG honors the
yann@1048
   209
DESTDIR variable:
yann@1048
   210
yann@1048
   211
  ./configure --prefix=/usr
yann@1048
   212
  make
rpjday@1291
   213
  make DESTDIR=/packaging/place install
yann@1048
   214
yann@837
   215
Shell completion |
yann@837
   216
-----------------+
yann@837
   217
yann@837
   218
crosstool-NG comes with a shell script fragment that defines bash-compatible
yann@837
   219
completion. That shell fragment is currently not installed automatically, but
yann@837
   220
this is planned.
yann@837
   221
yann@837
   222
To install the shell script fragment, you have two options:
yann@837
   223
 - install system-wide, most probably by copying ct-ng.comp into
yann@837
   224
   /etc/bash_completion.d/
yann@837
   225
 - install for a single user, by copying ct-ng.comp into ${HOME}/ and
yann@837
   226
   sourcing this file from your ${HOME}/.bashrc
yann@837
   227
yann@456
   228
Contributed code |
yann@456
   229
-----------------+
yann@456
   230
yann@456
   231
Some people contibuted code that couldn't get merged for various reasons. This
yann@1574
   232
code is available as lzma-compressed patches, in the contrib/ sub-directory.
yann@1574
   233
These patches are to be applied to the source of crosstool-NG, prior to
yann@1574
   234
installing, using something like the following:
yann@1574
   235
  lzcat contrib/foobar.patch.lzma |patch -p1
yann@620
   236
yann@620
   237
There is no guarantee that a particuliar contribution applies to the current
yann@620
   238
version of crosstool-ng, or that it will work at all. Use contributions at
yann@620
   239
your own risk.
yann@620
   240
yann@1580
   241
yann@168
   242
____________________________
yann@168
   243
                           /
yann@168
   244
Configuring crosstool-NG  /
yann@168
   245
_________________________/
yann@168
   246
yann@620
   247
crosstool-NG is configured with a configurator presenting a menu-stuctured set
yann@620
   248
of options. These options let you specify the way you want your toolchain
yann@620
   249
built, where you want it installed, what architecture and specific processor it
yann@277
   250
will support, the version of the components you want to use, etc... The
yann@277
   251
value for those options are then stored in a configuration file.
yann@277
   252
yann@476
   253
The configurator works the same way you configure your Linux kernel. It is
yann@277
   254
assumed you now how to handle this.
yann@168
   255
yann@168
   256
To enter the menu, type:
yann@192
   257
  ct-ng menuconfig
yann@168
   258
yann@203
   259
Almost every config item has a help entry. Read them carefully.
yann@168
   260
yann@168
   261
String and number options can refer to environment variables. In such a case,
yann@192
   262
you must use the shell syntax: ${VAR}. You shall neither single- nor double-
yann@294
   263
quote the string/number options.
yann@168
   264
yann@192
   265
There are three environment variables that are computed by crosstool-NG, and
yann@168
   266
that you can use:
yann@168
   267
yann@168
   268
CT_TARGET:
yann@335
   269
  It represents the target tuple you are building for. You can use it for
yann@168
   270
  example in the installation/prefix directory, such as:
yann@168
   271
    /opt/x-tools/${CT_TARGET}
yann@168
   272
yann@168
   273
CT_TOP_DIR:
yann@182
   274
  The top directory where crosstool-NG is running. You shouldn't need it in
yann@182
   275
  most cases. There is one case where you may need it: if you have local
yann@182
   276
  patches and you store them in your running directory, you can refer to them
yann@168
   277
  by using CT_TOP_DIR, such as:
yann@168
   278
    ${CT_TOP_DIR}/patches.myproject
yann@168
   279
yann@168
   280
CT_VERSION:
yann@192
   281
  The version of crosstool-NG you are using. Not much use for you, but it's
yann@168
   282
  there if you need it.
yann@168
   283
yann@168
   284
Interesting config options |
yann@476
   285
---------------------------+
yann@168
   286
yann@168
   287
CT_LOCAL_TARBALLS_DIR:
yann@277
   288
  If you already have some tarballs in a direcotry, enter it here. That will
yann@197
   289
  speed up the retrieving phase, where crosstool-NG would otherwise download
yann@168
   290
  those tarballs.
yann@168
   291
yann@168
   292
CT_PREFIX_DIR:
yann@168
   293
  This is where the toolchain will be installed in (and for now, where it
yann@437
   294
  will run from). Common use is to add the target tuple in the directory
yann@277
   295
  path, such as (see above):
yann@277
   296
    /opt/x-tools/${CT_TARGET}
yann@168
   297
yann@168
   298
CT_TARGET_VENDOR:
yann@168
   299
  An identifier for your toolchain, will take place in the vendor part of the
yann@335
   300
  target tuple. It shall *not* contain spaces or dashes. Usually, keep it
yann@168
   301
  to a one-word string, or use underscores to separate words if you need.
yann@168
   302
  Avoid dots, commas, and special characters.
yann@168
   303
yann@168
   304
CT_TARGET_ALIAS:
yann@168
   305
  An alias for the toolchian. It will be used as a prefix to the toolchain
yann@168
   306
  tools. For example, you will have ${CT_TARGET_ALIAS}-gcc
yann@168
   307
yann@246
   308
Also, if you think you don't see enough versions, you can try to enable one of
yann@246
   309
those:
yann@246
   310
yann@246
   311
CT_OBSOLETE:
yann@246
   312
  Show obsolete versions or tools. Most of the time, you don't want to base
yann@246
   313
  your toolchain on too old a version (of gcc, for example). But at times, it
yann@246
   314
  can come handy to use such an old version for regression tests. Those old
yann@1300
   315
  versions are hidden behind CT_OBSOLETE. Those versions (or features) are so
yann@1300
   316
  marked because maintaining support for those in crosstool-NG would be too
yann@1300
   317
  costly, time-wise, and time is dear.
yann@246
   318
yann@246
   319
CT_EXPERIMENTAL:
yann@246
   320
  Show experimental versions or tools. Again, you might not want to base your
yann@246
   321
  toolchain on too recent tools (eg. gcc) for production. But if you need a
yann@246
   322
  feature present only in a recent version, or a new tool, you can find them
yann@1300
   323
  hidden behind CT_EXPERIMENTAL. Those versions (or features) did not (yet)
yann@1300
   324
  receive thorough testing in crosstool-NG, and/or are not mature enough to
yann@1300
   325
  be blindly trusted.
yann@246
   326
yann@276
   327
Re-building an existing toolchain |
yann@276
   328
----------------------------------+
yann@276
   329
yann@276
   330
If you have an existing toolchain, you can re-use the options used to build it
yann@276
   331
to create a new toolchain. That needs a very little bit of effort on your side
yann@894
   332
but is quite easy. The options to build a toolchain are saved with the
yann@894
   333
toolchain, and you can retrieve this configuration by running:
yann@1803
   334
  ${CT_TARGET}-ct-ng.config
yann@276
   335
yann@1803
   336
An alternate method is to extract the configuration from a build.log file.
yann@1803
   337
This will be necessary if your toolchain was build with crosstool-NG prior
yann@1803
   338
to 1.4.0, but can be used with build.log files from any version:
yann@1803
   339
  ct-ng extractconfig <build.log >.config
yann@1803
   340
yann@1803
   341
Or, if your build.log file is compressed (most probably!):
yann@1803
   342
  bzcat build.log.bz2 |ct-ng extractconfig >.config
yann@1803
   343
yann@1803
   344
The above commands will dump the configuration to stdout, so to rebuild a
yann@1803
   345
toolchain with this configuration, just redirect the output to the
yann@1803
   346
.config file:
yann@1803
   347
  ${CT_TARGET}-ct-ng.config >.config
yann@1098
   348
  ct-ng oldconfig
yann@276
   349
yann@894
   350
Then, you can review and change the configuration by running:
yann@894
   351
  ct-ng menuconfig
yann@276
   352
yann@1580
   353
yann@168
   354
________________________
yann@168
   355
                       /
yann@168
   356
Running crosstool-NG  /
yann@168
   357
_____________________/
yann@1
   358
yann@168
   359
To build the toolchain, simply type:
yann@203
   360
  ct-ng build
yann@135
   361
yann@135
   362
This will use the above configuration to retrieve, extract and patch the
yann@135
   363
components, build, install and eventually test your newly built toolchain.
yann@1
   364
yann@1
   365
You are then free to add the toolchain /bin directory in your PATH to use
yann@1
   366
it at will.
yann@1
   367
yann@135
   368
In any case, you can get some terse help. Just type:
yann@192
   369
  ct-ng help
yann@203
   370
or:
yann@203
   371
  man 1 ct-ng
yann@135
   372
rpjday@436
   373
Stopping and restarting a build |
yann@476
   374
--------------------------------+
yann@135
   375
yann@135
   376
If you want to stop the build after a step you are debugging, you can pass the
yann@135
   377
variable STOP to make:
fr@1643
   378
  ct-ng build STOP=some_step
yann@135
   379
yann@135
   380
Conversely, if you want to restart a build at a specific step you are
yann@135
   381
debugging, you can pass the RESTART variable to make:
fr@1643
   382
  ct-ng build RESTART=some_step
yann@135
   383
yann@136
   384
Alternatively, you can call make with the name of a step to just do that step:
yann@192
   385
  ct-ng libc_headers
yann@136
   386
is equivalent to:
fr@1643
   387
  ct-ng build RESTART=libc_headers STOP=libc_headers
yann@136
   388
yann@304
   389
The shortcuts +step_name and step_name+ allow to respectively stop or restart
yann@136
   390
at that step. Thus:
fr@1643
   391
  ct-ng +libc_headers              and:    ct-ng libc_headers+
yann@136
   392
are equivalent to:
fr@1643
   393
  ct-ng build STOP=libc_headers    and:    ct-ng build RESTART=libc_headers
yann@136
   394
yann@181
   395
To obtain the list of acceptable steps, please call:
yann@544
   396
  ct-ng list-steps
yann@181
   397
yann@168
   398
Note that in order to restart a build, you'll have to say 'Y' to the config
yann@168
   399
option CT_DEBUG_CT_SAVE_STEPS, and that the previous build effectively went
yann@168
   400
that far.
yann@92
   401
yann@1025
   402
Building all toolchains at once |
yann@1025
   403
--------------------------------+
yann@92
   404
yann@1025
   405
You can build all samples; simply call:
yann@1025
   406
  ct-ng build-all
yann@40
   407
yann@335
   408
Overriding the number of // jobs |
yann@476
   409
---------------------------------+
yann@335
   410
yann@335
   411
If you want to override the number of jobs to run in // (the -j option to
yann@335
   412
make), you can either re-enter the menuconfig, or simply add it on the command
yann@335
   413
line, as such:
yann@335
   414
  ct-ng build.4
yann@335
   415
yann@335
   416
which tells crosstool-NG to override the number of // jobs to 4.
yann@335
   417
yann@335
   418
You can see the actions that support overriding the number of // jobs in
yann@335
   419
the help menu. Those are the ones with [.#] after them (eg. build[.#] or
yann@1025
   420
build-all[.#], and so on...).
yann@1025
   421
yann@1025
   422
Note on // jobs |
yann@1025
   423
----------------+
yann@1025
   424
yann@1025
   425
The crosstool-NG script 'ct-ng' is a Makefile-script. It does *not* execute
yann@1025
   426
in parallel (there is not much to gain). When speaking of // jobs, we are
yann@1025
   427
refering to the number of // jobs when making the *components*. That is, we
yann@1025
   428
speak of the number of // jobs used to build gcc, glibc, and so on...
yann@1025
   429
yann@1493
   430
Tools wrapper |
yann@1493
   431
--------------+
yann@1493
   432
yann@1493
   433
Starting with gcc-4.3 come two new dependencies: GMP and MPFR. With gcc-4.4,
yann@1493
   434
come three new ones: GMP, PPL and CLooG/ppl. These are libraries that enable
yann@1493
   435
advanced features to gcc. Additionally, some of the libraries can be used by
yann@1493
   436
binutils and gdb. Unfortunately, not all systems on which crosstool-NG runs
yann@1493
   437
have all of those libraries. And for those that do, the versions of those
yann@1493
   438
libraries may be older than the version required by gcc.
yann@1493
   439
yann@1493
   440
This is why crosstool-NG builds its own set of libraries as part of the
yann@1493
   441
toolchain.
yann@1493
   442
yann@1493
   443
The libraries are built as shared libraries, because building them as static
yann@1493
   444
libraries has some short-comings. This poses no problem at build time, as
yann@1513
   445
crosstool-NG correctly points gcc (and binutils and gdb) to the correct
yann@1493
   446
place where our own version of the libraries are installed. But it poses
yann@1493
   447
a problem when gcc et al. are run: the place where the libraries are is most
yann@1493
   448
probably not known to the host dynamic linker. Still worse, if the host system
yann@1493
   449
has its own versions, then ld.so would load the wrong library!
yann@1493
   450
yann@1493
   451
So we have to force the dynamic linker to load the correct version. We do this
yann@1493
   452
by using the LD_LIBRARY_PATH variable, that informs the dynamic linker where
yann@1493
   453
to look for shared libraries prior to searching its standard places. But we
yann@1493
   454
can't impose that burden on all the system (because it'd be a nightmare to
yann@1513
   455
configure, and because two toolchains on the same system may use different
yann@1493
   456
versions of the libraries); so we have to do it on a per-toolchain basis.
yann@1493
   457
yann@1493
   458
So we rename all binaries of the toolchain (by adding a dot '.' as their first
yann@1493
   459
character), and add a small program, the so-called "tools wrapper", that
yann@1493
   460
correctly sets LD_LIBRARY_PATH prior to running the real tool.
yann@1493
   461
yann@1493
   462
First, the wrapper was written as a POSIX-compliant shell script. That shell
yann@1493
   463
script is very simple, if not trivial, and works great. The only drawback is
yann@1493
   464
that it does not work on host systems that lack a shell, for example the
yann@1493
   465
MingW32 environment. To solve the issue, the wrapper has been re-written in C,
yann@1493
   466
and compiled at build time. This C wrapper is much more complex than the shell
yann@1493
   467
script, and although it sems to be working, it's been only lightly tested.
yann@1493
   468
Some of the expected short-comings with this C wrapper are;
yann@1493
   469
 - multi-byte file names may not be handled correctly
yann@1493
   470
 - it's really big for what it does
yann@1493
   471
yann@1493
   472
So, the default wrapper installed with your toolchain is the shell script.
yann@1493
   473
If you know that your system is missing a shell, then you shall use the C
yann@1493
   474
wrapper (and report back whether it works, or does not work, for you).
yann@1493
   475
yann@335
   476
yann@227
   477
_______________________
yann@227
   478
                      /
yann@227
   479
Using the toolchain  /
yann@227
   480
____________________/
yann@227
   481
yann@227
   482
Using the toolchain is as simple as adding the toolchain's bin directory in
yann@227
   483
your PATH, such as:
yann@227
   484
  export PATH="${PATH}:/your/toolchain/path/bin"
yann@227
   485
yann@335
   486
and then using the target tuple to tell the build systems to use your
yann@227
   487
toolchain:
yann@335
   488
  ./configure --target=your-target-tuple
yann@294
   489
or
yann@335
   490
  make CC=your-target-tuple-gcc
yann@294
   491
or
yann@335
   492
  make CROSS_COMPILE=your-target-tuple-
yann@294
   493
and so on...
yann@227
   494
yann@476
   495
It is strongly advised not to use the toolchain sys-root directory as an
yann@620
   496
install directory for your programs/packages. If you do so, you will not be
yann@476
   497
able to use your toolchain for another project. It is even strongly advised
yann@476
   498
that your toolchain is chmod-ed to read-only once successfully build, so that
yann@620
   499
you don't go polluting your toolchain with your programs/packages' files.
yann@476
   500
yann@476
   501
Thus, when you build a program/package, install it in a separate directory,
yann@476
   502
eg. /your/root. This directory is the /image/ of what would be in the root file
yann@620
   503
system of your target, and will contain all that your programs/packages have
yann@476
   504
installed.
yann@476
   505
Yann@1405
   506
The 'populate' script |
Yann@1405
   507
----------------------+
Yann@1405
   508
yann@227
   509
When your root directory is ready, it is still missing some important bits: the
yann@227
   510
toolchain's libraries. To populate your root directory with those libs, just
yann@227
   511
run:
yann@335
   512
  your-target-tuple-populate -s /your/root -d /your/root-populated
yann@227
   513
yann@227
   514
This will copy /your/root into /your/root-populated, and put the needed and only
yann@227
   515
the needed libraries there. Thus you don't polute /your/root with any cruft that
yann@227
   516
would no longer be needed should you have to remove stuff. /your/root always
yann@227
   517
contains only those things you install in it.
yann@227
   518
yann@227
   519
You can then use /your/root-populated to build up your file system image, a
yann@227
   520
tarball, or to NFS-mount it from your target, or whatever you need.
yann@227
   521
Yann@1405
   522
The populate script accepts the following options:
yann@294
   523
Yann@1405
   524
 -s src_dir
Yann@1405
   525
    Use 'src_dir' as the un-populated root directory.
yann@294
   526
Yann@1405
   527
 -d dst_dir
Yann@1405
   528
    Put the populated root directory in 'dst_dir'.
Yann@1405
   529
Yann@1405
   530
 -l lib1 [...]
Yann@1405
   531
    Always add specified libraries.
Yann@1405
   532
Yann@1405
   533
 -L file
Yann@1405
   534
    Always add libraries listed in 'file'.
yann@294
   535
yann@294
   536
 -f
Yann@1405
   537
    Remove 'dst_dir' if it previously existed; continue even if any library
Yann@1405
   538
    specified with -l or -L is missing.
yann@294
   539
yann@294
   540
 -v
yann@294
   541
    Be verbose, and tell what's going on (you can see exactly where libs are
yann@294
   542
    coming from).
yann@294
   543
yann@294
   544
 -h
Yann@1405
   545
    Print the help.
Yann@1405
   546
Yann@1405
   547
See 'your-target-tuple-populate -h' for more information on the options.
yann@294
   548
Yann@1406
   549
Here is how populate works:
Yann@1406
   550
Yann@1406
   551
  1) performs some sanity checks:
Yann@1406
   552
     - src_dir and dst_dir are specified
Yann@1406
   553
     - src_dir exists
Yann@1406
   554
     - unless forced, dst_dir does not exist
Yann@1406
   555
     - src_dir != dst_dir
Yann@1406
   556
Yann@1406
   557
  2) copy src_dir to dst_dir
Yann@1406
   558
Yann@1406
   559
  3) add forced libraries to dst_dir
Yann@1406
   560
     - build the list from -l and -L options
Yann@1406
   561
     - get forced libraries from the sysroot (see below for heuristics)
Yann@1406
   562
       - abort on the first missing library, unless -f is specified
Yann@1406
   563
Yann@1406
   564
  4) add all missing libraries to dst_dir
Yann@1406
   565
     - scan dst_dir for every ELF files that are 'executable' or
Yann@1406
   566
       'shared object'
Yann@1406
   567
     - list the "NEEDED Shared library" fields
Yann@1406
   568
       - check if the library is already in dst_dir/lib or dst_dir/usr/lib
Yann@1406
   569
       - if not, get the library from the sysroot
Yann@1406
   570
         - if it's in sysroot/lib, copy it to dst_dir/lib
Yann@1406
   571
         - if it's in sysroot/usr/lib, copy it to dst_dir/usr/lib
Yann@1406
   572
         - in both cases, use the SONAME of the library to create the file
Yann@1406
   573
           in dst_dir
Yann@1406
   574
         - if it was not found in the sysroot, this is an error.
Yann@1406
   575
yann@1580
   576
yann@40
   577
___________________
yann@40
   578
                  /
yann@40
   579
Toolchain types  /
yann@40
   580
________________/
yann@40
   581
yann@40
   582
There are four kinds of toolchains you could encounter.
yann@40
   583
yann@40
   584
First off, you must understand the following: when it comes to compilers there
yann@40
   585
are up to four machines involved:
yann@40
   586
  1) the machine configuring the toolchain components: the config machine
yann@40
   587
  2) the machine building the toolchain components:    the build machine
yann@40
   588
  3) the machine running the toolchain:                the host machine
yann@203
   589
  4) the machine the toolchain is generating code for: the target machine
yann@40
   590
yann@40
   591
We can most of the time assume that the config machine and the build machine
yann@40
   592
are the same. Most of the time, this will be true. The only time it isn't
yann@40
   593
is if you're using distributed compilation (such as distcc). Let's forget
yann@40
   594
this for the sake of simplicity.
yann@40
   595
yann@40
   596
So we're left with three machines:
yann@40
   597
 - build
yann@40
   598
 - host
yann@40
   599
 - target
yann@40
   600
yann@40
   601
Any toolchain will involve those three machines. You can be as pretty sure of
yann@40
   602
this as "2 and 2 are 4". Here is how they come into play:
yann@40
   603
yann@40
   604
1) build == host == target
yann@40
   605
    This is a plain native toolchain, targetting the exact same machine as the
yann@40
   606
    one it is built on, and running again on this exact same machine. You have
yann@40
   607
    to build such a toolchain when you want to use an updated component, such
yann@40
   608
    as a newer gcc for example.
yann@197
   609
    crosstool-NG calls it "native".
yann@40
   610
yann@40
   611
2) build == host != target
yann@40
   612
    This is a classic cross-toolchain, which is expected to be run on the same
yann@40
   613
    machine it is compiled on, and generate code to run on a second machine,
yann@40
   614
    the target.
yann@197
   615
    crosstool-NG calls it "cross".
yann@40
   616
yann@40
   617
3) build != host == target
yann@40
   618
    Such a toolchain is also a native toolchain, as it targets the same machine
yann@40
   619
    as it runs on. But it is build on another machine. You want such a
yann@40
   620
    toolchain when porting to a new architecture, or if the build machine is
yann@40
   621
    much faster than the host machine.
yann@197
   622
    crosstool-NG calls it "cross-native".
yann@40
   623
yann@40
   624
4) build != host != target
yann@92
   625
    This one is called a canadian-toolchain (*), and is tricky. The three
yann@40
   626
    machines in play are different. You might want such a toolchain if you
yann@40
   627
    have a fast build machine, but the users will use it on another machine,
yann@40
   628
    and will produce code to run on a third machine.
yann@197
   629
    crosstool-NG calls it "canadian".
yann@40
   630
yann@197
   631
crosstool-NG can build all these kinds of toolchains (or is aiming at it,
yann@197
   632
anyway!)
yann@40
   633
yann@40
   634
(*) The term Canadian Cross came about because at the time that these issues
yann@40
   635
    were all being hashed out, Canada had three national political parties.
yann@40
   636
    http://en.wikipedia.org/wiki/Cross_compiler
yann@40
   637
yann@1551
   638
yann@1575
   639
________________
yann@1575
   640
               /
yann@1575
   641
Contributing  /
yann@1575
   642
_____________/
yann@1575
   643
yann@1575
   644
Sending a bug report |
yann@1575
   645
---------------------+
yann@1575
   646
yann@1575
   647
If you need to send a bug report, please send a mail with subject
yann@1575
   648
prefixed with "[CT_NG]" with to following destinations:
yann@1575
   649
    TO: yann.morin.1998 (at) anciens.enib.fr
yann@1575
   650
    CC: crossgcc (at) sourceware.org
yann@1575
   651
yann@1575
   652
Sending patches |
yann@1575
   653
----------------+
yann@1575
   654
yann@1575
   655
If you want to enhance crosstool-NG, there's a to-do list in the TODO file.
yann@1575
   656
yann@1575
   657
Patches should come with the appropriate SoB line. A SoB line is typically
yann@1575
   658
something like:
yann@1575
   659
   Signed-off-by: John DOE <john.doe@somewhere.net>
yann@1575
   660
yann@1575
   661
The SoB line is clearly described in Documentation/SubmittingPatches , section
yann@1575
   662
12, of your favourite Linux kernel source tree.
yann@1575
   663
yann@1575
   664
Then you'll need to correctly configure Mercurial. There are two extensions
yann@1575
   665
that you may find usefull:
yann@1575
   666
  - mq        : http://mercurial.selenic.com/wiki/MqExtension
yann@1575
   667
  - patchbomb : http://mercurial.selenic.com/wiki/PatchbombExtension
yann@1575
   668
yann@1575
   669
Commit messages should look like (without leading pipes):
yann@1575
   670
 |component: short, one-line description
yann@1575
   671
 |
yann@1575
   672
 |optional longer description
yann@1575
   673
 |on multiple lines if needed
yann@1575
   674
yann@1575
   675
Here is an example commit message (see revision a53a5e1d61db):
yann@1575
   676
 |comp-libs/cloog: fix building
yann@1575
   677
 |
yann@1575
   678
 |For CLooG/PPL 0.15.3, the directory name was simply cloog-ppl.
yann@1575
   679
 |For any later versions, the directory name does have the version, such as
yann@1575
   680
 |cloog-ppl-0.15.4.
yann@1575
   681
yann@1575
   682
Here's a typical hacking session:
yann@1575
   683
  hg clone http://ymorin.is-a-geek.org/hg/crosstool-ng crosstool-ng
yann@1575
   684
  cd crosstool-ng
yann@1575
   685
  hg qinit
yann@1575
   686
  hg qnew -D -U -e my_first_patch
yann@1575
   687
  *edit patch description*
yann@1575
   688
  *hack* *hack* *check* *fails* *hack* *hack* *check* *works*
yann@1575
   689
  hg qref -D -e
yann@1575
   690
  *edit patch description, serving as commit message*
yann@1575
   691
  hg qnew -D -U -e my_second_patch
yann@1575
   692
  *edit patch description*
yann@1575
   693
  *hack* *hack* *check* *fails* *hack* *hack* *check* *works*
yann@1575
   694
  hg qref -D -e
yann@1575
   695
  *edit patch description, serving as commit message*
yann@1575
   696
  hg email --outgoing --intro   \
yann@1575
   697
           --from '"Your Full NAME" <your.email (at) your.domain>'   \
yann@1575
   698
           --to '"Yann E. MORIN" <yann.morin.1998 (at) anciens.enib.fr>'    \
yann@1575
   699
           --cc 'crossgcc (at) sourceware.org'
yann@1575
   700
  *edit introductory message*
yann@1575
   701
  *wait for feedback*
yann@1575
   702
  *re-send if no answer for a few days*
yann@1575
   703
yann@1575
   704
Note: replace '(at)' above with a plain '@'.
yann@1575
   705
yann@1575
   706
yann@1
   707
_____________
yann@1
   708
            /
yann@1
   709
Internals  /
yann@1
   710
__________/
yann@1
   711
yann@92
   712
Internally, crosstool-NG is script-based. To ease usage, the frontend is
yann@92
   713
Makefile-based.
yann@92
   714
yann@92
   715
Makefile front-end |
yann@476
   716
-------------------+
yann@92
   717
yann@203
   718
The entry point to crosstool-NG is the Makefile script "ct-ng". Calling this
yann@203
   719
script with an action will act exactly as if the Makefile was in the current
yann@203
   720
working directory and make was called with the action as rule. Thus:
yann@203
   721
  ct-ng menuconfig
yann@294
   722
yann@203
   723
is equivalent to having the Makefile in CWD, and calling:
yann@203
   724
  make menuconfig
yann@203
   725
yann@203
   726
Having ct-ng as it is avoids copying the Makefile everywhere, and acts as a
yann@203
   727
traditional command.
yann@203
   728
yann@203
   729
ct-ng loads sub- Makefiles from the library directory $(CT_LIB_DIR), as set up
yann@203
   730
at configuration time with ./configure.
yann@203
   731
yann@437
   732
ct-ng also searches for config files, sub-tools, samples, scripts and patches in
yann@203
   733
that library directory.
yann@92
   734
yann@294
   735
Because of a stupid make behavior/bug I was unable to track down, implicit make
yann@294
   736
rules are disabled: installing with --local would triger those rules, and mconf
yann@294
   737
was unbuildable.
yann@294
   738
yann@182
   739
Kconfig parser |
yann@476
   740
---------------+
yann@92
   741
yann@965
   742
The kconfig language is a hacked version, vampirised from the Linux kernel
yann@965
   743
(http://www.kernel.org/), and (heavily) adapted to my needs.
yann@92
   744
yann@1040
   745
The list of the most notable changes (at least the ones I remember) follows:
yann@1040
   746
- the CONFIG_ prefix has been replaced with CT_
yann@1040
   747
- a leading | in prompts is skipped, and subsequent leading spaces are not
yann@1040
   748
  trimmed
yann@1040
   749
- otherwise leading spaces are silently trimmed
yann@1040
   750
yann@203
   751
The kconfig parsers (conf and mconf) are not installed pre-built, but as
yann@203
   752
source files. Thus you can have the directory where crosstool-NG is installed,
yann@203
   753
exported (via NFS or whatever) and have clients with different architectures
yann@203
   754
use the same crosstool-NG installation, and most notably, the same set of
yann@203
   755
patches.
yann@203
   756
yann@381
   757
Architecture-specific |
yann@476
   758
----------------------+
yann@381
   759
yann@628
   760
Note: this chapter is not really well written, and might thus be a little bit
yann@628
   761
complex to understand. To get a better grasp of what an architecture is, the
yann@628
   762
reader is kindly encouraged to look at the "arch/" sub-directory, and to the
yann@628
   763
existing architectures to see how things are laid out.
yann@628
   764
yann@381
   765
An architecture is defined by:
yann@381
   766
yann@381
   767
 - a human-readable name, in lower case letters, with numbers as appropriate.
yann@628
   768
   The underscore is allowed; space and special characters are not.
yann@628
   769
     Eg.: arm, x86_64
yann@903
   770
 - a file in "config/arch/", named after the architecture's name, and suffixed
yann@903
   771
   with ".in".
yann@903
   772
     Eg.: config/arch/arm.in
yann@903
   773
 - a file in "scripts/build/arch/", named after the architecture's name, and
yann@903
   774
   suffixed with ".sh".
yann@903
   775
     Eg.: scripts/build/arch/arm.sh
yann@628
   776
yann@903
   777
The architecture's ".in" file API:
yann@628
   778
 > the config option "ARCH_%arch%" (where %arch% is to be replaced with the
yann@628
   779
   actual architecture name).
yann@628
   780
   That config option must have *neither* a type, *nor* a prompt! Also, it can
yann@628
   781
   *not* depend on any other config option (EXPERIMENTAL is managed as above).
yann@628
   782
     Eg.:
yann@628
   783
       config ARCH_arm
yann@630
   784
   + mandatory:
yann@702
   785
       defines a (terse) help entry for this architecture:
yann@630
   786
       Eg.:
yann@630
   787
         config ARCH_arm
yann@630
   788
           help
yann@630
   789
             The ARM architecture.
yann@628
   790
   + optional:
yann@628
   791
       selects adequate associated config options.
yann@1038
   792
       Note: 64-bit architectures *shall* select ARCH_64
yann@628
   793
       Eg.:
yann@628
   794
         config ARCH_arm
yann@628
   795
           select ARCH_SUPPORTS_BOTH_ENDIAN
yann@628
   796
           select ARCH_DEFAULT_LE
yann@630
   797
           help
yann@630
   798
             The ARM architecture.
yann@1038
   799
       Eg.:
yann@1038
   800
         config ARCH_x86_64
yann@1038
   801
            select ARCH_64
yann@1038
   802
            help
yann@1038
   803
              The x86_64 architecture.
yann@628
   804
yann@628
   805
 > other target-specific options, at your discretion. Note however that to
yann@628
   806
   avoid name-clashing, such options shall be prefixed with "ARCH_%arch%",
yann@628
   807
   where %arch% is again replaced by the actual architecture name.
yann@628
   808
   (Note: due to historical reasons, and lack of time to clean up the code,
yann@628
   809
    I may have left some config options that do not completely conform to
yann@628
   810
    this, as the architecture name was written all upper case. However, the
yann@628
   811
    prefix is unique among architectures, and does not cause harm).
yann@381
   812
yann@903
   813
The architecture's ".sh" file API:
yann@965
   814
 > the function "CT_DoArchTupleValues"
yann@381
   815
   + parameters: none
yann@381
   816
   + environment:
yann@901
   817
     - all variables from the ".config" file,
yann@901
   818
     - the two variables "target_endian_eb" and "target_endian_el" which are
yann@901
   819
       the endianness suffixes
yann@381
   820
   + return value: 0 upon success, !0 upon failure
yann@381
   821
   + provides:
yann@391
   822
     - mandatory
yann@383
   823
     - the environment variable CT_TARGET_ARCH
yann@389
   824
     - contains:
yann@389
   825
       the architecture part of the target tuple.
yann@389
   826
       Eg.: "armeb" for big endian ARM
yann@389
   827
            "i386" for an i386
yann@389
   828
   + provides:
yann@391
   829
     - optional
yann@389
   830
     - the environment variable CT_TARGET_SYS
yann@456
   831
     - contains:
yann@383
   832
       the sytem part of the target tuple.
yann@383
   833
       Eg.: "gnu" for glibc on most architectures
yann@383
   834
            "gnueabi" for glibc on an ARM EABI
yann@383
   835
     - defaults to:
yann@383
   836
       - for glibc-based toolchain: "gnu"
yann@383
   837
       - for uClibc-based toolchain: "uclibc"
yann@383
   838
   + provides:
yann@383
   839
     - optional
yann@767
   840
     - the environment variables to configure the cross-gcc (defaults)
yann@767
   841
       - CT_ARCH_WITH_ARCH    : the gcc ./configure switch to select architecture level         ( "--with-arch=${CT_ARCH_ARCH}"   )
yann@767
   842
       - CT_ARCH_WITH_ABI     : the gcc ./configure switch to select ABI level                  ( "--with-abi=${CT_ARCH_ABI}"     )
yann@767
   843
       - CT_ARCH_WITH_CPU     : the gcc ./configure switch to select CPU instruction set        ( "--with-cpu=${CT_ARCH_CPU}"     )
yann@767
   844
       - CT_ARCH_WITH_TUNE    : the gcc ./configure switch to select scheduling                 ( "--with-tune=${CT_ARCH_TUNE}"   )
yann@767
   845
       - CT_ARCH_WITH_FPU     : the gcc ./configure switch to select FPU type                   ( "--with-fpu=${CT_ARCH_FPU}"     )
yann@767
   846
       - CT_ARCH_WITH_FLOAT   : the gcc ./configure switch to select floating point arithmetics ( "--with-float=soft" or /empty/  )
yann@391
   847
   + provides:
yann@391
   848
     - optional
yann@767
   849
     - the environment variables to pass to the cross-gcc to build target binaries (defaults)
yann@391
   850
       - CT_ARCH_ARCH_CFLAG   : the gcc switch to select architecture level                     ( "-march=${CT_ARCH_ARCH}"            )
yann@456
   851
       - CT_ARCH_ABI_CFLAG    : the gcc switch to select ABI level                              ( "-mabi=${CT_ARCH_ABI}"              )
yann@391
   852
       - CT_ARCH_CPU_CFLAG    : the gcc switch to select CPU instruction set                    ( "-mcpu=${CT_ARCH_CPU}"              )
yann@391
   853
       - CT_ARCH_TUNE_CFLAG   : the gcc switch to select scheduling                             ( "-mtune=${CT_ARCH_TUNE}"            )
yann@391
   854
       - CT_ARCH_FPU_CFLAG    : the gcc switch to select FPU type                               ( "-mfpu=${CT_ARCH_FPU}"              )
yann@391
   855
       - CT_ARCH_FLOAT_CFLAG  : the gcc switch to choose floating point arithmetics             ( "-msoft-float" or /empty/           )
yann@391
   856
       - CT_ARCH_ENDIAN_CFLAG : the gcc switch to choose big or little endian                   ( "-mbig-endian" or "-mlittle-endian" )
yann@391
   857
     - default to:
yann@391
   858
       see above.
yann@767
   859
   + provides:
yann@767
   860
     - optional
yann@767
   861
     - the environement variables to configure the core and final compiler, specific to this architecture:
yann@767
   862
       - CT_ARCH_CC_CORE_EXTRA_CONFIG   : additional, architecture specific core gcc ./configure flags
yann@767
   863
       - CT_ARCH_CC_EXTRA_CONFIG        : additional, architecture specific final gcc ./configure flags
yann@767
   864
     - default to:
yann@767
   865
       - all empty
yann@767
   866
   + provides:
yann@767
   867
     - optional
yann@767
   868
     - the architecture-specific CFLAGS and LDFLAGS:
yann@767
   869
       - CT_ARCH_TARGET_CLFAGS
yann@767
   870
       - CT_ARCH_TARGET_LDFLAGS
yann@767
   871
     - default to:
yann@767
   872
       - all empty
yann@628
   873
yann@903
   874
You can have a look at "config/arch/arm.in" and "scripts/build/arch/arm.sh" for
yann@903
   875
a quite complete example of what an actual architecture description looks like.
yann@901
   876
yann@890
   877
Kernel specific |
yann@890
   878
----------------+
yann@890
   879
yann@890
   880
A kernel is defined by:
yann@890
   881
yann@890
   882
 - a human-readable name, in lower case letters, with numbers as appropriate.
yann@890
   883
   The underscore is allowed; space and special characters are not (although
yann@890
   884
   they are internally replaced with underscores.
yann@890
   885
     Eg.: linux, bare-metal
yann@890
   886
 - a file in "config/kernel/", named after the kernel name, and suffixed with
yann@890
   887
   ".in".
yann@890
   888
     Eg.: config/kernel/linux.in, config/kernel/bare-metal.in
yann@901
   889
 - a file in "scripts/build/kernel/", named after the kernel name, and suffixed
yann@901
   890
   with ".sh".
yann@901
   891
     Eg.: scripts/build/kernel/linux.sh, scripts/build/kernel/bare-metal.sh
yann@890
   892
yann@890
   893
The kernel's ".in" file must contain:
yann@890
   894
 > an optional lines containing exactly "# EXPERIMENTAL", starting on the
yann@890
   895
   first column, and without any following space or other character.
yann@890
   896
   If this line is present, then this kernel is considered EXPERIMENTAL,
yann@890
   897
   and correct dependency on EXPERIMENTAL will be set.
yann@901
   898
yann@890
   899
 > the config option "KERNEL_%kernel_name%" (where %kernel_name% is to be
yann@890
   900
   replaced with the actual kernel name, with all special characters and
yann@890
   901
   spaces replaced by underscores).
yann@890
   902
   That config option must have *neither* a type, *nor* a prompt! Also, it can
yann@890
   903
   *not* depends on EXPERIMENTAL.
yann@890
   904
     Eg.: KERNEL_linux, KERNEL_bare_metal
yann@890
   905
   + mandatory:
yann@890
   906
       defines a (terse) help entry for this kernel.
yann@890
   907
       Eg.:
yann@890
   908
         config KERNEL_bare_metal
yann@890
   909
           help
yann@890
   910
             Build a compiler for use without any kernel.
yann@890
   911
   + optional:
yann@890
   912
       selects adequate associated config options.
yann@890
   913
       Eg.:
yann@890
   914
         config KERNEL_bare_metal
yann@890
   915
           select BARE_METAL
yann@890
   916
           help
yann@890
   917
             Build a compiler for use without any kernel.
yann@890
   918
yann@890
   919
 > other kernel specific options, at your discretion. Note however that, to
yann@890
   920
   avoid name-clashing, such options should be prefixed with
yann@890
   921
   "KERNEL_%kernel_name%", where %kernel_name% is again tp be replaced with
yann@890
   922
   the actual kernel name.
yann@890
   923
   (Note: due to historical reasons, and lack of time to clean up the code,
yann@890
   924
    I may have left some config options that do not completely conform to
yann@890
   925
    this, as the kernel name was written all upper case. However, the prefix
yann@890
   926
    is unique among kernels, and does not cause harm).
yann@890
   927
yann@901
   928
The kernel's ".sh" file API:
yann@901
   929
 > is a bash script fragment
yann@901
   930
yann@965
   931
 > defines the function CT_DoKernelTupleValues
yann@965
   932
   + see the architecture's CT_DoArchTupleValues, except for:
yann@965
   933
   + set the environment variable CT_TARGET_KERNEL, the kernel part of the
yann@965
   934
     target tuple
yann@965
   935
   + return value: ignored
yann@965
   936
yann@901
   937
 > defines the function "do_kernel_get":
yann@901
   938
   + parameters: none
yann@901
   939
   + environment:
yann@901
   940
      - all variables from the ".config" file.
yann@901
   941
   + return value: 0 for success, !0 for failure.
yann@901
   942
   + behavior: download the kernel's sources, and store the tarball into
yann@901
   943
     "${CT_TARBALLS_DIR}". To this end, a functions is available, that
yann@901
   944
     abstracts downloading tarballs:
yann@901
   945
     - CT_DoGet <tarball_base_name> <URL1 [URL...]>
yann@901
   946
       Eg.: CT_DoGet linux-2.6.26.5 ftp://ftp.kernel.org/pub/linux/kernel/v2.6
yann@901
   947
     Note: retrieving sources from svn, cvs, git and the likes is not supported
yann@901
   948
     by CT_DoGet. You'll have to do this by hand, as it is done for eglibc in
yann@901
   949
     "scripts/build/libc/eglibc.sh"
yann@901
   950
yann@901
   951
 > defines the function "do_kernel_extract":
yann@901
   952
   + parameters: none
yann@901
   953
   + environment:
yann@901
   954
      - all variables from the ".config" file,
yann@901
   955
   + return value: 0 for success, !0 for failure.
yann@901
   956
   + behavior: extract the kernel's tarball into "${CT_SRC_DIR}", and apply
yann@901
   957
     required patches. To this end, a function is available, that abstracts
yann@901
   958
     extracting tarballs:
yann@901
   959
     - CT_ExtractAndPatch <tarball_base_name>
yann@901
   960
       Eg.: CT_ExtractAndPatch linux-2.6.26.5
yann@901
   961
yann@901
   962
 > defines the function "do_kernel_headers":
yann@901
   963
   + parameters: none
yann@901
   964
   + environment:
yann@901
   965
      - all variables from the ".config" file,
yann@901
   966
   + return value: 0 for success, !0 for failure.
yann@901
   967
   + behavior: install the kernel headers (if any) in "${CT_SYSROOT_DIR}/usr/include"
yann@901
   968
yann@901
   969
 > defines any kernel-specific helper functions
yann@901
   970
   These functions, if any, must be prefixed with "do_kernel_%CT_KERNEL%_",
yann@901
   971
   where '%CT_KERNEL%' is to be replaced with the actual kernel name, to avoid
yann@901
   972
   any name-clashing.
yann@901
   973
yann@901
   974
You can have a look at "config/kernel/linux.in" and "scripts/build/kernel/linux.sh"
yann@903
   975
as an example of what a complex kernel description looks like.
yann@901
   976
yann@620
   977
Adding a new version of a component |
yann@476
   978
------------------------------------+
yann@476
   979
yann@476
   980
When a new component, such as the Linux kernel, gcc or any other is released,
yann@476
   981
adding the new version to crosstool-NG is quite easy. There is a script that
yann@476
   982
will do all that for you:
yann@1095
   983
  scripts/addToolVersion.sh
yann@476
   984
yann@476
   985
Run it with no option to get some help.
yann@381
   986
yann@203
   987
Build scripts |
yann@476
   988
--------------+
yann@203
   989
yann@203
   990
To Be Written later...