docs/overview.txt
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 13 10:32:38 2008 +0000 (2008-07-13)
changeset 645 8e58024f8e37
parent 628 87802cb25a0f
child 702 1f296e367622
permissions -rw-r--r--
Ioannis E. VENETIS <venetis@mail.capsl.udel.edu> pointed out that GMP and MPFR were not used by gcc.
Turned out that none could use GMP and MPFR as the config option changed its name, but the change was not propagated to all users.

/trunk/scripts/build/binutils.sh | 2 1 1 0 +-
/trunk/scripts/build/debug/300-gdb.sh | 2 1 1 0 +-
/trunk/scripts/build/cc_gcc.sh | 6 3 3 0 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
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@628
    14
Installing crosstool-NG
yann@628
    15
  Install method
yann@628
    16
  The hacker's way
yann@628
    17
  Contributed code
yann@628
    18
Configuring crosstool-NG
yann@628
    19
  Interesting config options
yann@628
    20
  Re-building an existing toolchain
yann@628
    21
Running crosstool-NG
yann@628
    22
  Stopping and restarting a build
yann@628
    23
  Testing all toolchains at once
yann@628
    24
  Overriding the number of // jobs
yann@628
    25
Using the toolchain
yann@628
    26
Toolchain types
yann@628
    27
Internals
yann@628
    28
  Makefile front-end
yann@628
    29
  Kconfig parser
yann@628
    30
  Architecture-specific
yann@628
    31
  Adding a new version of a component
yann@628
    32
  Build scripts
yann@628
    33
yann@1
    34
________________
yann@1
    35
               /
yann@1
    36
Introduction  /
yann@1
    37
_____________/
yann@1
    38
yann@1
    39
crosstool-NG aims at building toolchains. Toolchains are an essential component
yann@1
    40
in a software development project. It will compile, assemble and link the code
rpjday@436
    41
that is being developed. Some pieces of the toolchain will eventually end up
yann@1
    42
in the resulting binary/ies: static libraries are but an example.
yann@1
    43
yann@1
    44
So, a toolchain is a very sensitive piece of software, as any bug in one of the
yann@1
    45
components, or a poorly configured component, can lead to execution problems,
yann@1
    46
ranging from poor performance, to applications ending unexpectedly, to
yann@1
    47
mis-behaving software (which more than often is hard to detect), to hardware
rpjday@436
    48
damage, or even to human risks (which is more than regrettable).
yann@1
    49
yann@1
    50
Toolchains are made of different piece of software, each being quite complex
yann@1
    51
and requiring specially crafted options to build and work seamlessly. This
yann@1
    52
is usually not that easy, even in the not-so-trivial case of native toolchains.
yann@1
    53
The work reaches a higher degree of complexity when it comes to cross-
yann@40
    54
compilation, where it can become quite a nightmare...
yann@1
    55
yann@40
    56
Some cross-toolchains exist on the internet, and can be used for general
yann@1
    57
development, but they have a number of limitations:
yann@1
    58
  - they can be general purpose, in that they are configured for the majority:
yann@1
    59
    no optimisation for your specific target,
yann@1
    60
  - they can be prepared for a specific target and thus are not easy to use,
yann@1
    61
    nor optimised for, or even supporting your target,
rpjday@436
    62
  - they often are using aging components (compiler, C library, etc...) not
yann@1
    63
    supporting special features of your shiny new processor;
yann@1
    64
On the other side, these toolchain offer some advantages:
yann@1
    65
  - they are ready to use and quite easy to install and setup,
yann@1
    66
  - they are proven if used by a wide community.
yann@1
    67
yann@1
    68
But once you want to get all the juice out of your specific hardware, you will
yann@197
    69
want to build your own toolchain. This is where crosstool-NG comes into play.
yann@1
    70
rpjday@436
    71
There are also a number of tools that build toolchains for specific needs,
rpjday@436
    72
which are not really scalable. Examples are:
rpjday@436
    73
  - buildroot (buildroot.uclibc.org) whose main purpose is to build root file
yann@1
    74
    systems, hence the name. But once you have your toolchain with buildroot,
yann@1
    75
    part of it is installed in the root-to-be, so if you want to build a whole
yann@1
    76
    new root, you either have to save the existing one as a template and
yann@1
    77
    restore it later, or restart again from scratch. This is not convenient,
yann@1
    78
  - ptxdist (www.pengutronix.de/software/ptxdist), whose purpose is very
yann@1
    79
    similar to buildroot,
rpjday@436
    80
  - other projects (openembedded.org for example), which is again used to
