Changes between Version 24 and Version 25 of BuildSystem


Ignore:
Timestamp:
Mar 21, 2010, 12:48:37 AM (14 years ago)
Author:
becoulet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildSystem

    v24 v25  
    11
    2 This document describes the MutekH build system.
    3 
    4 = Overview of the build process =
    5 
    6 The build system use one or more used defined '''build configuration files''' to compiles the desired kernel together with the application.
     2= Introduction =
     3
     4This document describes the MutekH build system invocation and base features and is intended for beginners and application developers.
    75
    86The build system takes care of features dependencies, file modifications, ... but is still simple to use for the beginner.
     7MutekH source code is highly configurable, this implies the application developer
     8has to provide a '''build configuration file''' along with the application source code.
     9
    910Available features, tweakable values and associated constraints are represented by '''configuration tokens'''
    10 and described by developers through '''configuration description files''' (.config) in the source tree.
    11 
    12 Depending on the target architecture, the binary output file may be an ELF (.out), a plain binary file (.bin), an intel-hex file (.hex) or an object file (.o).
    13 
    14 = User point of view =
    15 
    16 == Invocation ==
     11and described by kernel developers through '''configuration description files''' (.config) in the source tree.
     12The configuration description syntax is detailed on the BuildSystemDev page which cover more advanced topics.
     13
     14Reading the BuildingExamples page may be of some interest too.
     15
     16= Invocation =
     17
     18== Building ==
    1719
    1820When building MutekH, several options may be used to change the behavior of the build system.
     
    3638}}}
    3739
    38 === Main variables ===
     40Depending on the target architecture, the binary output file may be an ELF (.out), a plain binary file (.bin), an intel-hex file (.hex) or an object file (.o).
     41
     42== Configuration display ==
     43
     44This section explains how to display information about MutekH configuration being used.
     45
     46You can display a list of relevant tokens with their value for a given configuration:
     47{{{
     48$ make CONF=path/to/config_file listconfig
     49}}}
     50
     51You can display a list of '''all''' tokens with their value for a given configuration:
     52{{{
     53$ make CONF=path/to/config_file listallconfig
     54}}}
     55
     56To display help about a specific token:
     57{{{
     58$ make CONF=path/to/config_file showconfig TOKEN=CONFIG_PTHREAD
     59}}}
     60
     61= Main variables =
    3962
    4063The following option is mandatory:
     
    5881   An absolute path to the directory containing the {{{.config.*}}} files, this defaults to `$(BUILD_DIR)`
    5982
    60 === Make targets ===
     83= Make targets =
    6184
    6285The following targets are available
     
    87110See usage below.
    88111
    89 == Build configuration files ==
    90 
    91 === Content ===
     112= Build configuration files =
     113
     114== Content ==
    92115
    93116MutekH build configuration files contain token values pairs defining the kernel we are currently building. They must contain:
     
    100123 * ...
    101124
    102 === Basic syntax ===
     125== Basic syntax ==
    103126
    104127Syntax is `token` '''space''' `value`. Tokens begin with `CONFIG_`. Value may be omitted thus defaults to `defined`. e.g.
     
    133156The [http://www.mutekh.org/www/mutekh_api/ MutekH API reference manual] describes all available configuration tokens.
    134157
    135 == Help display ==
    136 
    137 You can display a list of relevant tokens with their value for a given configuration:
    138 {{{
    139 $ make CONF=path/to/config_file listconfig
    140 }}}
    141 
    142 You can display a list of *all* tokens with their value for a given configuration:
    143 {{{
    144 $ make CONF=path/to/config_file listallconfig
    145 }}}
    146 
    147 To display help about a specific token:
    148 {{{
    149 $ make CONF=path/to/config_file showconfig TOKEN=CONFIG_PTHREAD
    150 }}}
    151 
    152 === Module declaration ===
    153 
    154 A build configuration file may declare a new module. Modules can be located anywhere outside of the main source tree.
     158== Module declaration ==
     159
     160MutekH has a modular and component-based architecture.
     161
     162A build configuration file may declare a new module for the application.
     163Modules can be located anywhere outside of the main source tree.
    155164We must tell the build system the directory where the configuration lies.
    156165The path to the module directory is usually the same as its configuration file and the `CONFIGPATH` special variable is well suited:
     
    161170}}}
    162171
    163 === Output name ===
     172== Output name ==
    164173
    165174the MutekH build system takes care of building in directory named after application name and build target.
     
    169178}}}
    170179
    171 === Advanced syntax ===
     180== Advanced syntax ==
    172181
    173182Basic configuration is really simple. Complex applications or multiple target architectures require
     
    225234allowing to override values set in included files.
    226235
    227 = Developer point of view =
    228 
    229 MutekH has a component-based architecture where each module declares its configuration tokens.
    230 
    231 Tokens are declared in configuration description files which are located at various places in the MutekH source tree.
    232 These constraints configuration files have a different syntax from the build configuration files.
    233 They are designed to declare configuration tokens and express relationships between available tokens.
    234 
    235 Declared tokens can have their value changed in build configuration files and can be tested from C source code and Makefile.
    236 
    237 == The .config constraints files ==
    238 
    239 Their are several types of configuration tokens:
    240  * normal features enabling tokens which can be either defined or undefined in build configuration files.
    241  * meta tokens which can only get defined through definition of other tokens.
    242  * value tokens which can have any value.
    243 
    244 === Token flags ===
    245 
    246 Several flags can be attached to tokens, most important ones are:
    247  `value`::
    248    Indicate the token is a value token. Value tokens can not have dependencies but can take values other than `defined` and `undefined`
    249  `meta`::
    250    Indicate the token is a meta token which may only be defined by an other token using the `provide` tag.
    251  `auto`::
    252    Indicate the token may be automatically defined to satisfy dependencies.
    253 
    254 Other flags can be attached to tokens:
    255  `harddep`::
    256    Indicate the token can not be safely undefined due to a unsatisfied dependency.
    257  `mandatory`::
    258    Indicate the token can not be undefined at all. Useful to enforce requirements on other tokens, mainly for mandatory modules.
    259  `root`::
    260    Indicate the token has no parent.
    261  `internal`::
    262    Indicate the token is for internal use and can not be defined in build configuration file directly.
    263  `noexport`::
    264    Indicate the token should not be written out in generated files.
    265  `private`::
    266    Indicate the token can not be used with `parent`, `depend` or `provide` tag from an other `.config` file.
    267 
    268 === Constraint tags ===
    269 
    270 For each configuration token, one may use the following tags:
    271  `desc Description string without quotes`::
    272    Short description about the token, multiple `desc` tags will be concatenated.
    273  `flags FLAGS […]`::
    274    Set some flags with special meaning for the token (see above).
    275  `parent TOKEN`::
    276    Hierarchical dependency, it ensures all token with a parent gets silently undefined if the parent is undefined. This prevents options enabled by default to stay enabled if the parent is disabled; this way it avoids errors due to unneeded requirements. This is also used to hide irrelevant tokens from the help screen if the parent token is undefined.
    277  `default value`::
    278    Set the token default value. `defined` and `undefined` values act as booleans. default value is `undefined` if this line is omitted.
    279  `module name [long name]`::
    280    The feature token is associated with a module name. A module with the given name and the actual config file directory will be considered for building when the token gets defined.
    281 
    282 The following tags may be used to specify features constraints:
    283  `depend TOKEN […]`::
    284    The tag must be used to express feature dependencies, at least one of the given feature tokens is required. Unsatisfied dependency undefine the current token and emit a notice, unless flags modify this behavior.
    285  `single TOKEN […]`::
    286    Same as depend with the additional constraint that only one of the given tokens may be defined.
    287  `exclude TOKEN`::
    288    Specify excluded tokens, the current token must not be defined at the same time as any given token.
    289  `when TOKEN_CONDITION […]`::
    290    The current feature token will be automatically defined if all specified conditions are met. Missing dependencies will emit a notice as if it was defined in the build configuration file.
    291  `provide TOKEN`::
    292    Define a meta token if the current token is defined.
    293 
    294 Some tags may be used to deals with values tokens. Value tokens must have the `value` flag set:
    295 
    296  `require TOKEN_CONDITION […]`::
    297    Requirements on value tokens, having at least one condition evaluates to true on the line is mandatory if the current token is defined.
    298  `provide TOKEN=value`::
    299    Set a value token to the specified value if the current token is defined.
    300 
    301 Some tags can be used to give some configurations advice to the user when building MutekH:
    302 
    303  `suggest TOKEN_CONDITION`::
    304    Defining the current feature token suggest the given condition to the user.
    305  `suggest_when TOKEN_CONDITION […]`::
    306    The current token will be suggested to the user if dependencies are actually satisfied and all given conditions are met.
    307 
    308 The `TOKEN_CONDITION` might check different conditions:
    309 
    310  * Token definition check: `TOKEN` or `TOKEN!`
    311  * Token value equality check: `TOKEN=value`
    312  * Token numerical value magnitude check: `TOKEN<value` or `TOKEN>value`
    313 
    314 The configuration tool will check both constraint rules consistency and build configuration file respect of the rules when building MutekH.
    315 
    316 Configuration constraints example:
    317 {{{
    318 %config CONFIG_FEATURE
    319   desc This is a great module for MutekH
    320   depend CONFIG_MUTEK_SCHEDULER
    321   module great The great library
    322   require CONFIG_CPU_MAXCOUNT>1
    323 %config end
    324 
    325 %config CONFIG_FEATURE_DEBUG
    326   desc Enable debug mode for the great feature
    327   parent CONFIG_FEATURE
    328   provide CONFIG_FEATURE_STACK_SIZE=4096
    329   when CONFIG_DEBUG
    330 %config end
    331 
    332 %config CONFIG_FEATURE_STACK_SIZE
    333   desc This is the thread stack size for the great feature
    334   parent CONFIG_FEATURE
    335   flags value
    336   default 512
    337 %config end
    338 
    339 }}}
    340 
    341 == Source tree Makefile syntax & rules ==
    342 
    343 Makefiles in source directories may use the following variables:
    344  `objs`::
    345    A list of .o files compiled from `.c`, `.s` or `.S` files
    346  `meta`::
    347    A list of files that may be translated from `.m4`, `.cpp` or `.def` files
    348  `copy`::
    349    A list of files that must be copied verbatim from source directory to object directory
    350  `subdirs`::
    351    A list of subdirectories where more files are to be processed. These directories must exist and contain a `Makefile`.
    352  `doc_headers`::
    353    A list of header files which must be parsed to generate the [http://www.mutekh.org/www/mutekh_api/ MutekH API reference manual], see [wiki:HeaderDoc header documentation] for details.
    354 
    355 Makefiles may contain optional flags that may be used for compilation:
    356  `file.o_CFLAGS=…`::
    357    CFLAGS to use for a given object
    358  `DIR_CFLAGS=…`::
    359    CFLAGS to use for all the objects compiled by the current Makefile. Flags added by this setting add-up with the object-specific ones above.
    360 
    361 Moreover, one may use `ifeq (…,…)` make constructs to conditionally compile different things. Configuration tokens are usable.
    362 
    363 Example:
    364 {{{
    365 objs = main.o
    366 
    367 ifeq ($(CONFIG_SRL_SOCLIB),defined)
    368 objs += barrier.o sched_wait.o srl_log.o hw_init.o
    369 else
    370 objs += posix_wait_cycles.o
    371 endif
    372 
    373 main.o_CFLAGS = -O0 -ggdb
    374 }}}
    375 
    376 == The arch & cpu specific parts ==
    377 
    378 Architecture and CPU directories have some special files which are injected in the building process:
    379  * config.mk, included by make. It can define some compilation flags
    380  * ldscript, invoked at link-time.
    381   * Architecture ldscript must create a loadable binary
    382   * CPU ldscript usually only specifies the entry point name
    383 
    384 === config.mk ===
    385 
    386 The arch `config.mk`  may override the following variables:
    387  `ARCHCFLAGS`::
    388    C-compiler flags
    389  `ARCHLDFLAGS`::
    390    Linker flags
    391  `LD_NO_Q`::
    392    Linker for the current architecture does not support -q switch, this slightly changes the linking process.
    393  `HOSTCPPFLAGS`::
    394    Flags to give to host's cpp (HOSTCPP) program. This is only used for expansion of `.def` files.
    395 
    396 The cpu `config.mk`  may override the following variables:
    397 
    398  `CPUCFLAGS`::
    399    C-compiler flags
    400  `CPULDFLAGS`::
    401    Linker flags
    402 
    403 === ldscript ===
    404 
    405 Try `info ld` for a guide through ldscripts…
    406 
    407 This ldscript is taken from architecture's object directory, thus it may be obtained from either:
    408  * copy
    409  * m4 processing
    410  * cpp processing
    411 
    412 See
    413 [source:trunk/mutekh/arch/emu/ldscript arch/emu/ldscript],
    414 [source:trunk/mutekh/arch/soclib/ldscript.m4 arch/soclib/ldscript.m4], and
    415 [source:trunk/mutekh/arch/simple/ldscript.cpp arch/simple/ldscript.cpp] for the three flavors !
    416 
    417 = Notes =
    418 == Prerequisites ==
    419 
    420 The MutekH build-system is based on GNU Make features. It makes intensive use of:
    421  * includes
    422  * $(foreach) $(subst) $(eval) $(call) macros
    423  * macro definitions
    424 Therefore, a Make-3.81 at least is mandatory.