| | 1 | |
| | 2 | = Introduction = |
| | 3 | |
| | 4 | This document describes the MutekH build system configuration files and is intended for kernel developers. |
| | 5 | |
| | 6 | Be sure to first read the BuildSystem page which contains more basic information. |
| | 7 | |
| | 8 | MutekH has a component-based architecture where each module declares its configuration tokens. |
| | 9 | |
| | 10 | Tokens are declared in '''configuration description files''' which are located at various places in the MutekH source tree. |
| | 11 | These constraints configuration files have a different syntax from the build configuration files. |
| | 12 | They are designed to declare configuration tokens, express relationships between available tokens and describe associated constraints. |
| | 13 | |
| | 14 | Declared tokens may be assigned in build configuration files to build with a given configuration. |
| | 15 | Their values can later be tested from source code and `Makefile` files using C macros and `make` variables. |
| | 16 | |
| | 17 | = The `.config` files syntax = |
| | 18 | |
| | 19 | Their are several types of configuration tokens: |
| | 20 | * normal features enabling tokens which can be either defined or undefined in build configuration files. |
| | 21 | * meta tokens which can only get defined through definition of other tokens. |
| | 22 | * value tokens which can have any value. |
| | 23 | |
| | 24 | == Configuration token declaration == |
| | 25 | |
| | 26 | === Token flags === |
| | 27 | |
| | 28 | Several flags can be attached to tokens, most important ones are: |
| | 29 | `value`:: |
| | 30 | Indicate the token is a value token. Value tokens can not have dependencies but can take values other than `defined` and `undefined` |
| | 31 | `meta`:: |
| | 32 | Indicate the token is a meta token which may only be defined by an other token using the `provide` tag. |
| | 33 | `auto`:: |
| | 34 | Indicate the token may be automatically defined to satisfy dependencies. |
| | 35 | |
| | 36 | Other flags can be attached to tokens: |
| | 37 | `harddep`:: |
| | 38 | Indicate the token can not be safely undefined due to a unsatisfied dependency. |
| | 39 | `mandatory`:: |
| | 40 | Indicate the token can not be undefined at all. Useful to enforce requirements on other tokens, mainly for mandatory modules. |
| | 41 | `root`:: |
| | 42 | Indicate the token has no parent. |
| | 43 | `internal`:: |
| | 44 | Indicate the token is for internal use and can not be defined in build configuration file directly. |
| | 45 | `noexport`:: |
| | 46 | Indicate the token should not be written out in generated files. |
| | 47 | `private`:: |
| | 48 | Indicate the token can not be used with `parent`, `depend` or `provide` tag from an other `.config` file. |
| | 49 | |
| | 50 | === Constraint tags === |
| | 51 | |
| | 52 | For each configuration token, one may use the following tags: |
| | 53 | `desc Description string without quotes`:: |
| | 54 | Short description about the token, multiple `desc` tags will be concatenated. |
| | 55 | `flags FLAGS […]`:: |
| | 56 | Set some flags with special meaning for the token (see above). |
| | 57 | `parent TOKEN`:: |
| | 58 | 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. |
| | 59 | `default value`:: |
| | 60 | Set the token default value. `defined` and `undefined` values act as booleans. default value is `undefined` if this line is omitted. |
| | 61 | `module name [long name]`:: |
| | 62 | 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. |
| | 63 | |
| | 64 | The following tags may be used to specify features constraints: |
| | 65 | `depend TOKEN […]`:: |
| | 66 | 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. |
| | 67 | `single TOKEN […]`:: |
| | 68 | Same as depend with the additional constraint that only one of the given tokens may be defined. |
| | 69 | `exclude TOKEN`:: |
| | 70 | Specify excluded tokens, the current token must not be defined at the same time as any given token. |
| | 71 | `when TOKEN_CONDITION […]`:: |
| | 72 | 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. |
| | 73 | `provide TOKEN`:: |
| | 74 | Define a meta token if the current token is defined. |
| | 75 | |
| | 76 | Some tags may be used to deals with values tokens. Value tokens must have the `value` flag set: |
| | 77 | |
| | 78 | `require TOKEN_CONDITION […]`:: |
| | 79 | Requirements on value tokens, having at least one condition evaluates to true on the line is mandatory if the current token is defined. |
| | 80 | `provide TOKEN=value`:: |
| | 81 | Set a value token to the specified value if the current token is defined. |
| | 82 | |
| | 83 | Some tags can be used to give some configurations advice to the user when building MutekH: |
| | 84 | |
| | 85 | `suggest TOKEN_CONDITION`:: |
| | 86 | Defining the current feature token suggest the given condition to the user. |
| | 87 | `suggest_when TOKEN_CONDITION […]`:: |
| | 88 | The current token will be suggested to the user if dependencies are actually satisfied and all given conditions are met. |
| | 89 | |
| | 90 | The `TOKEN_CONDITION` might check different conditions: |
| | 91 | |
| | 92 | * Token definition check: `TOKEN` or `TOKEN!` |
| | 93 | * Token value equality check: `TOKEN=value` |
| | 94 | * Token numerical value magnitude check: `TOKEN<value` or `TOKEN>value` |
| | 95 | |
| | 96 | The configuration tool will check both constraint rules consistency and build configuration file respect of the rules when building MutekH. |
| | 97 | |
| | 98 | Configuration constraints example: |
| | 99 | {{{ |
| | 100 | %config CONFIG_FEATURE |
| | 101 | desc This is a great module for MutekH |
| | 102 | depend CONFIG_MUTEK_SCHEDULER |
| | 103 | module great The great library |
| | 104 | require CONFIG_CPU_MAXCOUNT>1 |
| | 105 | %config end |
| | 106 | |
| | 107 | %config CONFIG_FEATURE_DEBUG |
| | 108 | desc Enable debug mode for the great feature |
| | 109 | parent CONFIG_FEATURE |
| | 110 | provide CONFIG_FEATURE_STACK_SIZE=4096 |
| | 111 | when CONFIG_DEBUG |
| | 112 | %config end |
| | 113 | |
| | 114 | %config CONFIG_FEATURE_STACK_SIZE |
| | 115 | desc This is the thread stack size for the great feature |
| | 116 | parent CONFIG_FEATURE |
| | 117 | flags value |
| | 118 | default 512 |
| | 119 | %config end |
| | 120 | |
| | 121 | }}} |
| | 122 | |
| | 123 | = Source tree `Makefile` syntax and rules = |
| | 124 | |
| | 125 | Makefiles in source directories may use the following variables: |
| | 126 | `objs`:: |
| | 127 | A list of .o files compiled from `.c`, `.s` or `.S` files |
| | 128 | `meta`:: |
| | 129 | A list of files that may be translated from `.m4`, `.cpp` or `.def` files |
| | 130 | `copy`:: |
| | 131 | A list of files that must be copied verbatim from source directory to object directory |
| | 132 | `subdirs`:: |
| | 133 | A list of subdirectories where more files are to be processed. These directories must exist and contain a `Makefile`. |
| | 134 | `doc_headers`:: |
| | 135 | 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. |
| | 136 | |
| | 137 | `Makefiles` may contain optional flags that may be used for compilation: |
| | 138 | `file.o_CFLAGS=…`:: |
| | 139 | CFLAGS to use for a given object |
| | 140 | `DIR_CFLAGS=…`:: |
| | 141 | 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. |
| | 142 | |
| | 143 | Moreover, one may use `ifeq (…,…)` make constructs to conditionally compile different things. Configuration tokens are usable. |
| | 144 | |
| | 145 | Example: |
| | 146 | {{{ |
| | 147 | objs = main.o |
| | 148 | |
| | 149 | ifeq ($(CONFIG_SRL_SOCLIB),defined) |
| | 150 | objs += barrier.o sched_wait.o srl_log.o hw_init.o |
| | 151 | else |
| | 152 | objs += posix_wait_cycles.o |
| | 153 | endif |
| | 154 | |
| | 155 | main.o_CFLAGS = -O0 -ggdb |
| | 156 | }}} |
| | 157 | |
| | 158 | = The `arch/` and `cpu/` specific parts = |
| | 159 | |
| | 160 | Architecture and CPU directories have some special files which are injected in the building process: |
| | 161 | * config.mk, included by make. It can define some compilation flags |
| | 162 | * ldscript, invoked at link-time. |
| | 163 | * Architecture ldscript must create a loadable binary |
| | 164 | * CPU ldscript usually only specifies the entry point name |
| | 165 | |
| | 166 | == The `config.mk` file == |
| | 167 | |
| | 168 | The arch `config.mk` may override the following variables: |
| | 169 | `ARCHCFLAGS`:: |
| | 170 | C-compiler flags |
| | 171 | `ARCHLDFLAGS`:: |
| | 172 | Linker flags |
| | 173 | `LD_NO_Q`:: |
| | 174 | Linker for the current architecture does not support -q switch, this slightly changes the linking process. |
| | 175 | `HOSTCPPFLAGS`:: |
| | 176 | Flags to give to host's cpp (HOSTCPP) program. This is only used for expansion of `.def` files. |
| | 177 | |
| | 178 | The cpu `config.mk` may override the following variables: |
| | 179 | |
| | 180 | `CPUCFLAGS`:: |
| | 181 | C-compiler flags |
| | 182 | `CPULDFLAGS`:: |
| | 183 | Linker flags |
| | 184 | |
| | 185 | == The `ldscript` file == |
| | 186 | |
| | 187 | Try `info ld` for a guide through ldscripts… |
| | 188 | |
| | 189 | This ldscript is taken from architecture's object directory, thus it may be obtained from either: |
| | 190 | * copy |
| | 191 | * m4 processing |
| | 192 | * cpp processing |
| | 193 | |
| | 194 | See |
| | 195 | [source:trunk/mutekh/arch/emu/ldscript arch/emu/ldscript], |
| | 196 | [source:trunk/mutekh/arch/soclib/ldscript.m4 arch/soclib/ldscript.m4], and |
| | 197 | [source:trunk/mutekh/arch/simple/ldscript.cpp arch/simple/ldscript.cpp] for the three flavors ! |
| | 198 | |
| | 199 | = Notes = |
| | 200 | == Prerequisites == |
| | 201 | |
| | 202 | The MutekH build-system is based on GNU Make features. It makes intensive use of: |
| | 203 | * includes |
| | 204 | * $(foreach) $(subst) $(eval) $(call) macros |
| | 205 | * macro definitions |
| | 206 | Therefore, a Make-3.81 at least is mandatory. |
| | 207 | |
| | 208 | The configuration script requires perl >= 5.8. |