DOKK / manpages / debian 12 / zmk-doc / zmk.Toolchain.5.en
zmk.Toolchain(5) File Formats Manual (prm) zmk.Toolchain(5)

Toolchainmodule providing information and configuration about compiler toolchain

include z.mk

$(eval $(call ZMK.Import,Toolchain))

The Toolchain module encapsulates information about the used C and C++ compilers. This knowledge is mainly consumed internally by other modules and templates, but can be used directly to construct custom rules.

This module does not provide any targets.

This module provides the following variables.

Please take note that make supports , where a specific variable, for example CFLAGS or LDLIBS takes a particular value only while building a specific target as well as all the targets that it depends on. This scheme is removes the need for additional variables manually customized to a specific target.

The C compiler.

The pre-processor, responsible for macros and include directives.

The C++ compiler.

Configuration options for the C compiler.

This variable should be used to pass options such as , , or . Please refer to your compiler manual for details.

This variable is often abused, mainly for simplicity, as a kitchen-sink that holds all of the compiler and linker options. This is discouraged.

Configurations options for the pre-processor.

This variable should be used to provide command line options that alter the include search path, such as , or define a pre-processor macro, such as .

Configuration options for the C++ compiler. This variable the equivalent of CFLAGS for the C++ compiler.

Configuration options for the Objective C compiler. This variable the equivalent of CFLAGS for the Objective C compiler.

Configuration options for the ar program.

Compiler options for performing architecture selection.

This variable is not used by zmk. Cross compilation is supported by selecting a cross-compiling CC or CXX.

Additional libraries to link with.

Libraries are provided in the form -lfoo where foo is the name of the library, without the prefix . Given the choice of static and dynamic libraries, the linker will prefer dynamic linking. You can a specific library statically with the following option sequence. -Wl,-dn -lfoo -Wl,-dy. The first segment -Wl,-dn turns off dynamic linking -lfoo links to the library libfoo.a while the final turns dynamic linking back again. Note that using this sequence the final executable is not entirely statically linked. If libfoo.a has any additional dependences those must be linked as well, either dynamically or statically.

Configuration options for the linker.

This variable should be used to provide command line options that alter the linker search path, such as , or customize linker behavior. Note that the linker is not invoked directly, but through the compiler front-end. For example, when using gcc, one would typically pass in order to pass the option foo to the linker.

The suffix for executables. It is either empty or has the value , if the of the resulting executable is either PE or MZ.

This variable is automatically used by zmk when building executables.

Path of the root directory where the compiler looks for headers and libraries. A non-empty value causes to be passed to the compiler whenever it is used for compiling, linking or pre-processing.

The default value is , namely the preference from the configuration system.

Expands to yes, if compilation of C, C++ and Objective C source files will automatically generate dependency rules for Make.

The default value is , namely the preference from the configuration system.

Identifier or the application image format generated by the C compiler or the C++ compiler. If the two compilers produce different image formats, for example because one is a the effective value is .

Expands to yes if programs created by the C compiler or the C++ compiler cannot be executed on the machine performing the build.

Expands to yes, if both the C and C++ compilers are from the GNU Compiler Collection.

Expands to yes, if both the C and C++ compilers are from the clang project.

Expands to yes, if both the C and C++ compilers are from the Open Watcom compiler.

Expands to yes if the C compiler is available.

Identifier or the application image format generated by the C compiler. Refer to the documentation of OS.ImageFormat for a description of known formats.

Unless cross-compiling, the default value is $(OS.ImageFormat).

Expands to yes if programs created by the C compiler cannot be executed on the machine performing the build.

Expands to yes, if the selected C compiler is the GNU Compiler Collection. This variable, as well as several others documented below, can be used to conditionally enable compiler specific options in a manner that does not break when another compiler is used.

Expands to yes, if the selected C compiler is clang.

Expands to yes, if the selected C compiler is the Open Watcom compiler.

Expands to yes, if the selected C compiler is the .

Expands to yes if the C++ compiler is available.

Identifier or the application image format generated by the C++ compiler.

Unless cross-compiling, the default value is $(OS.ImageFormat).

Expands to yes if programs created by the C++ compiler cannot be executed on the machine performing the build.

Expands to yes, if the selected C++ compiler is the GNU Compiler Collection.

Expands to yes, if the selected C++ compiler is clang.

Expands to yes, if the selected C++ compiler is the Open Watcom compiler.

The Toolchain module first appeared in zmk 0.3

Zygmunt Krynicki <me@zygoon.pl>

May 3, 2020 zmk 0.5.1