yann@1
    81
    build root file systems.
yann@1
    82
rpjday@436
    83
crosstool-NG is really targeted at building toolchains, and only toolchains.
yann@1
    84
It is then up to you to use it the way you want.
yann@1
    85
yann@1
    86
___________
yann@1
    87
          /
yann@1
    88
History  /
yann@1
    89
________/
yann@1
    90
rpjday@436
    91
crosstool was first 'conceived' by Dan Kegel, who offered it to the community
yann@1
    92
as a set of scripts, a repository of patches, and some pre-configured, general
yann@1
    93
purpose setup files to be used to configure crosstool. This is available at
yann@203
    94
http://www.kegel.com/crosstool, and the subversion repository is hosted on
yann@203
    95
google at http://code.google.com/p/crosstool/.
yann@1
    96
yann@1
    97
I once managed to add support for uClibc-based toolchains, but it did not make
yann@437
    98
into mainline, mostly because I didn't have time to port the patch forward to
yann@1
    99
the new versions, due in part to the big effort it was taking.
yann@1
   100
yann@1
   101
So I decided to clean up crosstool in the state it was, re-order the things
yann@437
   102
in place, add appropriate support for what I needed, that is uClibc support
yann@437
   103
and a menu-driven configuration, named the new implementation crosstool-NG,
yann@437
   104
(standing for crosstool Next Generation, as many other comunity projects do,
yann@437
   105
and as a wink at the TV series "Star Trek: The Next Generation" ;-) ) and
yann@437
   106
made it available to the community, in case it was of interest to any one.
yann@1
   107
yann@294
   108
___________________________
yann@294
   109
                          /
yann@294
   110
Installing crosstool-NG  /
yann@294
   111
________________________/
yann@294
   112
yann@294
   113
There are two ways you can use crosstool-NG:
yann@294
   114
 - build and install it, then get rid of the sources like you'd do for most
yann@294
   115
   programs,
yann@294
   116
 - or only build it and run from the source directory.
yann@294
   117
yann@294
   118
The former should be used if you got crosstool-NG from a packaged tarball, see
rpjday@436
   119
"Install method", below, while the latter is most useful for developpers that
yann@294
   120
checked the code out from SVN, and want to submit patches, see "The Hacker's
yann@294
   121
way", below.
yann@294
   122
yann@294
   123
Install method |
yann@294
   124
---------------+
yann@294
   125
yann@294
   126
If you go for the install, then you just follow the classical, but yet easy
yann@294
   127
./configure way:
yann@294
   128
  ./configure --prefix=/some/place
yann@294
   129
  make
yann@294
   130
  make install
yann@294
   131
  export PATH="${PATH}:/some/place/bin"
yann@294
   132
yann@294
   133
You can then get rid of crosstool-NG source. Next create a directory to serve
yann@294
   134
as a working place, cd in there and run:
yann@294
   135
  ct-ng help
yann@294
   136
yann@294
   137
See below for complete usage.
yann@294
   138
yann@294
   139
The Hacker's way |
yann@294
   140
-----------------+
yann@294
   141
yann@294
   142
If you go the hacker's way, then the usage is a bit different, although very
yann@294
   143
simple:
yann@294
   144
  ./configure --local
yann@294
   145
  make
yann@294
   146
yann@294
   147
Now, *do not* remove crosstool-NG sources. They are needed to run crosstool-NG!
yann@294
   148
Stay in the directory holding the sources, and run:
yann@294
   149
  ./ct-ng help
yann@294
   150
yann@294
   151
See below for complete usage.
yann@294
   152
yann@294
   153
Now, provided you checked-out the code, you can send me your interesting changes
yann@294
   154
by running:
yann@294
   155
  svn diff
yann@294
   156
yann@294
   157
and mailing me the result! :-P
yann@294
   158
yann@456
   159
Contributed code |
yann@456
   160
-----------------+
yann@456
   161
yann@456
   162
Some people contibuted code that couldn't get merged for various reasons. This
yann@456
   163
code is available as patches in the contrib/ sub-directory. These patches are
yann@456
   164
to be applied to the source of crosstool-NG, prior to installing.
yann@456
   165
yann@620
   166
An easy way to use contributed code is to pass the --with-contrib= option to
yann@620
   167
./configure. The possible values depend upon which contributions are packaged
yann@620
   168
with your version, but you can get with it with passing one of those two
yann@620
   169
special values:
yann@620
   170
  --with-contrib=list
yann@620
   171
    will list all available contributions
yann@620
   172
yann@620
   173
  --with-contrib=all
yann@620
   174
    will select all avalaible contributions
