NOTE: The following info are valid for MaKL versions older then 1.8.0. If you’re using MaKL ver. 1.8.0 and above see makl_toolchain_ng
MaKL toolchains are files which contain settings about the tools (and corresponding parameters) used in the configuration and build process.
MaKL is completely agnostic with respect to the specific toolchain it is using at a given time. This behaviour leads to a very natural way of performing cross compilation: it is sufficient to tell MaKL that the toolchain to use is the “cross-compilation” one and that’s all. Per-project toolchains are another possible way to exploit this feature.
When MaKL is installed, a system-wide toolchain is installed (via ${GNUMAKE} toolchain target ), containing sensible settings for the host system. This toolchain is silently used by makl every time you invoke it.
Anyway the active toolchain can be changed at any moment - e.g. as already said on a per-project basis - by setting the MAKL_ETC environment variable. The MAKL_ETC value can be inspected via makl-help command. By default it is unset, meaning that the system-wide (i.e. $MAKL_DIR/etc) is in use.
When set, the MAKL_ETC environment variable must point to a directory containing the toolchain (.cf and .mk) and shared library files to use. The standard way to create such files is to let the makl-tc command derive them for you from a well formatted .tc file.
So long we’ve been going backwards. Now let’s turn things upside-down: starting from a .tc file we’re doing all steps that lead us to cross compilation.
Let’s say we want to build for the ARM platform on a Intel based machine and all the needed cross compilation tools reside in /home/arm/toolchain-arm_gcc4.1.2/bin/ directory. Our .tc file (say /home/me/my-project/target/arm.tc) is then:
> cat << EOF > /home/me/my-project/target/arm.tc
# toolchain basedir
XC_BASE = /home/arm/toolchain-arm_gcc4.1.2/bin/
# build tools
CC = ${XC_BASE}/arm-linux-gcc
CXX = ${XC_BASE}/arm-linux-g++
AR = ${XC_BASE}/arm-linux-ar
RANLIB = ${XC_BASE}/arm-linux-ranlib
LD = ${XC_BASE}/arm-linux-ld
NM = ${XC_BASE}/arm-linux-nm
STRIP = ${XC_BASE}/arm-linux-strip
INSTALL_STRIP =
EOF
Now we have to choose where our MAKL_ETC directory is, say, /home/me/my-project/target/makl-etc/ and invoke makl-tc to do its job:
> mkdir -p /home/me/my-project/target/makl-etc/ > env MAKL_TC_FILE=/home/me/my-project/target/arm.tc \ MAKL_ETC=/home/me/my-project/target/makl-etc/ \ MAKL_SHLIB=null.mk \ makl-tc
Now that the ARM toolchain is in place, you’d want to automatically switch to it when entering you project root directory. That’s where .maklrc file comes in handy:
> cat << EOF > /home/me/my-project/.maklrc export MAKL_ETC="/home/me/my-project/target/makl-etc/" EOF
From now on, whenever you call makl from within your project root directory (if directory nesting is > 5, set MAKL_RC_MAXDEPTH in the environment to the needed value), the ARM toolchain will be used.
MaKL comes with a host of ready-made toolchain files, including host specific and cross compilation ones.
In the previous scenario you could first of all check if a suitable .tc files already exists in the set of bundled toolchains:
cygwin.tc linux-mipsel.tc qnx-armle.tc darwin.tc linux-powerpc.tc qnx-mipsbe.tc default.tc linux-sh4.tc qnx-mipsle.tc freebsd.tc linux.tc qnx-ppcbe.tc linux-arm.tc makl_tc qnx-shle.tc linux-cris-axis.tc mingw.tc qnx-x86.tc linux-i386.tc netbsd.tc vxworks-default.tc linux-m68k.tc openbsd.tc vxworks-x86.tc linux-mips.tc qnx-armbe.tc
Suppose that after careful inspection you decide that the linux-arm.tc is good for you, then the toolchain creation step above would be overridden by the following:
> mkdir -p /home/me/my-project/target/makl-etc/ > env MAKL_TC=linux-arm MAKL_ETC=/home/me/my-project/target/makl-etc/ makl-tc