1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-20 21:17:46 +00:00
nixpkgs/pkgs/development/tools/misc/blackmagic/helper.sh
Richard Marko 87057d9bdc blackmagic: add libusb, pkgconfig. expose pc-* (hosted) targets
Add myself to maintainers and change meta.platforms to platforms.linux
due to build failures on Darwin.
2020-02-20 11:07:17 +01:00

61 lines
1.7 KiB
Bash
Executable file

################################################################################
# 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
install -m 0555 blackmagic "$out/bin"
fi
if [ "$1" = "pc-hosted" ]; then
install -m 0555 blackmagic_hosted "$out/bin"
fi
if [ "$1" = "pc-stlinkv2" ]; then
install -m 0555 blackmagic_stlinkv2 "$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
mkdir -p "$out/bin"
for platform in platforms/*/Makefile.inc; do
probe=$(basename "$(dirname "$platform")")
make_platform "$probe"
done