mk Tools

Overview

Tool Description
mksys Generate a system bundle to install and run on a target.
mkapp Generate a binary app package to distribute to others for use in their systems or an app bundle to install and run on a target.
mkexe Create an executable program. (You should never need this.)
mkcomp Pre-build a component library ( .so) file. (You should never need this.)

mksys is the preferred tool to use. It checks inter-app communications bindings to prevent build bugs in your app and prevent the app from hanging at start-up because of missing or misspelled bindings. The output of mksys is an update bundle that contains all the apps that your device should be running, so your device can be atomically updated (meaning all or none). Using this approach ensures that your device is never left in a partially-updated, non-working state.

Tool Chain Configuration

This section describes how the mk tools choose what compilers, linkers, etc. to use and how to control that choice.

C/C++

Warning
The mk tools are designed to work with the GNU Compiler Collection (gcc and related tools) and other tools (such as clang) that are command-line compatible with GCC. If your tool chain doesn't accept the same command-line arguments as GCC, then you will almost certainly not be able to use the mk tools.

Target-Specific Tool Path Environment Variables

The selection of compiler, linker, etc., can be controlled by the target command-line option that is provided to the tool via the -t option. E.g., to choose the "wp85" target with mksys:

$ mksys -t wp85 mySystem.sdef

The mk tools will convert this target name to uppercase, and then look for environment variables that begin with this target name as follows (where XXXX should be replaced by the target name in all uppercase):

Env Var Name Tool
XXXX_CC C compiler
XXXX_CXX C++ compiler
XXXX_LD Linker
XXXX_AR Archiver
XXXX_AS Assembler
XXXX_STRIP Debug symbol stripper
XXXX_OBJCOPY Object file copier/translator
XXXX_READELF ELF file information extraction tool

In addition, it's possible to select the compiler sysroot using an environment variable:

Env Var Name Tool
XXXX_SYSROOT C/C++ compiler sysroot directory path
Note
If the compiler sysroot path is not specified, and the compiler is gcc, then the mk tools will ask gcc what its default sysroot path is.

So, for example,

$ mksys -t wp85 mySystem.sdef

will use the following environment variables if they are set:

WP85_CC
WP85_CXX
WP85_LD
WP85_AR
WP85_AS
WP85_STRIP
WP85_OBJCOPY
WP85_READELF
WP85_SYSROOT
Note
The target name specified on the command-line will also be made available to def files in the LEGATO_TARGET environment variable (see Environment Variables).

Using Mixed-Case Target Names

If one of the above mentioned variables is not found, the mk tools will try looking for a variable that does not have the target name converted to all uppercase.

For example, if WP85_CC can't be found, then the mk tools will look for wp85_CC.

Non-Target-Specific Tool Variables

If neither of the above forms of target-specific variable is found for a given tool, the mk tools will look for a non-target-specific variable, such as CC.

XXXX_TOOLCHAIN_DIR and XXXX_TOOLCHAIN_PREFIX

The mk tools also support the option of leaving a tool-specific variable (like CC, WP85_CC, etc.) unset, and instead setting the XXXX_TOOLCHAIN_DIR and/or XXXX_TOOLCHAIN_PREFIX variables.

Env Var Name Tool
XXXX_TOOLCHAIN_DIR Directory in which the build tools can be found
XXXX_TOOLCHAIN_PREFIX Prefix of the names of the tools (e.g., "arm-poky-linux-gnueabi-")

In this case, the mk tools will assume that the tools in the directory specified by XXXX_TOOLCHAIN_DIR are the GNU Compiler Collection, and that the names of those executables are prefixed with the string contained in XXXX_TOOLCHAIN_PREFIX.

For example, if building for the wp85 target and all of WP85_CC, wp85_CC, and CC are not set, then the mk tools will generate CC as follows:

CC=${WP85_TOOLCHAIN_DIR}/${WP85_TOOLCHAIN_PREFIX}gcc

And, if the all-uppercase version of one of these is not found, the mk tools will look for the mixed-case version. E.g., wp85_TOOLCHAIN_DIR.