aboutsummaryrefslogtreecommitdiffstats
path: root/build.sh
blob: 606f7107f665ff3dd069d8321e9fe560601becb8 (plain)
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
#!/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"
bues.ch cgit interface