Build Environment

Build Environment

12 July 2024 seperator dot clairet

 

Dependencies

Windows

  • Windows 10 / Windows 11
  • Visual Studio 2022 Professional
  • GIT SCM – GIT source control utility
  • OpenSSL 3.0.9

 

Linux

Debian based Linux – Ubuntu or Windows Subsystem for Linux (WSL)

  • Required packages:
    • build-essentials
      • Package provides the common build packages e.g, gcc, g++, make
    • python3
      • Required to generate files from KeyScaler tenant XML files
      • Ideally Python 3.10

 

Ubuntu

  • Install Ubuntu (use VirtualBox or WSL2 in Windows)
  • For compatibility with older GCC libraries a sysroot can be configured that allows for cross compilation. Use a
    tool such as such as crosstools (x-tools) to build the environment.
  • Within Ubuntu install:
    • sudo apt install build-essential zlib1g-dev libcurl4-openssl-dev python3

Note that the scripts directory included within the GitHub repositories contains scripts that download and compile
further third-party dependencies.

 

[Back to Top]

 

Makefiles (Linux)

DDKG and Credential Manager both use Makefiles to enable the compilation of the application.

This page details the Makefiles, how they are used and their capabilities.

 

DDKG

Makefile capabilities

The makefiles have the following capabilities:

Make debug

If debugging DDKG (e.g., with gdb) the software should be built as a debug library with all symbol information attached:

make BUILD_TARGET=debug

This command will output files in the dist/debug directory.

Make release

When building a release version of DDKG, optimising for size and speed, the following command should be used:

make BUILD_TARGET=release

This command will output files in the dist/release/ directory.

 

Makefiles

make_tinyxml.mk: Builds the tinyxml.a library
make_ossp_uuid.mk:Builds the ossp_uuid.a library
make_libnauddk_shared.mk: Builds the DDKG library – libnaudaddk_shared.so
make_ddkdemo.mk: Builds the DDKDemo application
makefile: Parent makefile that executes the above makefiles

Note that it is expected that you will only run `make` which defaults to running the makefile file

 

[Back to Top]

 

Credential Manager

Makefile capabilities

The makefiles have the following capabilities:

Disable MQTT support

If we do not need MQTT protocol support we can remove the mosquitto dependency by declaring the environment variable
DISABLE_MQTT=1 e.g.,

DISABLE_MQTT=1 make release

Disable TPM support

If we do not need TPM support we can remove tpm2tss and associated dependencies from the application by declaring the
environment variable DISABLE_TPM=1 e.g.,

DISABLE_TPM=1 make release

Make debug

If debugging credential manager (e.g., with gdb) the software should be built as a debug application with all symbol
information attached:

make

This command will output files in the dist/debug directory.

Make release

When building a release version of credential manager, optimising for size and speed, the following command should be
used:

make BUILD_TARGET=release

This command will output files in the dist/release directory.

 

Makefiles

make_agent.mk: Compiles the credential_manager application
makefile: Parent makefile that executes the above makefiles

Note that it is expected that you will only run `make` which defaults to running the makefile file

 

[Back to Top]

 

Cross Compilation

For Linux platforms we use cross compilation to build DDKG and Credential Manager for a specific target from an Intel
based host OS.

Build Crosstool-NG

The following commands should be executed to build Crosstool-NG in Ubuntu.

Replace VERSION with the
latest version (or target version) of Crosstool-NG

wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-VERSION.tar.bz2
tar -xf crosstool-ng-VERSION.tar.bz2
cd crosstool-ng-VERSION/

# install dependencies
sudo apt update
sudo apt install flex
sudo apt install texinfo
sudo apt install help2man
sudo apt install libtool-bin libtool-doc
sudo apt install libcurses-ocaml-dev
sudo apt install install-info info
sudo apt install bison byacc

./configure # check no errors / missing dependencies
make -j4

sudo make install
 

Add Crosstool-NG Build Environment

Crosstool-NG allows you to create a sysroot for a specific target platform. The
following command adds a target environment to Crosstool-NG using the following commands:

ct-ng <target> # Configure the target e.g., arm-unknown-linux-gnueabi
ct-ng build

This writes the build environment to ~/x-tools/

Configure environment variables for cross compilation

To compile DDKG or Credential Manager using a cross compilation sysroot, the following environment variables should be
configured:

Environment Variable

Target

TOOLCHAIN

The target toolchain e.g. armv8-rpi3-linux-gnuabihf

CROSS_COMPILE

Generally is the same as toolchain e.g., CROSS_COMPILER=${TOOLCHAIN}

CROSS_CPU

The target CPU e.g., armv7

CROSS_CFLAGS

The cross compiler C flags – e.g., -DLX_DDKG specifying we are building DDKG v1

CROSS_CXXFLAGS

The cross compiler CXX flags – e.g., -DLX_DDKG specifying we are building DDKG v1

After configuring these environment variables, re-build the dependencies by running the provided scripts, then run
make to build the DDKG or Credential Manager for the target platform.

[Back to Top]