[r142]: do-binutils.sh  Maximize  Restore  History

Download this file

96 lines (73 with data), 2.5 kB

 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# This work is partially financed by the European Commission under the
# Framework 6 Information Society Technologies Project
# "Wirelessly Accessible Sensor Populations (WASP)".
#The following versions of BINUTILS have been tested:
# 2.19
# 2.19.1
. ./buildgcc.subr
VERSION_TAG=$(cat _version_tag.txt)
BINUTILS_VERSION=2.20.1
GNU_MIRROR=http://ftp.uni-kl.de
BUILD_DIR=build
INITIAL_DIR="$(pwd)"
FETCH_ONLY=0
WIN32_OPTS=
GNUMAKE=$(find_gnumake)
case "$(uname -s)" in
MINGW*)
WIN32_OPTS=--enable-win32-registry=MSP430-GCC-$VERSION_TAG ;;
esac
set -eu
if [ $# = 0 ]; then
echo "Usage: do-binutils.sh <toolchain target dir> [<binutils_version>] [<GNU mirror site>] [<build dir>] [--fetch-only]"
echo "Example: do-binutils.sh /opt/msp430-gcc-latest $BINUTILS_VERSION $GNU_MIRROR build"
exit 1
fi
TARGET_LOCATION="$1" ; shift
if [ $# -ge 1 ] ; then BINUTILS_VERSION="$1" ; shift ; fi
if [ $# -ge 1 ] ; then GNU_MIRROR="$1" ; shift ; fi
if [ $# -ge 1 ] ; then BUILD_DIR="$1" ; shift ; fi
while [ $# -ge 1 ] ; do
case "$1" in
--fetch-only) FETCH_ONLY=1 ;;
*) echo "Unknown options $@. Abort." ; exit 1;
esac
shift
done
if ! makeinfo --version >/dev/null 2>&1 ; then
exec >&2
echo "==================================================================="
echo "makeinfo is missing from path, but required for the binutils build."
echo "Please install texinfo. Aborting."
echo "==================================================================="
exit 1
fi
INSTALL_LAUNCHER=$(sh do-detect-sudo.sh $TARGET_LOCATION)
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
export "PATH=$PATH:$TARGET_LOCATION/bin"
wget -c "$GNU_MIRROR/pub/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2"
if [ $FETCH_ONLY = 1 ]; then
echo "Binutils $BINUTILS_VERSION downloaded successfully"
exit 0
fi
echo "Unpacking binutils..."
tar xjf "binutils-$BINUTILS_VERSION.tar.bz2"
cd "binutils-$BINUTILS_VERSION"
if [ -e "$INITIAL_DIR/binutils-$BINUTILS_VERSION.patch" ]
then
patch -p1 < "$INITIAL_DIR/binutils-$BINUTILS_VERSION.patch"
fi
cd ..
mkdir -p "binutils-$BINUTILS_VERSION-build"
cd "binutils-$BINUTILS_VERSION-build"
"$(pwd)/../binutils-$BINUTILS_VERSION/configure" "--prefix=$TARGET_LOCATION" --target=msp430 --disable-werror $WIN32_OPTS --disable-nls
$GNUMAKE -j$(num_cpus)
$INSTALL_LAUNCHER $GNUMAKE install
if [ -z "${SUPPRESS_CLEAN+""}" ] ; then
cd ..
rm -rf "binutils-$BINUTILS_VERSION-build"
rm -rf "binutils-$BINUTILS_VERSION"
fi
cd "$INITIAL_DIR"