# Build Scripts

Scripts to build software libraries for various systems.

Libraries for Windows are built for static linking, for simple single-file EXE distribution.

Libraries for Web are built for static linking, as Emscripten does not yet support shared libraries.

Libraries for Android are built for static linking. Targets Android API level 21 (Android 5.0, Lollipop, 2014).

# 1 Source Code

code.mathr.co.uk/build-scripts

git clone https://code.mathr.co.uk/build-scripts.git

# 2 Prerequisites

Tested on Debian Bookworm x86_64.

  • mingw-w64, wine, with i386 multiarch (for x86_64 and i686 builds for Windows, pre-installed in /usr/); See distribution packages, current version 10.0.0-3 (Debian Bookworm).

  • llvm-mingw (for aarch64 and armv7 builds for Windows, pre-installed in ${HOME}/opt/llvm-mingw/, with its bin in the PATH environment variable after /usr/bin); See https://github.com/mstorsjo/llvm-mingw/releases, current version 2023-11-28 with LLVM 17.0.6 (Ubuntu 20.04 MSVCRT x86_64).

  • emsdk (for emscripten builds for Web, installed automatically in ${HOME}/opt/src/emsdk); See https://github.com/emscripten-core/emsdk, current version 3.1.53.

  • Android SDK + NDK in ${ANDROID_HOME} and ${ANDROID_NDK_HOME} (for builds for Android, see below for setup) A complete build of everything for Android needs about 5.2GB of disk space.

  • a complete build of everything else needs about 10GB of disk space.

# 3 Usage

  • ./BUILD.sh download "lib ..." will download the source code for the libraries to ${HOME}/opt/src.

  • ./BUILD.sh arch "lib ..." will build the specified libraries for the specified architecture storing the results in ${HOME}/opt/windows/... and ${HOME}/opt/emscripten/...

Both commands default to all libraries if not specified.

# 4 Architectures:

  • x86_64-w64-mingw32 - Windows Intel 64bit
  • i686-w64-mingw32 - Windows Intel 32bit
  • aarch64-w64-mingw32 - Windows ARM 64bit
  • armv7-w64-mingw32 - Windows ARM 32bit
  • emscripten - Web (WASM, Javascript and HTML etc)
  • aarch64-linux-android21 - Android ARM 64bit
  • armv7a-linux-androideabi21 - Android ARM 32bit
  • x86_64-linux-android21 - Android Intel 64bit
  • i686-linux-android21 - Android Intel 32bit

# 5 Libraries

These build scripts are kept up to date. More may be added.

  • clew - latest - git clone/update
  • deflate - 1.20
  • emsdk - latest - git clone/update
  • flite - latest - git clone/update
  • fftw3 - 3.3.10
  • glew - 2.2.0 - copies glew.c to include/GL, for compilation with -DGLEW_STATIC
  • glfw - 3.3.10 - not emscripten or Android (suggest using sdl2 instead)
  • glm - 1.0.1
  • gmp - 6.3.0
  • imath - 3.1.11
  • jpeg - 3.0.3 - libjpeg-turbo
  • mpc - 1.3.1 - depends on mpfr (and thus gmp)
  • mpfr - 4.2.1 - depends on gmp
  • mpreal - 3.7.1 - depends on mpfr (and thus gmp) - also known as mpfrc++
  • openexr3 - 3.2.4 - depends on imath and deflate
  • opengl - latest - Khronos OpenGL API headers
  • png - 1.6.43 - depends on zlib
  • sdl2 - 2.30.2 - emscripten has a built in version, Android app framework needs to be built differently
  • toml11 - latest - git clone/update
  • zlib - 1.3.1

# 5.1 Old Libraries

These build scripts are no longer updated, but may still work if you need them.

  • openexr2 - 2.5.8 - depends on zlib, has a built in version of imath

# 6 Android

# 6.1 SDK and NDK

Use Debian’s sdkmanager to install upstream’s stuff. Requires accepting some custom licenses.

sudo apt install default-jre sdkmanager
export ANDROID_HOME="/opt/android-sdk"
sudo mkdir -p $ANDROID_HOME
sudo chown $USER $ANDROID_HOME
sdkmanager "cmdline-tools;latest"
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \
  "platform-tools" \
  "platforms;android-21" \
  "ndk;25.2.9519653"

Add to ~/.bashrc or similar:

export ANDROID_HOME="/opt/android-sdk"
export ANDROID_NDK_HOME="${ANDROID_HOME}/ndk/25.2.9519653"
PATH="${ANDROID_HOME}/tools:$PATH"
PATH="${ANDROID_HOME}/platform-tools:$PATH"
PATH="${ANDROID_NDK_HOME}:$PATH"

# 6.2 Emulator

If you have KVM support on your x86_64 system:

$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \
  "emulator" \
  "system-images;android-21;default;x86_64"
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd \
  --tag default --package "system-images;android-21;default;x86_64" \
  --sdcard 64M --device "Nexus 5" --name Nexus_5_API_21
$ANDROID_HOME/emulator/emulator @Nexus_5_API_21
$ANDROID_HOME/platform-tools/adb -e install *.apk

# 6.3 SDL2

See Fraktaler 3 for a non-trivial program built for Android using barely-modified SDL2 app framework with dependent libraries built with this project.