yann@620
   175
yann@620
   176
There is no guarantee that a particuliar contribution applies to the current
yann@620
   177
version of crosstool-ng, or that it will work at all. Use contributions at
yann@620
   178
your own risk.
yann@620
   179
yann@168
   180
____________________________
yann@168
   181
                           /
yann@168
   182
Configuring crosstool-NG  /
yann@168
   183
_________________________/
yann@168
   184
yann@620
   185
crosstool-NG is configured with a configurator presenting a menu-stuctured set
yann@620
   186
of options. These options let you specify the way you want your toolchain
yann@620
   187
built, where you want it installed, what architecture and specific processor it
yann@277
   188
will support, the version of the components you want to use, etc... The
yann@277
   189
value for those options are then stored in a configuration file.
yann@277
   190
yann@476
   191
The configurator works the same way you configure your Linux kernel. It is
yann@277
   192
assumed you now how to handle this.
yann@168
   193
yann@168
   194
To enter the menu, type:
yann@192
   195
  ct-ng menuconfig
yann@168
   196
yann@203
   197
Almost every config item has a help entry. Read them carefully.
yann@168
   198
yann@168
   199
String and number options can refer to environment variables. In such a case,
yann@192
   200
you must use the shell syntax: ${VAR}. You shall neither single- nor double-
yann@294
   201
quote the string/number options.
yann@168
   202
yann@192
   203
There are three environment variables that are computed by crosstool-NG, and
yann@168
   204
that you can use:
yann@168
   205
yann@168
   206
CT_TARGET:
yann@335
   207
  It represents the target tuple you are building for. You can use it for
yann@168
   208
  example in the installation/prefix directory, such as:
yann@168
   209
    /opt/x-tools/${CT_TARGET}
yann@168
   210
yann@168
   211
CT_TOP_DIR:
yann@182
   212
  The top directory where crosstool-NG is running. You shouldn't need it in
yann@182
   213
  most cases. There is one case where you may need it: if you have local
yann@182
   214
  patches and you store them in your running directory, you can refer to them
yann@168
   215
  by using CT_TOP_DIR, such as:
yann@168
   216
    ${CT_TOP_DIR}/patches.myproject
yann@168
   217
yann@168
   218
CT_VERSION:
yann@192
   219
  The version of crosstool-NG you are using. Not much use for you, but it's
yann@168
   220
  there if you need it.
yann@168
   221
yann@168
   222
Interesting config options |
yann@476
   223
---------------------------+
yann@168
   224
yann@168
   225
CT_LOCAL_TARBALLS_DIR:
yann@277
   226
  If you already have some tarballs in a direcotry, enter it here. That will
yann@197
   227
  speed up the retrieving phase, where crosstool-NG would otherwise download
yann@168
   228
  those tarballs.
yann@168
   229
yann@168
   230
CT_PREFIX_DIR:
yann@168
   231
  This is where the toolchain will be installed in (and for now, where it
yann@437
   232
  will run from). Common use is to add the target tuple in the directory
yann@277
   233
  path, such as (see above):
yann@277
   234
    /opt/x-tools/${CT_TARGET}
yann@168
   235
yann@168
   236
CT_TARGET_VENDOR:
yann@168
   237
  An identifier for your toolchain, will take place in the vendor part of the
yann@335
   238
  target tuple. It shall *not* contain spaces or dashes. Usually, keep it
yann@168
   239
  to a one-word string, or use underscores to separate words if you need.
yann@168
   240
  Avoid dots, commas, and special characters.
yann@168
   241
yann@168
   242
CT_TARGET_ALIAS:
yann@168
   243
  An alias for the toolchian. It will be used as a prefix to the toolchain
yann@168
   244
  tools. For example, you will have ${CT_TARGET_ALIAS}-gcc
yann@168
   245
yann@246
   246
Also, if you think you don't see enough versions, you can try to enable one of
yann@246
   247
those:
yann@246
   248
yann@246
   249
CT_OBSOLETE:
yann@246
   250
  Show obsolete versions or tools. Most of the time, you don't want to base
yann@246
   251
  your toolchain on too old a version (of gcc, for example). But at times, it
yann@246
   252
  can come handy to use such an old version for regression tests. Those old
yann@294
   253
  versions are hidden behind CT_OBSOLETE.
yann@246
   254
yann@246
   255
CT_EXPERIMENTAL:
yann@246
   256
  Show experimental versions or tools. Again, you might not want to base your
yann@246
   257
  toolchain on too recent tools (eg. gcc) for production. But if you need a
