[r85]: buildgcc.sh Maximize Restore History

Download this file

buildgcc.sh    183 lines (158 with data), 4.7 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
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/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 GCC have been tested:
#3.2.3 (patch directory gcc-3.3)
#3.3.6 (patch directory gcc-3.4, additional configure.in patch involved)
#4.2.4
#4.3.4
#4.4.2
: ${DIALOG=dialog}
if ! $DIALOG --version >/dev/null 2>&1 && [ _$1 != _--defaults ]; then
echo "Dialog package not found and --defaults not specified"
echo "Either install dialog package, or run 'buildgcc --defaults'"
exit 1
fi
#Defaults
GCC_VERSION=4.4.2
GCC_PATCH_FOLDER=gcc-4.x
GMP_VERSION=4.3.1
MPFR_VERSION=2.4.1
if [ $(uname -o) = Msys ]; then
TARGET_LOCATION=/c/msp430-gcc-$GCC_VERSION
else
TARGET_LOCATION=/opt/msp430-gcc-$GCC_VERSION
fi
BINUTILS_VERSION=2.19.1
GNU_MIRROR=ftp.uni-kl.de
BINPACKAGE_NAME=
GDB_VERSION=7.0
INSIGHT_VERSION=6.8-1
BASEDIR="$(pwd)"
SKIP_BINUTILS=0
if [ $# -lt 1 ] || [ "_$1" != _--defaults ]; then
$DIALOG --menu "Select GCC version to build" 13 50 6 1 "gcc-4.4.2" 2 "gcc-4.3.4" 3 "gcc-4.2.4" 4 "gcc-3.3.6" 5 "gcc-3.2.3" 6 "none" 2>/tmp/dialog.ans
if [ $? = 0 -a -e /tmp/dialog.ans ]; then
case "$(cat /tmp/dialog.ans)" in
1)
GCC_VERSION=4.4.2
GCC_PATCH_FOLDER=gcc-4.x
GMP_VERSION=4.3.1
MPFR_VERSION=2.4.1 ;;
2)
GCC_VERSION=4.3.4
GCC_PATCH_FOLDER=gcc-4.x
GMP_VERSION=4.3.1
MPFR_VERSION=2.4.1 ;;
3)
GCC_VERSION=4.2.4
GCC_PATCH_FOLDER=gcc-4.x ;;
4)
GCC_VERSION=3.3.6
GCC_PATCH_FOLDER=gcc-3.4 ;;
5)
GCC_VERSION=3.2.3
GCC_PATCH_FOLDER=gcc-3.3 ;;
6)
GCC_VERSION= ;;
esac
rm /tmp/dialog.ans
TARGET_LOCATION=/opt/msp430-gcc-$GCC_VERSION
else
echo "Build cancelled"
exit
fi
$DIALOG --menu "Select GDB version to build" 10 50 3 1 "gdb-7.0" 2 "gdb-6.8" 3 "none" 2>/tmp/dialog.ans
if [ $? = 0 -a -e /tmp/dialog.ans ]; then
case "$(cat /tmp/dialog.ans)" in
1)
GDB_VERSION=7.0
GDB_PACKAGE_SUFFIX=_gdb_$GDB_VERSION ;;
2)
GDB_VERSION=6.8
GDB_PACKAGE_SUFFIX=_gdb_$GDB_VERSION ;;
3)
GDB_VERSION=
GDB_PACKAGE_SUFFIX= ;;
esac
rm /tmp/dialog.ans
else
echo "Build cancelled"
exit
fi
$DIALOG --menu "Select GNU Insight version to build" 10 50 3 1 "insight-6.8-1" 2 "none" 2>/tmp/dialog.ans
if [ $? = 0 -a -e /tmp/dialog.ans ]; then
case "$(cat /tmp/dialog.ans)" in
1)
INSIGHT_VERSION=6.8-1 ;;
2)
INSIGHT_VERSION= ;;
esac
rm /tmp/dialog.ans
else
echo "Build cancelled"
exit
fi
$DIALOG --inputbox "Enter target toolchain path" 7 50 "$TARGET_LOCATION" 2>/tmp/dialog.ans
if [ $? = 0 -a -e /tmp/dialog.ans ]; then
TARGET_LOCATION="$(cat /tmp/dialog.ans)"
rm /tmp/dialog.ans
else
echo "Build cancelled"
exit
fi
if [ -e $TARGET_LOCATION/bin/msp430-as ]; then
$DIALOG --yesno "Looks like binutils are already installed in $TARGET_LOCATION. Skip building binutils?" 5 50
if [ $? = 0 ]; then
SKIP_BINUTILS=1
fi
fi
$DIALOG --yesno "Create binary package after build?" 5 50
if [ $? = 0 ]; then
BINPACKAGE_NAME="mspgcc-$GCC_VERSION$GDB_PACKAGE_SUFFIX.tar.bz2"
$DIALOG --inputbox "Enter binary package name" 7 50 "$BINPACKAGE_NAME" 2>/tmp/dialog.ans
if [ $? = 0 -a -e /tmp/dialog.ans ]; then
BINPACKAGE_NAME="$(cat /tmp/dialog.ans)"
rm /tmp/dialog.ans
else
echo "Build cancelled"
exit
fi
fi
fi
cat <<_EOF
---------------------------------------------------------------
Building GCC $GCC_VERSION
GDB version: $GDB_VERSION
Target location: "$TARGET_LOCATION"
Binary package name: "$BINPACKAGE_NAME"
---------------------------------------------------------------
_EOF
BUILD_DIR=build
if [ -n "$GCC_VERSION" ]; then
if [ x"$SKIP_BINUTILS" != x"1" ]; then
sh do-binutils.sh "$TARGET_LOCATION" "$BINUTILS_VERSION" "$GNU_MIRROR" "$BUILD_DIR" || exit 1
fi
sh do-gcc.sh "$TARGET_LOCATION" "$GCC_VERSION" "$GNU_MIRROR" "$BUILD_DIR" "$GCC_PATCH_FOLDER" "$GMP_VERSION" "$MPFR_VERSION" || exit 1
sh do-libc.sh "$TARGET_LOCATION" "$BUILD_DIR" || exit 1
fi
if [ -n "$GDB_VERSION" ]; then
sh do-gdb.sh "$TARGET_LOCATION" "$GDB_VERSION" "$GNU_MIRROR" "$BUILD_DIR" gdb || exit 1
fi
if [ -n "$INSIGHT_VERSION" ]; then
sh do-gdb.sh "$TARGET_LOCATION" "$INSIGHT_VERSION" "$GNU_MIRROR" "$BUILD_DIR" insight || exit 1
fi
cat <<_EOF
-------------------------------------------------------------------------------
Build succeeded
Do not forget to add $TARGET_LOCATION/bin to your PATH environment variable
-------------------------------------------------------------------------------
_EOF
if [ -n "$BINPACKAGE_NAME" ]; then
echo "Creating binary package..."
cd "$TARGET_LOCATION"
tar cjf "$BASEDIR/$BINPACKAGE_NAME" *
ls -ldq "$BASEDIR/$BINPACKAGE_NAME"
cd "$BASEDIR"
fi