# mk Tools

Source: [https://docs.qualcomm.com/doc/80-41102-4/topic/mk-Tools.html](https://docs.qualcomm.com/doc/80-41102-4/topic/mk-Tools.html)

## Overview

| Tool | Description |
| --- | --- |
| [mksys](https://docs.qualcomm.com/doc/80-41102-4/topic/mksys.html) | Generate a system bundle to install and run on a target. |
| [mkapp](https://docs.qualcomm.com/doc/80-41102-4/topic/mkapp.html) | 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](https://docs.qualcomm.com/doc/80-41102-4/topic/mkexe.html) | Create an executable program. (You should never need this.) |
| [mkcomp](https://docs.qualcomm.com/doc/80-41102-4/topic/mkcomp.html) | Pre-build a component library ( .so) file. (You should never need this.) |

[mksys](https://docs.qualcomm.com/doc/80-41102-4/topic/mksys.html) 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](https://docs.qualcomm.com/doc/80-41102-4/topic/mksys.html) 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++

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 "SA515M" target with `mksys:`

    $ mksys -t sa515m mySystem.sdefCopy to clipboard

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 sa515m mySystem.sdefCopy to clipboard

will use the following environment variables if they are set:

    SA515M_CC
    SA515M_CXX
    SA515M_LD
    SA515M_AR
    SA515M_AS
    SA515M_STRIP
    SA515M_OBJCOPY
    SA515M_READELF
    SA515M_SYSROOTCopy to clipboard

Note: The target name specified on the command-line will also be made available to def files in the `TELAF_TARGET` environment variable.

## 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 `SA515M_CC` can't be found, then the mk tools will look for `SA515M_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`, `SA515M_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 `SA515M` target and all of `SA515M_CC`, `SA515M_CC`, and `CC` are not set, then the mk tools will generate `CC` as follows:

    CC=${SA515M_TOOLCHAIN_DIR}/${SA515M_TOOLCHAIN_PREFIX}gccCopy to clipboard

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., `SA515M_TOOLCHAIN_DIR`.

- **[mkapp](https://docs.qualcomm.com/doc/80-41102-4/topic/mkapp.html)**
- **[mkexe](https://docs.qualcomm.com/doc/80-41102-4/topic/mkexe.html)**
- **[mkcomp](https://docs.qualcomm.com/doc/80-41102-4/topic/mkcomp.html)**
- **[mksys](https://docs.qualcomm.com/doc/80-41102-4/topic/mksys.html)**

**Parent Topic:** [Build Tools](https://docs.qualcomm.com/doc/80-41102-4/topic/Build-Tools.html)

Last Published: Jan 13, 2025

[Previous Topic
Build Tools](https://docs.qualcomm.com/bundle/publicresource/80-41102-4/topics/Build-Tools.md) [Next Topic
mkapp](https://docs.qualcomm.com/bundle/publicresource/80-41102-4/topics/mkapp.md)