| | 1 | |
| | 2 | This document describes the MutekH build system. |
| | 3 | |
| | 4 | = Overview of the build process = |
| | 5 | |
| | 6 | The build system take a configuration file, processes the dependancies, and compiles the desired kernel. |
| | 7 | |
| | 8 | Depending on the targeted architecture, the output file may be an ELF (.out), a plain binary file (.bin), an intel-hex file (.hex) or an object file (.o). |
| | 9 | |
| | 10 | The build system takes care of dependancies, file modifications, ... |
| | 11 | |
| | 12 | = User point of view = |
| | 13 | |
| | 14 | == Makefile options (command line) == |
| | 15 | |
| | 16 | When building with MutekH, several options may be used to change the behavior of the build system. |
| | 17 | These options are given through variables when calling `make`, in the form: |
| | 18 | {{{ |
| | 19 | $ make VAR1=value1 VAR2=value2 |
| | 20 | }}} |
| | 21 | |
| | 22 | The following options are mandatory: |
| | 23 | `CONF=`:: |
| | 24 | An absolute path to the root configuration file for the desired kernel instance. |
| | 25 | |
| | 26 | The following options may be useful: |
| | 27 | `VERBOSE=1`:: |
| | 28 | Prints all the commands executed |
| | 29 | |
| | 30 | The following options are useful when building out of the source tree: |
| | 31 | `MUTEK_SRC_DIR`:: |
| | 32 | An absolute path to the MutekH source tree. This defaults to `.` |
| | 33 | `BUILD_DIR`:: |
| | 34 | An absolute path to the directory containing the objects and results, this defaults to `.` |
| | 35 | `CONF_DIR`:: |
| | 36 | An absolute path to the directory containing the {{{.config.*}}} files, this defaults to `.` |
| | 37 | |
| | 38 | == MutekH configuration files == |
| | 39 | |
| | 40 | MutekH configuration files contain tokens defining the kernel we are currently building. They must contain: |
| | 41 | |
| | 42 | * the license for the application, enforcing license compatibility between some kernel parts and your code, |
| | 43 | * the target architecture |
| | 44 | * the libraries used, and their configurations |
| | 45 | * the used drivers |
| | 46 | * some global compilation switches (optimization, debugging, …) |
| | 47 | |
| | 48 | Syntax is `token` '''space''' `value`. Tokens begin with `CONFIG_`, `value` may be unspecified thus defaults to `defined`. e.g. |
| | 49 | {{{ |
| | 50 | CONFIG_LICENSE_APP_LGPL |
| | 51 | |
| | 52 | # Platform type |
| | 53 | CONFIG_ARCH_EMU |
| | 54 | |
| | 55 | # Processor type |
| | 56 | CONFIG_CPU_X86_EMU |
| | 57 | |
| | 58 | # Mutek features |
| | 59 | CONFIG_PTHREAD |
| | 60 | |
| | 61 | CONFIG_MUTEK_CONSOLE |
| | 62 | |
| | 63 | # Device drivers |
| | 64 | CONFIG_DRIVER_CHAR_EMUTTY |
| | 65 | |
| | 66 | # Code compilation options |
| | 67 | CONFIG_COMPILE_DEBUG |
| | 68 | }}} |
| | 69 | |
| | 70 | A configuration file may declare a new module, telling the build system the directory where the configuration file lies has a Makefile and some more objects to build. |
| | 71 | {{{ |
| | 72 | # New source code module to be compiled |
| | 73 | CONFIG_MODULES hello:%CONFIGPATH |
| | 74 | }}} |
| | 75 | |
| | 76 | For the list of all available tokens, do |
| | 77 | {{{ |
| | 78 | $ make listallconfig |
| | 79 | }}} |
| | 80 | |
| | 81 | For a list of current available tokens depending on your configuration file, do |
| | 82 | {{{ |
| | 83 | $ make CONF=path/to/config_file listconfig |
| | 84 | }}} |
| | 85 | |
| | 86 | = Developer point of view = |
| | 87 | |
| | 88 | MutekH has a component-based architecture where each module declares its configuration tokens. |
| | 89 | |
| | 90 | == The xxx.config files == |
| | 91 | |
| | 92 | For each configuration token, one may use the following tags: |
| | 93 | `desc Description string without quotes`:: |
| | 94 | Short description about the token |
| | 95 | `parent TOKEN`:: |
| | 96 | Parent token is help screen. This is only for pretty-printing. |
| | 97 | `require TOKEN […]`:: |
| | 98 | Mandatory requirements, having at least one of the tokens on the line is mandatory, conflict yields error |
| | 99 | `depend TOKEN […]`:: |
| | 100 | Dependencies, having at least one of the tokens on the line is mandatory, conflict implicitly undefines the current token |
| | 101 | `provide TOKEN […]`:: |
| | 102 | Mandatory forced requirements, given tokens are defined, conflict yields an error |
| | 103 | `provide TOKEN=value`:: |
| | 104 | Mandatory forced requirements variant, sets a configuration token to a given value; value must not be `undefined` |
| | 105 | `provide TOKEN=+value`:: |
| | 106 | Mandatory forced requirements variant, adds a value to a configuration token |
| | 107 | `exclude TOKEN`:: |
| | 108 | Mandatory unrequirements, the specified token must not be defined |
| | 109 | `suggest TOKEN […]`:: |
| | 110 | Makes a token suggest other tokens when it is used. This is for help listing. |
| | 111 | `single TOKEN […]`:: |
| | 112 | Require a single one of the following tokens |
| | 113 | |
| | 114 | Example: |
| | 115 | {{{ |
| | 116 | %config CONFIG_SRL |
| | 117 | desc MutekS API |
| | 118 | provide CONFIG_MODULES=+libsrl:%CONFIGPATH |
| | 119 | depend CONFIG_MUTEK_SCHEDULER |
| | 120 | depend CONFIG_MWMR |
| | 121 | require CONFIG_SRL_SOCLIB CONFIG_SRL_STD |
| | 122 | single CONFIG_SRL_SOCLIB CONFIG_SRL_STD |
| | 123 | %config end |
| | 124 | }}} |
| | 125 | |
| | 126 | Here we declare a `CONFIG_SRL` token |
| | 127 | * needing CONFIG_MUTEK_SCHEDULER and CONFIG_MWMR, |
| | 128 | * needing one of `CONFIG_SRL_SOCLIB` or `CONFIG_SRL_STD`, |
| | 129 | * adding the directory containing the .conf as the "libsrl" module |
| | 130 | |
| | 131 | == The directories Makefile syntax & rules == |
| | 132 | |
| | 133 | Makefiles in directories may use the following variables: |
| | 134 | `objs`:: |
| | 135 | A list of .o files compiled from `.c`, `.s` or `.S` files |
| | 136 | `meta`:: |
| | 137 | A list of files that may be translated from `.m4`, `.cpp` or `.def` files |
| | 138 | `copy`:: |
| | 139 | A list of files that must be copied from source directory to object directory |
| | 140 | |
| | 141 | Makefiles may contain optional flags that may be used for compilation: |
| | 142 | `file.o_CFLAGS=…`:: |
| | 143 | CFLAGS to use for a given object |
| | 144 | |
| | 145 | Moreover, one may use `ifeq (…,…)` make constructs to conditionally compile different things. Configuration tokens are usable. |
| | 146 | |
| | 147 | Example: |
| | 148 | {{{ |
| | 149 | objs = main.o |
| | 150 | |
| | 151 | ifeq ($(CONFIG_SRL_SOCLIB),defined) |
| | 152 | objs += barrier.o sched_wait.o srl_log.o hw_init.o |
| | 153 | else |
| | 154 | objs += posix_wait_cycles.o |
| | 155 | endif |
| | 156 | |
| | 157 | main.o_CFLAGS = -O0 -ggdb |
| | 158 | }}} |
| | 159 | |
| | 160 | == The arch & cpu specific parts == |
| | 161 | |
| | 162 | Architecture and CPU directories have some special files which are injected in the building process: |
| | 163 | * config.mk, included by make. It can define some compilation flags |
| | 164 | * ldscript, invoked at link-time. |
| | 165 | * Architecture ldscript must create a loadable binary |
| | 166 | * CPU ldscript usually only specifies the entry point name |
| | 167 | |
| | 168 | === config.mk === |
| | 169 | |
| | 170 | The following variable may be overridden: |
| | 171 | `ARCHCFLAGS`:: |
| | 172 | C-compiler flags |
| | 173 | `ARCHLDFLAGS`:: |
| | 174 | Linker flags |
| | 175 | `LD_NO_Q`:: |
| | 176 | Linker for the current architecture does not support -q switch, this slightly changes the linking process. |
| | 177 | `HOSTCPPFLAGS`:: |
| | 178 | Flags to give to host's cpp (HOSTCPP) program. This is only used for expansion of `.def` files. |
| | 179 | |
| | 180 | === ldscript === |
| | 181 | |
| | 182 | Try `info ld` for a guide through ldscripts… |
| | 183 | |
| | 184 | This ldscript is taken from architecture's object directory, thus it may be obtained from either: |
| | 185 | * copy |
| | 186 | * m4 processing |
| | 187 | * cpp processing |
| | 188 | |
| | 189 | See arch/emu/ldscript, arch/soclib/ldscript, and arch/simple/ldscript for the three flavors ! |
| | 190 | |
| | 191 | = Notes = |
| | 192 | == Prerequisites == |
| | 193 | |
| | 194 | The MutekH build-system is base on GNU Make features. It makes intensive use of: |
| | 195 | * includes |
| | 196 | * $(foreach) $(subst) $(eval) $(call) macros |
| | 197 | * macro definitions |
| | 198 | Therefore, a Make-3.81 at least is mandatory. |