yann@246
   258
  feature present only in a recent version, or a new tool, you can find them
yann@246
   259
  hidden behind CT_EXPERIMENTAL.
yann@246
   260
yann@246
   261
CT_BROKEN:
yann@246
   262
  Show broken versions or tools. Some usefull tools are currently broken: they
yann@246
   263
  won't compile, run, or worse, cause defects when running. But if you are
yann@246
   264
  brave enough, you can try and debug them. They are hidden behind CT_BROKEN,
yann@476
   265
  which itself is hidden behind CT_EXPERIMENTAL.
yann@246
   266
yann@276
   267
Re-building an existing toolchain |
yann@276
   268
----------------------------------+
yann@276
   269
yann@276
   270
If you have an existing toolchain, you can re-use the options used to build it
yann@276
   271
to create a new toolchain. That needs a very little bit of effort on your side
yann@276
   272
but is quite easy. The options to build a toolchain are saved in the build log
yann@276
   273
file that is saved within the toolchain. crosstool-NG can extract those options
yann@276
   274
to recreate a new configuration:
yann@620
   275
  ct-ng extractconfig </path/to/your/build.log >.config
yann@276
   276
yann@276
   277
will extract those options, prompt you for the new ones, which you can later
yann@276
   278
edit with menuconfig.
yann@276
   279
yann@276
   280
Of course, if your build log was compressed, you'd have to use something like:
yann@620
   281
  bzcat /path/to/your/build.log.bz2 |ct-ng extractconfig >.config
yann@620
   282
yann@620
   283
Then, once the configuration has been extracted, run:
yann@620
   284
  ct-ng oldconfig
yann@276
   285
yann@168
   286
________________________
yann@168
   287
                       /
yann@168
   288
Running crosstool-NG  /
yann@168
   289
_____________________/
yann@1
   290
yann@168
   291
To build the toolchain, simply type:
yann@203
   292
  ct-ng build
yann@135
   293
yann@135
   294
This will use the above configuration to retrieve, extract and patch the
yann@135
   295
components, build, install and eventually test your newly built toolchain.
yann@1
   296
yann@1
   297
You are then free to add the toolchain /bin directory in your PATH to use
yann@1
   298
it at will.
yann@1
   299
yann@135
   300
In any case, you can get some terse help. Just type:
yann@192
   301
  ct-ng help
yann@203
   302
or:
yann@203
   303
  man 1 ct-ng
yann@135
   304
rpjday@436
   305
Stopping and restarting a build |
yann@476
   306
--------------------------------+
yann@135
   307
yann@135
   308
If you want to stop the build after a step you are debugging, you can pass the
yann@135
   309
variable STOP to make:
yann@192
   310
  ct-ng STOP=some_step
yann@135
   311
yann@135
   312
Conversely, if you want to restart a build at a specific step you are
yann@135
   313
debugging, you can pass the RESTART variable to make:
yann@192
   314
  ct-ng RESTART=some_step
yann@135
   315
yann@136
   316
Alternatively, you can call make with the name of a step to just do that step:
yann@192
   317
  ct-ng libc_headers
yann@136
   318
is equivalent to:
yann@620
   319
  ct-ng RESTART=libc_headers STOP=libc_headers
yann@136
   320
yann@304
   321
The shortcuts +step_name and step_name+ allow to respectively stop or restart
yann@136
   322
at that step. Thus:
yann@304
   323
  ct-ng +libc_headers        and:    ct-ng libc_headers+
yann@136
   324
are equivalent to:
yann@192
   325
  ct-ng STOP=libc_headers    and:    ct-ng RESTART=libc_headers
yann@136
   326
yann@181
   327
To obtain the list of acceptable steps, please call:
yann@544
   328
  ct-ng list-steps
yann@181
   329
yann@168
   330
Note that in order to restart a build, you'll have to say 'Y' to the config
yann@168
   331
option CT_DEBUG_CT_SAVE_STEPS, and that the previous build effectively went
yann@168
   332
that far.
yann@92
   333
yann@168
   334
Testing all toolchains at once |
yann@476
   335
-------------------------------+
yann@92
   336
yann@168
   337
You can test-build all samples; simply call:
yann@192
   338
  ct-ng regtest
yann@40
   339
yann@335
   340
Overriding the number of // jobs |
yann@476
   341
---------------------------------+
yann@335
   342
yann@335
   343
If you want to override the number of jobs to run in // (the -j option to
yann@335
   344
make), you can either re-enter the menuconfig, or simply add it on the command
yann@335
   345
line, as such:
yann@335
   346
  ct-ng build.4
yann@335
   347
