Using the build system

Genode relies on a custom tool chain, which can be downloaded at the following website:

Tool chain

https://genode.org/download/tool-chain

Build directory

The build system never touches the source tree but generates object files, libraries, and programs in a dedicated build directory. We do not have a build directory yet. For a quick start, let us create one using the following command:

 cd <genode-dir>
 ./tool/create_builddir x86_64

To follow the subsequent steps of test driving the Linux version of Genode, the specified platform argument should match your host OS installation. If you are using a 32-bit installation, specify x86_32 instead of x86_64.

The command creates a new build directory at build/x86_64.

Build configuration

Before using the build directory, it is recommended to revisit and possibly adjust the build configuration, which is located in the etc/ subdirectory of the build directory, e.g., build/x86_64/etc/. The build.conf file contains global build parameters, in particular the selection of source-code repositories to be incorporated, the kernel to use (KERNEL), and the targeted board (BOARD). It is also a suitable place for adding global build options. For example, for enabling GNU make to use 4 CPU cores, use the following line in the build.conf file:

 MAKE += -j4

You may also consider speeding up your workflow by enabling the use of the compiler cache (ccache) using the following line:

 CCACHE := yes

Building components

The recipe for building a component has the form of a target.mk file within the src/ directory of one of the source-code repositories. For example, the target.mk file of the init component is located at <genode-dir>/repos/os/src/init/target.mk. To build the component, execute the following command from within the build directory:

 make init

The argument "init" refers to the path relative to the src/ subdirectory. The build system determines and builds all targets found under this path in all source-code repositories. When the build is finished, the resulting executable binary can be found in a subdirectory that matches the target's path. Additionally, the build system installs a symbolic link in the bin/ subdirectory that points to the executable binary. It also installs symbolic links to the debug version of the executable binary along with its symbol information at the bin/debug/ subdirectory.

If the specified path contains multiple target.mk files in different subdirectories, the build system builds all of them. For example, the following command builds all targets found within one of the <repo>/src/drivers/ subdirectories:

 make drivers

Static libraries are implicitly built whenever needed by a dependent target. Shared libraries can be built by specifying lib/<name> as target where <name> corresponds to the name of the library. For example, the following command builds the vfs library from the library description found at repos/os/lib/mk/vfs.mk. The result can be found within the build directory at var/libcache/vfs/.

 make lib/vfs

Furthermore, it is possible to specify multiple targets at once. The following command builds both the init component, the nitpicker GUI server component, and the vfs library:

 make init server/nitpicker lib/vfs