#!/bin/bash # # Build the Common Firmware Environment (CFE) using the OpenWRT SDK. # set -e thisdir="$(dirname $0)" [ "$(echo $thisdir | cut -b 1)" = "/" ] || thisdir="$PWD/$thisdir" config="$thisdir/build.conf" if ! [ -r "$config" ]; then echo "ERROR: Please create the build configuration file '$config'" exit 1 fi . $config if ! [ -d "$SDK_PATH/staging_dir" ]; then echo "ERROR: Please adjust the SDK_PATH in build.conf to match your setup." exit 1 fi # Cleanup the environment rm -Rf "$thisdir/toolchain" rm -f "$thisdir/cfe.bin" TOOLDIR="$(echo $SDK_PATH/staging_dir/toolchain-mipsel* | sort | awk '{print $NF}')" if [ "$1" != "clean" ]; then # Setup the environment mkdir "$thisdir/toolchain" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-gcc" "$thisdir/toolchain/mipsel-linux-gcc" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-cpp" "$thisdir/toolchain/mipsel-linux-cpp" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-ld" "$thisdir/toolchain/mipsel-linux-ld" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-ar" "$thisdir/toolchain/mipsel-linux-ar" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-ranlib" "$thisdir/toolchain/mipsel-linux-ranlib" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-objcopy" "$thisdir/toolchain/mipsel-linux-objcopy" ln -s "$TOOLDIR/usr/bin/mipsel-openwrt-linux-objdump" "$thisdir/toolchain/mipsel-linux-objdump" export PATH="$thisdir/toolchain:$PATH" fi make -C "$thisdir/cfe/build/broadcom/bcm947xx" $@ if [ "$1" != "clean" ]; then cp "$thisdir/cfe/build/broadcom/bcm947xx/cfe.bin" "$thisdir" fi [ "$1" != "clean" ] && echo "Built cfe.bin"