yann@335
   348
which tells crosstool-NG to override the number of // jobs to 4.
yann@335
   349
yann@335
   350
You can see the actions that support overriding the number of // jobs in
yann@335
   351
the help menu. Those are the ones with [.#] after them (eg. build[.#] or
yann@335
   352
regtest[.#], and so on...).
yann@335
   353
yann@227
   354
_______________________
yann@227
   355
                      /
yann@227
   356
Using the toolchain  /
yann@227
   357
____________________/
yann@227
   358
yann@227
   359
Using the toolchain is as simple as adding the toolchain's bin directory in
yann@227
   360
your PATH, such as:
yann@227
   361
  export PATH="${PATH}:/your/toolchain/path/bin"
yann@227
   362
yann@335
   363
and then using the target tuple to tell the build systems to use your
yann@227
   364
toolchain:
yann@335
   365
  ./configure --target=your-target-tuple
yann@294
   366
or
yann@335
   367
  make CC=your-target-tuple-gcc
yann@294
   368
or
yann@335
   369
  make CROSS_COMPILE=your-target-tuple-
yann@294
   370
and so on...
yann@227
   371
yann@476
   372
It is strongly advised not to use the toolchain sys-root directory as an
yann@620
   373
install directory for your programs/packages. If you do so, you will not be
yann@476
   374
able to use your toolchain for another project. It is even strongly advised
yann@476
   375
that your toolchain is chmod-ed to read-only once successfully build, so that
yann@620
   376
you don't go polluting your toolchain with your programs/packages' files.
yann@476
   377
yann@476
   378
Thus, when you build a program/package, install it in a separate directory,
yann@476
   379
eg. /your/root. This directory is the /image/ of what would be in the root file
yann@620
   380
system of your target, and will contain all that your programs/packages have
yann@476
   381
installed.
yann@476
   382
yann@227
   383
When your root directory is ready, it is still missing some important bits: the
yann@227
   384
toolchain's libraries. To populate your root directory with those libs, just
yann@227
   385
run:
yann@335
   386
  your-target-tuple-populate -s /your/root -d /your/root-populated
yann@227
   387
yann@227
   388
This will copy /your/root into /your/root-populated, and put the needed and only
yann@227
   389
the needed libraries there. Thus you don't polute /your/root with any cruft that
yann@227
   390
would no longer be needed should you have to remove stuff. /your/root always
yann@227
   391
contains only those things you install in it.
yann@227
   392
yann@227
   393
You can then use /your/root-populated to build up your file system image, a
yann@227
   394
tarball, or to NFS-mount it from your target, or whatever you need.
yann@227
   395
yann@294
   396
populate accepts the following options:
yann@294
   397
yann@294
   398
 -s [src_dir]
yann@294
   399
    Use 'src_dir' as the 'source', un-populated root directory
yann@294
   400
yann@294
   401
 -d [dst_dir]
yann@294
   402
    Put the 'destination', populated root directory in 'dst_dir'
yann@294
   403
yann@294
   404
 -f
yann@294
   405
    Remove 'dst_dir' if it previously existed
yann@294
   406
yann@294
   407
 -v
yann@294
   408
    Be verbose, and tell what's going on (you can see exactly where libs are
yann@294
   409
    coming from).
yann@294
   410
yann@294
   411
 -h
yann@294
   412
    Print the help
yann@294
   413
yann@40
   414
___________________
yann@40
   415
                  /
yann@40
   416
Toolchain types  /
yann@40
   417
________________/
yann@40
   418
yann@40
   419
There are four kinds of toolchains you could encounter.
yann@40
   420
yann@40
   421
First off, you must understand the following: when it comes to compilers there
yann@40
   422
are up to four machines involved:
yann@40
   423
  1) the machine configuring the toolchain components: the config machine
yann@40
   424
  2) the machine building the toolchain components:    the build machine
yann@40
   425
  3) the machine running the toolchain:                the host machine
yann@203
   426
  4) the machine the toolchain is generating code for: the target machine
yann@40
   427
yann@40
   428
We can most of the time assume that the config machine and the build machine
yann@40
   429
are the same. Most of the time, this will be true. The only time it isn't
yann@40
   430
is if you're using distributed compilation (such as distcc). Let's forget
yann@40
   431
this for the sake of simplicity.
yann@40
   432
yann@40
   433
So we're left with three machines:
yann@40
   434
 - build
yann@40
   435
 - host
yann@40
   436
 - target
yann@40
   437
yann@40
   438
Any toolchain will involve those three machines. You can be as pretty sure of
yann@40
   439
