···11-################################################################################
22-# Build all of the platforms manually since the `all_platforms' target
33-# doesn't preserve all of the build outputs and overrides CFLAGS.
44-set -e
55-set -u
66-77-################################################################################
88-# Prevent a warning from shellcheck:
99-out=${out:-/tmp}
1010-1111-################################################################################
1212-export MAKEFLAGS="\
1313- ${enableParallelBuilding:+-j${NIX_BUILD_CORES}}"
1414-1515-################################################################################
1616-PRODUCTS="blackmagic.bin blackmagic.hex blackmagic_dfu.bin blackmagic_dfu.hex"
1717-1818-################################################################################
1919-make_platform() {
2020- echo "Building for hardware platform $1"
2121-2222- make clean
2323- make PROBE_HOST="$1"
2424-2525- if [ "$1" = "hosted" ]; then
2626- install -m 0555 blackmagic "$out/bin"
2727- fi
2828-2929- for f in $PRODUCTS; do
3030- if [ -r "$f" ]; then
3131- mkdir -p "$out/firmware/$1"
3232- install -m 0444 "$f" "$out/firmware/$1"
3333- fi
3434- done
3535-3636-}
3737-3838-################################################################################
3939-# Start by building libopencm3:
4040-make -C libopencm3
4141-4242-################################################################################
4343-# And now all of the platforms:
4444-cd src
4545-4646-mkdir -p "$out/bin"
4747-4848-for platform in platforms/*/Makefile.inc; do
4949- probe=$(basename "$(dirname "$platform")")
5050- make_platform "$probe"
5151-done