summary refs log tree commit diff
path: root/pkgs/development/tools/misc/blackmagic/helper.sh
blob: 991d0249e169f362420d0456d1bb0ddbac2d6584 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
################################################################################
# Build all of the platforms manually since the `all_platforms' target
# doesn't preserve all of the build outputs and overrides CFLAGS.
set -e
set -u

################################################################################
# Prevent a warning from shellcheck:
out=${out:-/tmp}

################################################################################
export CFLAGS=$NIX_CFLAGS_COMPILE
export MAKEFLAGS="\
  ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}"

################################################################################
PRODUCTS="blackmagic.bin blackmagic.hex blackmagic_dfu.bin blackmagic_dfu.hex"

################################################################################
make_platform() {
  echo "Building for hardware platform $1"

  make clean
  make PROBE_HOST="$1"

  if [ "$1" = libftdi ]; then
    mkdir -p "$out/bin"
    install -m 0555 blackmagic "$out/bin"
  fi

  for f in $PRODUCTS; do
    if [ -r "$f" ]; then
      mkdir -p "$out/firmware/$1"
      install -m 0444 "$f" "$out/firmware/$1"
    fi
  done

}

################################################################################
# Start by building libopencm3:
make -C libopencm3

################################################################################
# And now all of the platforms:
cd src

for platform in platforms/*/Makefile.inc; do
  probe=$(basename "$(dirname "$platform")")
  make_platform "$probe"
done