this as "2 and 2 are 4". Here is how they come into play:
yann@40
   440
yann@40
   441
1) build == host == target
yann@40
   442
    This is a plain native toolchain, targetting the exact same machine as the
yann@40
   443
    one it is built on, and running again on this exact same machine. You have
yann@40
   444
    to build such a toolchain when you want to use an updated component, such
yann@40
   445
    as a newer gcc for example.
yann@197
   446
    crosstool-NG calls it "native".
yann@40
   447
yann@40
   448
2) build == host != target
yann@40
   449
    This is a classic cross-toolchain, which is expected to be run on the same
yann@40
   450
    machine it is compiled on, and generate code to run on a second machine,
yann@40
   451
    the target.
yann@197
   452
    crosstool-NG calls it "cross".
yann@40
   453
yann@40
   454
3) build != host == target
yann@40
   455
    Such a toolchain is also a native toolchain, as it targets the same machine
yann@40
   456
    as it runs on. But it is build on another machine. You want such a
yann@40
   457
    toolchain when porting to a new architecture, or if the build machine is
yann@40
   458
    much faster than the host machine.
yann@197
   459
    crosstool-NG calls it "cross-native".
yann@40
   460
yann@40
   461
4) build != host != target
yann@92
   462
    This one is called a canadian-toolchain (*), and is tricky. The three
yann@40
   463
    machines in play are different. You might want such a toolchain if you
yann@40
   464
    have a fast build machine, but the users will use it on another machine,
yann@40
   465
    and will produce code to run on a third machine.
yann@197
   466
    crosstool-NG calls it "canadian".
yann@40
   467
yann@197
   468
crosstool-NG can build all these kinds of toolchains (or is aiming at it,
yann@197
   469
anyway!)
yann@40
   470
yann@40
   471
(*) The term Canadian Cross came about because at the time that these issues
yann@40
   472
    were all being hashed out, Canada had three national political parties.
yann@40
   473
    http://en.wikipedia.org/wiki/Cross_compiler
yann@40
   474
yann@1
   475
_____________
yann@1
   476
            /
yann@1
   477
Internals  /
yann@1
   478
__________/
yann@1
   479
yann@92
   480
Internally, crosstool-NG is script-based. To ease usage, the frontend is
yann@92
   481
Makefile-based.
yann@92
   482
yann@92
   483
Makefile front-end |
yann@476
   484
-------------------+
yann@92
   485
yann@203
   486
The entry point to crosstool-NG is the Makefile script "ct-ng". Calling this
yann@203
   487
script with an action will act exactly as if the Makefile was in the current
yann@203
   488
working directory and make was called with the action as rule. Thus:
yann@203
   489
  ct-ng menuconfig
yann@294
   490
yann@203
   491
is equivalent to having the Makefile in CWD, and calling:
yann@203
   492
  make menuconfig
yann@203
   493
yann@203
   494
Having ct-ng as it is avoids copying the Makefile everywhere, and acts as a
yann@203
   495
traditional command.
yann@203
   496
yann@203
   497
ct-ng loads sub- Makefiles from the library directory $(CT_LIB_DIR), as set up
yann@203
   498
at configuration time with ./configure.
yann@203
   499
yann@437
   500
ct-ng also searches for config files, sub-tools, samples, scripts and patches in
yann@203
   501
that library directory.
yann@92
   502
yann@294
   503
Because of a stupid make behavior/bug I was unable to track down, implicit make
yann@294
   504
rules are disabled: installing with --local would triger those rules, and mconf
yann@294
   505
was unbuildable.
yann@294
   506
yann@182
   507
Kconfig parser |
yann@476
   508
---------------+
yann@92
   509
yann@92
   510
The kconfig language is a hacked version, vampirised from the toybox project
yann@182
   511
