Public | Automated Build

Last pushed: 2 years ago
Short Description
Machinekit Builder V3: Cross-build MK Debian packages in Docker using `gcc --sysroot`
Full Description

Machinekit Builder v. 3

This builds a Docker image containing multistrap system root trees
for Debian Jessie armhf and i386 architectures, with tools in the
native system to cross-build Machinekit.

These containers are suitable for use either interactively on a
workstation or in automated build environments like Travis CI.

Right now, this build method is still under initial evaluation. While
the RIP build result will pass regression tests on a native ARM host,
and while the Debian packages will build, most functionality has never
been tested. Build results may have unpredicted results, and are
only suited for testing in simulated development environments.

Using the builder

  • Pull or build the Docker image

    • Pull image, jessie tag, from Docker Hub

          docker pull zultron/mk-builder-3:jessie
    • Or, build image from Dockerfile

      • Clone this repository and cd into the directory

          git clone
          cd mk-builder-3
      • Customize the Set up environment section the Dockerfile as

        • For interactive use, it may be practical to set $UID and
          $GID to match those outside the container.
      • Build Docker image

          ./ build
  • Start the Docker image

    • If $MK_BUILDER is the path to this clone (and $MK is the path
      to the Machinekit clone)

          cd $MK
  • Build Machinekit packages

    • Prepare the source (as usual)

        debian/configure -prxt 8.6
    • Build amd64 and architecture independent binary packages (as usual)

        dpkg-buildpackage -uc -us -b
    • Build i386 binary packages

        DPKG_ROOT=$I386_ROOT \
        LDFLAGS="-m32 --sysroot=$I386_ROOT" \
        CPPFLAGS="-m32 --sysroot=$I386_ROOT" \
        dpkg-buildpackage -uc -us -a i386 -B -d
    • Build armhf binary packages

        LDFLAGS=--sysroot=$ARM_ROOT \
        CPPFLAGS=--sysroot=$ARM_ROOT \
        dpkg-buildpackage -uc -us -a armhf -B -d
  • Build Machinekit RIP

    • Init autoconf (as usual)

        cd src && ./
    • Configure and build for amd64

    • Configure and build for i386

        CPPFLAGS="--sysroot=$I386_ROOT -m32"
        LDFLAGS="--sysroot=$I386_ROOT -m32" \
        ./configure --host=$I386_HOST_MULTIARCH
        CPPFLAGS="--sysroot=$I386_ROOT -m32" \
        LDFLAGS="--sysroot=$I386_ROOT -m32" \
        make -j4
    • Configure and build for armhf

        CPPFLAGS=--sysroot=$ARM_ROOT \
        LDFLAGS=--sysroot=$ARM_ROOT \
        ./configure --host=$ARM_HOST_MULTIARCH
        CPPFLAGS=--sysroot=$ARM_ROOT \
        LDFLAGS=--sysroot=$ARM_ROOT \
  • Setuid (as usual)

      sudo make setuid

How it works

This Dockerfile bootstraps foreign-arch system roots (using
multiarch) with needed host-architecture dependencies installed. It
makes a few adjustments to links and package build tools, and installs
the Emdebian armhf cross-compile tool chain. The commands above to
cross-build Machinekit instruct the compilers, linkers and build tools
to look for architecture-specific headers, libraries and build
configuration under the foreign-arch system root.

This method works around the rapidly progressing but still not yet
complete Debian Multi-Arch: support, where packages not yet
Multi-Arch:-aware may not have foreign-arch versions installed next
to or instead of native-arch versions, and cross-build dependencies
cannot be satisfied. Even once Multi-Arch: works to build against
Debian mainline package streams, someday, this method also enables
building against e.g. a Raspbian system root, where lagging package
versions are sufficient to break Multi-Arch: package installation.


  • Test build viability
    • Currently, RIP builds are known to pass regression tests (the
      built source tree must be copied to an ARM host with Machinekit
      run-time dependencies installed to test).
    • Packages have not been tested. Their viability must be determined
      before taking this project further.
  • Wheezy builds
    • The Emdebian repo was compromised some time back, and Wheezy
      cross-build tool chains were lost. That may be a problem for
      armhf architecture builds.
  • Other achitectures:
    • Raspberry Pi builds should work the same way as armhf. The tool
      chain may be different for armel.
Docker Pull Command
Source Repository