Skip to content

Commit 31e2d2f

Browse files
mguetschowcrasbe
andcommitted
guides/build-system: document more targets
Co-authored-by: crasbe <[email protected]>
1 parent 5196bac commit 31e2d2f

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

doc/guides/build-system/build_system.mdx

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Makefile providing at least the following variables:
1313
* `RIOTBASE`: specifies the path to your copy of the RIOT repository (note,
1414
that you may want to use `$(CURDIR)` here, to give a relative path)
1515

16-
Additionally it has to include the `Makefile.include`, located in RIOT's root
16+
Additionally, it has to include the `Makefile.include`, located in RIOT's root
1717
directory:
1818

1919
```make title="a minimal application Makefile"
@@ -32,27 +32,54 @@ platform, using the sample Makefile, by invoking make like this:
3232
make BOARD=iotlab-m3
3333
```
3434

35+
## Makefile targets
36+
3537
Besides typical targets like `clean`, `all`, or `doc`, RIOT provides the
3638
special targets `flash` and `term` to invoke the configured flashing and
3739
terminal tools for the specified platform. These targets use the variable
38-
`PORT` for the serial communication to the device. Neither this variable nor
39-
the targets `flash` and `term` are mandatory for the native port.
40+
`PORT` for the serial communication to the device, which defaults to
41+
`/dev/ttyACM0` and `/dev/tty.usbmodem*` on Linux and macOS, respectively.
42+
([source](https://github.com/RIOT-OS/RIOT/blob/master/makefiles/tools/serial.inc.mk#L37-L38)).
43+
Setting `MOST_RECENT_PORT=1` enables a more sophisticated serial port selection
44+
algorithm, which selects the most recently connected serial port whose metadata
45+
matches the board's known properties.
4046

4147
For the native port, `PORT` has a special meaning: it is used to identify the
4248
tap interface if the `netdev_tap` module is used. The target `debug` can be
43-
used to invoke a debugger on some platforms. For the native port the additional
49+
used to invoke a debugger on some platforms. For the native port additional
4450
targets such as `all-valgrind` and `valgrind` exist. Refer to
45-
`cpu/native/README.md` for additional information
51+
`cpu/native/README.md` for additional information.
52+
53+
The make target `help` lists all available targets, of which
54+
[the zsh completion script](https://github.com/RIOT-OS/RIOT/blob/master/dist/tools/zsh-completion/zsh-riot.zsh#L96-L126)
55+
offers a short description.
56+
57+
Notable targets include `info-*` targets which provide further information about
58+
the build system. As such, `info-modules` list all (recursively) included modules
59+
in the build, and `info-build` shows more details about the build: among others,
60+
include paths, a list of included Makefiles, and the `CFLAGS` used for the build.
61+
62+
## Build System Internals
63+
64+
### Basic
4665

47-
Some RIOT directories contain special Makefiles like `Makefile.base`,
48-
`Makefile.include` or `Makefile.dep`. The first one can be included into other
49-
Makefiles to define some standard targets. The files called `Makefile.include`
50-
are used in `boards` and `cpu` to append target specific information to
51-
variables like `INCLUDES`, setting the include paths. `Makefile.dep` serves to
52-
define dependencies.
66+
RIOT uses a recursive Makefile system. The starting point for these structure
67+
is typically the Makefile within the application's Makefile. Among other
68+
variables it sets the path to the RIOT repository as `RIOTBASE`.
69+
70+
### Makefiles
71+
72+
There is a number of special Makefiles in RIOT:
73+
74+
- `Makefile.include` in RIOT module directories: appends target-specific
75+
information to variables like `INCLUDES`, setting the include paths, etc.
76+
- `Makefile.include` in `RIOTBASE`: Part of the internal build system architecture
77+
and should be included in an application's `Makefile` as the last line.
78+
- `Makefile.base`: Meant for inclusion as the last line in a RIOT module's
79+
`Makefile`.
80+
- `Makefile.dep` serves to define dependencies for RIOT modules.
81+
- `makefiles/vars.inc.mk`: All RIOT specific variables used in the Make build
82+
system are listed and briefly explained in Makefile.vars.
5383

5484
Unless specified otherwise, make will create an elf-file as well as an Intel
5585
hex file in the `bin` folder of your application directory.
56-
57-
Learn more about the build system in the
58-
[Wiki](https://github.com/RIOT-OS/RIOT/wiki/The-Make-Build-System)

0 commit comments

Comments
 (0)