by Rob LANDLEY (http://www.landley.net/code/toybox/), itself coming from the
yann@294
   512
Linux kernel (http://www.kernel.org/), and (heavily) adapted to my needs.
yann@92
   513
yann@203
   514
The kconfig parsers (conf and mconf) are not installed pre-built, but as
yann@203
   515
source files. Thus you can have the directory where crosstool-NG is installed,
yann@203
   516
exported (via NFS or whatever) and have clients with different architectures
yann@203
   517
use the same crosstool-NG installation, and most notably, the same set of
yann@203
   518
patches.
yann@203
   519
yann@381
   520
Architecture-specific |
yann@476
   521
----------------------+
yann@381
   522
yann@628
   523
Note: this chapter is not really well written, and might thus be a little bit
yann@628
   524
complex to understand. To get a better grasp of what an architecture is, the
yann@628
   525
reader is kindly encouraged to look at the "arch/" sub-directory, and to the
yann@628
   526
existing architectures to see how things are laid out.
yann@628
   527
yann@381
   528
An architecture is defined by:
yann@381
   529
yann@381
   530
 - a human-readable name, in lower case letters, with numbers as appropriate.
yann@628
   531
   The underscore is allowed; space and special characters are not.
yann@628
   532
     Eg.: arm, x86_64
yann@381
   533
 - a directory in "arch/" named after the architecture, with the same letters
yann@381
   534
   as above. Eg.: arch/arm, arch/x86_64
yann@628
   535
   This directory contains the following files, and only those files:
yann@628
   536
   - a configuration file in kconfig syntax, named "config.in", which shall
yann@628
   537
     follow the API defined below.
yann@628
   538
       Eg.: arch/arm/config.in
yann@381
   539
   - a function script in bash-3.0 syntax, named "functions", which shall
yann@628
   540
     follow the API defined below.
yann@628
   541
       Eg.: arch/arm/functions
yann@628
   542
   - an optional file, named "experimental" (in lower case!), which, if it
yann@628
   543
     is present, means that support for this architecture is EXPERIMENTAL.
yann@628
   544
       Eg.: arch/arm/experimental
yann@628
   545
yann@628
   546
The "config.in" file API:
yann@628
   547
 > the config option "ARCH_%arch%" (where %arch% is to be replaced with the
yann@628
   548
   actual architecture name).
yann@628
   549
   That config option must have *neither* a type, *nor* a prompt! Also, it can
yann@628
   550
   *not* depend on any other config option (EXPERIMENTAL is managed as above).
yann@628
   551
     Eg.:
yann@628
   552
       config ARCH_arm
yann@630
   553
   + mandatory:
yann@630
   554
       defines an (terse) help entry for this architecture:
yann@630
   555
       Eg.:
yann@630
   556
         config ARCH_arm
yann@630
   557
           help
yann@630
   558
             The ARM architecture.
yann@628
   559
   + optional:
yann@628
   560
       selects adequate associated config options.
yann@628
   561
       Eg.:
yann@628
   562
         config ARCH_arm
yann@628
   563
           select ARCH_SUPPORTS_BOTH_ENDIAN
yann@628
   564
           select ARCH_DEFAULT_LE
yann@630
   565
           help
yann@630
   566
             The ARM architecture.
yann@628
   567
yann@628
   568
 > other target-specific options, at your discretion. Note however that to
yann@628
   569
   avoid name-clashing, such options shall be prefixed with "ARCH_%arch%",
yann@628
   570
   where %arch% is again replaced by the actual architecture name.
yann@628
   571
   (Note: due to historical reasons, and lack of time to clean up the code,
yann@628
   572
    I may have left some config options that do not completely conform to
yann@628
   573
    this, as the architecture name was written all upper case. However, the
yann@628
   574
    prefix is unique among architectures, and does not cause harm).
yann@381
   575
yann@381
   576
The "functions" file API:
yann@383
   577
 > the function "CT_DoArchValues"
yann@381
   578
   + parameters: none
yann@381
   579
   + environment:
yann@381
   580
      - all variables from the ".config" file,
yann@381
   581
      - the two variables "target_endian_eb" and "target_endian_el" which are
yann@383
   582
        the endianness suffixes
yann@381
   583
   + return value: 0 upon success, !0 upon failure
yann@381
   584
   + provides:
yann@391
   585
     - mandatory
yann@383
   586
     - the environment variable CT_TARGET_ARCH
yann@389
   587
     - contains:
yann@389
   588
       the architecture part of the target tuple.
yann@389
   589
       Eg.: "armeb" for big endian ARM
yann@389
   590
            "i386" for an i386
yann@389
   591
   + provides:
yann@391
   592
     - optional
yann@389
   593
     - the environment variable CT_TARGET_SYS
yann@456
   594
     - contains:
yann@383
   595
       the sytem part of the target tuple.
yann@383
   596
       Eg.: "gnu" for glibc on most architectures
yann@383
   597
            "gnueabi" for glibc on an ARM EABI
yann@383
   598
     - defaults to:
yann@383
   599
       - for glibc-based toolchain: "gnu"
yann@383
   600
       - for uClibc-based toolchain: "uclibc"
yann@383
   601
   + provides:
yann@383
   602
     - optional
yann@391
   603
     - the environment variable CT_KERNEL_ARCH
yann@383
   604
     - contains:
yann@391
   605
       the architecture name as understandable by the Linux kernel build
yann@391
   606
       system.
yann@391
   607
       Eg.: "arm" for an ARM
yann@391
   608
            "powerpc" for a PowerPC
yann@391
   609
            "i386" for an x86
yann@383
   610
     - defaults to:
yann@391
   611
       ${CT_ARCH}
yann@391
   612
   + provides:
yann@391
   613
     - optional
yann@391
   614
     - the environment variables to configure the cross-gcc
yann@391
   615
       - CT_ARCH_WITH_ARCH
yann@391
   616
       - CT_ARCH_WITH_ABI
yann@391
   617
       - CT_ARCH_WITH_CPU
yann@391
   618
       - CT_ARCH_WITH_TUNE
yann@391
   619
       - CT_ARCH_WITH_FPU
yann@391
   620
       - CT_ARCH_WITH_FLOAT
yann@391
   621
     - contain (defaults):
yann@391
   622
       - CT_ARCH_WITH_ARCH    : the gcc ./configure switch to select architecture level         ( "--with-arch=${CT_ARCH_ARCH}"       )
yann@456
   623
       - CT_ARCH_WITH_ABI     : the gcc ./configure switch to select ABI level                  ( "--with-abi=${CT_ARCH_ABI}"         )
yann@456
   624
       - CT_ARCH_WITH_CPU     : the gcc ./configure switch to select CPU instruction set        ( "--with-cpu=${CT_ARCH_CPU}"         )
yann@456
   625
       - CT_ARCH_WITH_TUNE    : the gcc ./configure switch to select scheduling                 ( "--with-tune=${CT_ARCH_TUNE}"       )
yann@456
   626
       - CT_ARCH_WITH_FPU     : the gcc ./configure switch to select FPU type                   ( "--with-fpu=${CT_ARCH_FPU}"         )
yann@391
   627
       - CT_ARCH_WITH_FLOAT   : the gcc ./configure switch to select floating point arithmetics ( "--with-float=soft" or /empty/      )
yann@391
   628
   + provides:
yann@391
   629
     - optional
yann@391
   630
     - the environment variables to pass to the cross-gcc to build target binaries
yann@391
   631
       - CT_ARCH_ARCH_CFLAG
yann@391
   632
       - CT_ARCH_ABI_CFLAG
yann@391
   633
       - CT_ARCH_CPU_CFLAG
yann@391
   634
       - CT_ARCH_TUNE_CFLAG
yann@391
   635
       - CT_ARCH_FPU_CFLAG
yann@391
   636
       - CT_ARCH_FLOAT_CFLAG
yann@391
   637
       - CT_ARCH_ENDIAN_CFLAG
yann@391
   638
     - contain (defaults):
yann@391
   639
       - CT_ARCH_ARCH_CFLAG   : the gcc switch to select architecture level                     ( "-march=${CT_ARCH_ARCH}"            )
yann@456
   640
       - CT_ARCH_ABI_CFLAG    : the gcc switch to select ABI level                              ( "-mabi=${CT_ARCH_ABI}"              )
yann@391
   641
       - CT_ARCH_CPU_CFLAG    : the gcc switch to select CPU instruction set                    ( "-mcpu=${CT_ARCH_CPU}"              )
yann@391
   642
       - CT_ARCH_TUNE_CFLAG   : the gcc switch to select scheduling                             ( "-mtune=${CT_ARCH_TUNE}"            )
yann@391
   643
       - CT_ARCH_FPU_CFLAG    : the gcc switch to select FPU type                               ( "-mfpu=${CT_ARCH_FPU}"              )
yann@391
   644
       - CT_ARCH_FLOAT_CFLAG  : the gcc switch to choose floating point arithmetics             ( "-msoft-float" or /empty/           )
yann@391
   645
       - CT_ARCH_ENDIAN_CFLAG : the gcc switch to choose big or little endian                   ( "-mbig-endian" or "-mlittle-endian" )
yann@391
   646
     - default to:
yann@391
   647
       see above.
yann@628
   648
yann@620
   649
Adding a new version of a component |
yann@476
   650
------------------------------------+
yann@476
   651
yann@476
   652
When a new component, such as the Linux kernel, gcc or any other is released,
yann@476
   653
adding the new version to crosstool-NG is quite easy. There is a script that
yann@476
   654
will do all that for you:
yann@476
   655
  tools/addToolVersion.sh
yann@476
   656
yann@476
   657
Run it with no option to get some help.
yann@381
   658
yann@203
   659
Build scripts |
yann@476
   660
--------------+
yann@203
   661
yann@203
   662
To Be Written later...